83 lines
2.4 KiB
C#
83 lines
2.4 KiB
C#
|
|
using BX;
|
|||
|
|
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using UnityEngine;
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20><><EFBFBD>÷<EFBFBD><C3B7><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public class CommonMethods:SingletonManager<CommonMethods>
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// <20>ֻ<EFBFBD><D6BB><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
public void CellPhoneShank()
|
|||
|
|
{
|
|||
|
|
//BXSdk.Instance.Shake();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// ɾ<><C9BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӷ<EFBFBD><D3B6><EFBFBD>
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="node"><3E><><EFBFBD>ڵ<EFBFBD></param>
|
|||
|
|
public void DeleteChildObjects(Transform node)
|
|||
|
|
{
|
|||
|
|
for (int i = 0; i < node.childCount; i++)
|
|||
|
|
{
|
|||
|
|
Object.Destroy(node.GetChild(i).gameObject);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// ŷ<><C5B7><EFBFBD><EFBFBD>ת<EFBFBD><D7AA>Instector<6F><72>rotationֵ
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="up"> GameObject <20><>transform.up</param>
|
|||
|
|
/// <param name="eulerAngle">GameObject <20><>transform.eulerAngle</param>
|
|||
|
|
/// <returns> <20><><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ֵ</returns>
|
|||
|
|
public Vector3 EulerAngles2InspectorRotation(GameObject obj)
|
|||
|
|
{
|
|||
|
|
Vector3 resVector = obj.transform.eulerAngles;
|
|||
|
|
|
|||
|
|
if (Vector3.Dot(obj.transform.up, Vector3.up) >= 0f)
|
|||
|
|
{
|
|||
|
|
if (obj.transform.eulerAngles.x >= 0f && obj.transform.eulerAngles.x <= 90f)
|
|||
|
|
{
|
|||
|
|
resVector.x = obj.transform.eulerAngles.x;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (obj.transform.eulerAngles.x >= 270f && obj.transform.eulerAngles.x <= 360f)
|
|||
|
|
{
|
|||
|
|
resVector.x = obj.transform.eulerAngles.x - 360f;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (Vector3.Dot(obj.transform.up, Vector3.up) < 0f)
|
|||
|
|
{
|
|||
|
|
if (obj.transform.eulerAngles.x >= 0f && obj.transform.eulerAngles.x <= 90f)
|
|||
|
|
{
|
|||
|
|
resVector.x = 180 - obj.transform.eulerAngles.x;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (obj.transform.eulerAngles.x >= 270f && obj.transform.eulerAngles.x <= 360f)
|
|||
|
|
{
|
|||
|
|
resVector.x = 180 - obj.transform.eulerAngles.x;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (obj.transform.eulerAngles.y > 180)
|
|||
|
|
{
|
|||
|
|
resVector.y = obj.transform.eulerAngles.y - 360f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (obj.transform.eulerAngles.z > 180)
|
|||
|
|
{
|
|||
|
|
resVector.z = obj.transform.eulerAngles.z - 360f;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
Debug.Log(" Inspector Rotation: " + " x=" + Mathf.RoundToInt(resVector.x * 1000) / 1000f + " , y=" + Mathf.RoundToInt(resVector.y * 1000) / 1000f + " , z=" + Mathf.RoundToInt(resVector.z * 1000) / 1000f);
|
|||
|
|
|
|||
|
|
return resVector;
|
|||
|
|
}
|
|||
|
|
}
|