13 [
System.Obsolete(
"Use GameObjectExtensions.SetLayerRecursively(gameObject, layer) instead;")]
16 gameObject.SetLayerRecursively(layer);
31 public static float Map(
float minA,
float maxA,
float minB,
float maxB,
float value)
33 return (value - minA) * (maxB / maxA) + minB;
48 public static float MapAndClamp(
float minA,
float maxA,
float minB,
float maxB,
float value)
50 return Mathf.Clamp(Map(minA, maxA, minB, maxB, value), minB, maxB);
65 stageHeadDir.y = 0.0f;
66 stageHeadDir.Normalize();
67 Vector3 sideDir = Vector3.Cross(stageHeadDir, Vector3.up).normalized;
68 Vector3 stageNewPos = stageHeadPos + stageHeadDir * offset.z + Vector3.up * offset.y + sideDir * offset.x;
73 Quaternion rot = Quaternion.FromToRotation(Vector3.forward, toDir.normalized) * Quaternion.Euler(0.0f, yawOffset, 0.0f);
74 tran.localRotation = rot;
88 cylTransform.localRotation = Quaternion.LookRotation(dir) * Quaternion.FromToRotation(Vector3.up, Vector3.forward);
89 Vector3 scale = cylTransform.localScale;
90 scale.y = (a - b).magnitude * 0.5f;
91 cylTransform.localScale = scale;
101 if (t.gameObject && t.gameObject.GetComponent<Renderer>())
103 t.gameObject.GetComponent<Renderer>().material = mat;
106 for (
int ii = 0; ii < t.childCount; ++ii)
108 SetMaterialRecursive(t.GetChild(ii), mat);
125 if (t.gameObject && t.gameObject.GetComponent<Renderer>() && t.gameObject.name == nameToTest)
127 t.gameObject.GetComponent<Renderer>().material = mat;
130 for (
int ii = 0; ii < t.childCount; ++ii)
132 SetMaterialRecursiveForName(t.GetChild(ii), mat, nameToTest);
135 Resources.UnloadUnusedAssets();
144 #if UNITY_WSA && !UNITY_EDITOR 159 int numChildren = t.childCount;
160 for (
int ii = 0; ii < numChildren; ++ii)
162 Transform child = t.GetChild(ii);
163 if (child.name == name)
167 Transform foundIt = GetChildRecursive(child, name);