1 using System.Collections.Generic;
8 public static bool IsARDevice()
11 Application.platform == RuntimePlatform.Android ||
12 Application.platform == RuntimePlatform.IPhonePlayer
16 public static float FloatListAverage(List<float> list)
20 foreach (var value
in list)
25 return average / list.Count;
29 public static float GetNormalizedDegrees(
float value)
33 return (360 + (value % 360));
39 public static T FindAndGetComponent<T>(
string name)
41 var gameObject = GameObject.Find(name);
43 if (gameObject ==
null)
48 return gameObject.GetComponent<T>();
51 public static T FindAndGetComponentAndLogError<T>(
string name,
string message)
53 var result = FindAndGetComponent<T>(name);
55 if (EqualityComparer<T>.Default.Equals(result,
default(T)))
57 Debug.LogError(message);
63 public static GameObject FindAndLogError(
string name,
string message)
65 var go = GameObject.Find(name);
69 Debug.LogError(message);
75 public static Spline BuildSpline(SplineType type, Vector3[] points,
int n,
float alpha)
77 if (type == SplineType.CatmullromSpline)
87 public static void SetActiveOnAllChildren(GameObject go,
bool value)
89 foreach (Transform child
in go.transform)
91 child.gameObject.SetActive(value);
95 public static void SetGameObjectVisible(GameObject go,
bool value)
97 var meshRenderer = go.GetComponent<MeshRenderer>();
98 var skinnedMeshRenderer = go.GetComponent<SkinnedMeshRenderer>();
102 meshRenderer.enabled = value;
105 if (skinnedMeshRenderer)
107 skinnedMeshRenderer.enabled = value;
110 SetActiveOnAllChildren(go, value);
113 public static void HideGameObject(GameObject go)
115 SetGameObjectVisible(go,
false);
118 public static void ShowGameObject(GameObject go)
120 SetGameObjectVisible(go,
true);