public static T GetComponentInParentSafe <T>(this GameObject obj) where T : Component { if (null == obj.GetComponentInParent <T>()) { InstantLog.StringLogWarning("unsafe GetComponent call"); return(null); } return(obj.GetComponentInParent <T>()); }
public static T AddComponentSafe <T>(this UdonBehaviour obj) where T : Component { if (null == obj || obj.IsDestroyed) { InstantLog.StringLogWarning("unsafe AddComponent call"); return(null); } return(obj.gameObject.AddComponent <T>()); }
public static void InvokeSafe <T>(this Action <T> action, T arg) { if (null == action) { InstantLog.StringLogWarning("Action Missing"); return; } action(arg); }
public static T GetComponentInChildrenAddSafe <T>(this GameObject obj) where T : Component { if (null == obj.GetComponentInChildren <T>()) { InstantLog.StringLogWarning("unsafe GetComponent call"); GameObject _obj = new GameObject(); _obj.transform.SetParent(obj.transform); _obj.AddComponent <T>(); return(null); } return(obj.GetComponentInChildren <T>()); }
public string GetValue(string key) { string value; if (_localizedTextMap.TryGetValue(key, out value)) { return(value); } else { InstantLog.StringLogWarning("Invalid Localization Key"); return(key); } }
public static void CreateInstance() { if (null != _instance) { InstantLog.StringLogWarning("Instance has already maked"); return; } else { GameObject instanceObject = new GameObject(ComponentName); T instance = instanceObject.AddComponent <T>(); _instance = instance; _instance.Initialize(); } }