You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			85 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C#
		
	
			
		
		
	
	
			85 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			C#
		
	
| using System.Collections;
 | |
| using UnityEngine;
 | |
| 
 | |
| namespace Game
 | |
| {
 | |
|     public abstract partial class Util
 | |
|     {
 | |
|         public static void Draw(Vector3 start, Vector3 end, Color color, float duration = 0)
 | |
|         {
 | |
|             if (!GameSetting.IsDebugDraw)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
|             Debug.DrawLine(start, end, color, duration);
 | |
|         }
 | |
|         public static void DrawBox(Vector3 center, Vector3 halfExtents, Vector3 castDir, Color color, float duration = 0)
 | |
|         {
 | |
|             if (!GameSetting.IsDebugDraw)
 | |
|             {
 | |
|                 return;
 | |
|             }
 | |
| 
 | |
|             var rot = Quaternion.FromToRotation(Vector3.right, castDir);
 | |
| 
 | |
|             var boxPoints = new Vector3[8];
 | |
|             boxPoints[0] = center + rot * new Vector3(halfExtents.x, halfExtents.y, halfExtents.z);
 | |
|             boxPoints[1] = center + rot * new Vector3(halfExtents.x, halfExtents.y, -halfExtents.z);
 | |
|             boxPoints[2] = center + rot * new Vector3(halfExtents.x, -halfExtents.y, halfExtents.z);
 | |
|             boxPoints[3] = center + rot * new Vector3(halfExtents.x, -halfExtents.y, -halfExtents.z);
 | |
|             boxPoints[4] = center + rot * new Vector3(-halfExtents.x, halfExtents.y, halfExtents.z);
 | |
|             boxPoints[5] = center + rot * new Vector3(-halfExtents.x, halfExtents.y, -halfExtents.z);
 | |
|             boxPoints[6] = center + rot * new Vector3(-halfExtents.x, -halfExtents.y, halfExtents.z);
 | |
|             boxPoints[7] = center + rot * new Vector3(-halfExtents.x, -halfExtents.y, -halfExtents.z);
 | |
| 
 | |
|             for (int i = 0; i < 8; i++)
 | |
|             {
 | |
|                 for (int j = i; j < 8; j++)
 | |
|                 {
 | |
|                     var p1 = boxPoints[i];
 | |
|                     var p2 = boxPoints[j];
 | |
|                     int defCount = 0;
 | |
|                     defCount += (p1.x == p2.x ? 1 : 0);
 | |
|                     defCount += (p1.y == p2.y ? 1 : 0);
 | |
|                     defCount += (p1.z == p2.z ? 1 : 0);
 | |
|                     Debug.DrawLine(boxPoints[i], boxPoints[j], color, duration);
 | |
|                 }
 | |
|             }
 | |
|         }
 | |
|         public static void Print(params object[] values)
 | |
|         {
 | |
|             string text = "";
 | |
|             foreach (object obj in values)
 | |
|             {
 | |
|                 text += Str(obj) + " ";
 | |
|             }
 | |
|             Debug.Log(text);
 | |
|         }
 | |
|         private static string Str(object obj)
 | |
|         {
 | |
|             string ret = "";
 | |
|             if (obj is null)
 | |
|             {
 | |
|                 ret = $"null";
 | |
|             }
 | |
|             else if (obj is string)
 | |
|             {
 | |
|                 ret = $"\"{obj}\"";
 | |
|             }
 | |
|             else if (obj is IEnumerable)
 | |
|             {
 | |
|                 ret += "List[";
 | |
|                 foreach (object subobj in (IEnumerable)obj)
 | |
|                 {
 | |
|                     ret += Str(subobj) + " ";
 | |
|                 }
 | |
|                 ret += "]";
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 ret = obj.ToString();
 | |
|             }
 | |
|             return ret;
 | |
|         }
 | |
|     }
 | |
| } |