コード例 #1
0
        internal static void DestroyChild(GameObject parent, string name)
        {
            GameObject gameObject = NGUIUtil.FindChild(parent, name);

            if (gameObject)
            {
                gameObject.transform.parent = null;
                UnityEngine.Object.Destroy(gameObject);
            }
        }
コード例 #2
0
        internal static GameObject SetCloneChild(GameObject parent, GameObject orignal, string name)
        {
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(orignal);

            if (gameObject == null)
            {
                return(null);
            }
            gameObject.name = name;
            NGUIUtil.SetChild(parent, gameObject);
            return(gameObject);
        }
コード例 #3
0
 internal GameOptionToggle(GameObject parent, GameObject target, string prefKey, Sprite icon, string text, bool defaultValue)
 {
     this.Value                   = defaultValue;
     this._prefKey                = prefKey;
     this.gameObject              = NGUIUtil.SetCloneChild(parent, target, prefKey);
     this._toggle                 = gameObject.GetComponentInChildren <HMUI.Toggle>();
     this._toggle.isOn            = this.Value;
     this._nameText               = gameObject.GetComponentInChildren <TextMeshProUGUI>();
     this.NameText                = text;
     this._toggle.didSwitchEvent += new Action <HMUI.Toggle, bool>(this.HandleNoEnergyToggleDidSwitch);
     foreach (MonoBehaviour obj in gameObject.GetComponentsInChildren <UnityEngine.UI.Image>())
     {
         if ("Image".Equals(obj.name))
         {
             ((UnityEngine.UI.Image)obj).sprite = icon;
             return;
         }
     }
 }
コード例 #4
0
 internal static GameObject FindChild(GameObject go, string s)
 {
     if (go == null)
     {
         return(null);
     }
     foreach (Transform transform in go.transform)
     {
         if (transform.gameObject.name == s)
         {
             GameObject result = transform.gameObject;
             return(result);
         }
         GameObject gameObject = NGUIUtil.FindChild(transform.gameObject, s);
         if (gameObject)
         {
             GameObject result = gameObject;
             return(result);
         }
     }
     return(null);
 }
コード例 #5
0
 internal static Transform FindChild(Transform tr, string s)
 {
     return(NGUIUtil.FindChild(tr.gameObject, s).transform);
 }