Skip to content

Commit f566274

Browse files
committed
feat: Add Bounds util
1 parent d00f76c commit f566274

File tree

12 files changed

+111
-0
lines changed

12 files changed

+111
-0
lines changed

Assets/JCSUnity/Scripts/Util/JCS_Bool3.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,19 @@ namespace JCSUnity
1515
[System.Serializable]
1616
public struct JCS_Bool3
1717
{
18+
/* Variables */
19+
1820
public static JCS_Bool3 allTrue { get { return new JCS_Bool3(true, true, true); } }
1921
public static JCS_Bool3 allFalse { get { return new JCS_Bool3(false, false, false); } }
2022

2123
public bool check1;
2224
public bool check2;
2325
public bool check3;
2426

27+
/* Setter & Getter */
28+
29+
/* Functions */
30+
2531
// init specific value
2632
public JCS_Bool3(bool ch1 = false, bool ch2 = false, bool ch3 = false)
2733
{
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* $File: JCS_Bounds.cs $
3+
* $Date: $
4+
* $Revision: $
5+
* $Creator: Jen-Chieh Shen $
6+
* $Notice: See LICENSE.txt for modification and distribution information
7+
* Copyright (c) 2025 by Shen, Jen-Chieh $
8+
*/
9+
using UnityEngine;
10+
11+
namespace JCSUnity
12+
{
13+
/// <summary>
14+
/// Bounds util.
15+
/// </summary>
16+
public static class JCS_Bounds
17+
{
18+
/* Variables */
19+
20+
/* Setter & Getter */
21+
22+
/* Functions */
23+
24+
/// <summary>
25+
/// Return 8 corners from the bounds.
26+
/// </summary>
27+
/// <param name="bounds"> The bounds to get from. </param>
28+
public static Vector3[] Corners(Bounds bounds)
29+
{
30+
Vector3 center = bounds.center;
31+
Vector3 extents = bounds.extents;
32+
33+
return new Vector3[]
34+
{
35+
center + new Vector3(-extents.x, -extents.y, -extents.z), // Bottom-back-left
36+
center + new Vector3(extents.x, -extents.y, -extents.z), // Bottom-back-right
37+
center + new Vector3(-extents.x, -extents.y, extents.z), // Bottom-front-left
38+
center + new Vector3(extents.x, -extents.y, extents.z), // Bottom-front-right
39+
center + new Vector3(-extents.x, extents.y, -extents.z), // Top-back-left
40+
center + new Vector3(extents.x, extents.y, -extents.z), // Top-back-right
41+
center + new Vector3(-extents.x, extents.y, extents.z), // Top-front-left
42+
center + new Vector3(extents.x, extents.y, extents.z) // Top-front-right
43+
};
44+
}
45+
}
46+
}

Assets/JCSUnity/Scripts/Util/JCS_Bounds.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/JCSUnity/Scripts/Util/JCS_Debug.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ namespace JCSUnity
1717
/// </summary>
1818
public static class JCS_Debug
1919
{
20+
/* Variables */
21+
22+
/* Setter & Getter */
23+
24+
/* Functions */
25+
2026
/// <summary>
2127
/// Print out log by deesign by JCSUnity format. (Log)
2228
/// </summary>

Assets/JCSUnity/Scripts/Util/JCS_Logger.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ namespace JCSUnity
3434
/// </summary>
3535
public static class JCS_Logger
3636
{
37+
/* Variables */
38+
39+
/* Setter & Getter */
40+
41+
/* Functions */
42+
3743
/// <summary>
3844
/// JCSUnity custom log function.
3945
/// </summary>

Assets/JCSUnity/Scripts/Util/JCS_Mathf.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ namespace JCSUnity
1616
/// </summary>
1717
public static class JCS_Mathf
1818
{
19+
/* Variables */
20+
1921
public static float ZERO = 0.0f;
2022
public static float D_HALF = 2.0f;
2123
public static float T_HALF = 0.5f;
@@ -25,6 +27,10 @@ public static class JCS_Mathf
2527
// Degree to Radian.
2628
public const float Deg2Rad = Mathf.PI / 180.0f;
2729

30+
/* Setter & Getter */
31+
32+
/* Functions */
33+
2834
/// <summary>
2935
/// Returns the smallest integer greater to or equal to f.
3036
/// </summary>

Assets/JCSUnity/Scripts/Util/JCS_Path.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ namespace JCSUnity
1414
/// </summary>
1515
public static class JCS_Path
1616
{
17+
/* Variables */
18+
19+
/* Setter & Getter */
20+
21+
/* Functions */
22+
1723
/// <summary>
1824
/// Safe way to combine multiple path to one path with slash.
1925
/// </summary>

Assets/JCSUnity/Scripts/Util/JCS_Physics.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ namespace JCSUnity
1717
[Serializable]
1818
public struct JCS_ColliderInfo
1919
{
20+
/* Variables */
21+
22+
/* Setter & Getter */
23+
2024
public float width;
2125
public float height;
2226

@@ -29,6 +33,8 @@ public struct JCS_ColliderInfo
2933
public Vector3 leftBound;
3034
public Vector3 rightBound;
3135

36+
/* Functions */
37+
3238
/// <summary>
3339
/// Find out all four bounding point.
3440
/// </summary>

Assets/JCSUnity/Scripts/Util/JCS_Random.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ namespace JCSUnity
1616
/// </summary>
1717
public static class JCS_Random
1818
{
19+
/* Variables */
20+
21+
/* Setter & Getter */
22+
23+
/* Functions */
24+
1925
/// <summary>
2026
/// Return normal random range.
2127
/// </summary>

Assets/JCSUnity/Scripts/Util/JCS_ResConverter.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@ namespace JCSUnity
1515
/// </summary>
1616
public static class JCS_ResConverter
1717
{
18+
/* Variables */
19+
20+
/* Setter & Getter */
21+
22+
/* Functions */
23+
1824
/// <summary>
1925
/// Turn byte array to texture data.
2026
/// </summary>

0 commit comments

Comments
 (0)