Ejemplo n.º 1
0
        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>());
        }
Ejemplo n.º 2
0
        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>());
        }
Ejemplo n.º 3
0
        public static void InvokeSafe <T>(this Action <T> action, T arg)
        {
            if (null == action)
            {
                InstantLog.StringLogWarning("Action Missing");
                return;
            }

            action(arg);
        }
Ejemplo n.º 4
0
        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>());
        }
Ejemplo n.º 5
0
        public string GetValue(string key)
        {
            string value;

            if (_localizedTextMap.TryGetValue(key, out value))
            {
                return(value);
            }
            else
            {
                InstantLog.StringLogWarning("Invalid Localization Key");
                return(key);
            }
        }
Ejemplo n.º 6
0
 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();
     }
 }