/*internal static void UpdateHLInfo(List<h2Info> vList) {
         *
         *  for (var i = 0;i < vList.Count; i++) {
         *      var item = vList[i];
         *      if (item.goHLStatus != h2HLType.Unknown) continue;
         *
         *      if (map.ContainsKey(item.instID)) {
         *          var info = map[item.instID];
         *          item.goHLStatus = h2HLType.Highlight;
         *          item.goHLColor  = info.color;
         *          continue;
         *      }
         *
         *      var p = item.go.transform.parent;
         *      if (p == null) {
         *          item.goHLStatus = h2HLType.None;
         *          continue;
         *      }
         *
         *      var instID = p.gameObject.GetInstanceID();
         *      if (!map.ContainsKey(instID)) {
         *          item.goHLStatus = h2HLType.None;
         *          continue;
         *      }
         *
         *      var info1 = map[instID];
         *
         *      item.goHLStatus = h2HLType.DirectChildren;
         *      item.goHLColor  = info1.color.xAlpha(0.5f);
         *  }
         * }*/

        //static public void Repaint() {
        //    MarkDirty();
        //    WindowX.Hierarchy.Repaint();
        //}

        internal static h2GOHLInfo Get(GameObject go)
        {
            if (go == null)
            {
                return(null);
            }
            var vlbGO = VietLabsRT.Get <Hierarchy2RT> (false);

            if (vlbGO == null)
            {
                return(null);
            }

            var list = vlbGO.listHL;

            if (list == null)
            {
                return(null);
            }

            for (var i = 0; i < list.Count; i++)
            {
                if (list[i].go == go)
                {
                    return(list[i]);
                }
            }
            return(null);
        }
        internal static void ClearColor(GameObject go)
        {
            var vlbGO = VietLabsRT.Get <Hierarchy2RT> (false);

            if (vlbGO == null)
            {
                return;
            }
            vlbGO.listHL.RemoveAll(item => item.go == go);
            Refresh();
        }
        internal static void SetColor(GameObject go, Color c)
        {
            var hlInfo = Get(go);

            if (hlInfo == null)   //new
            //Debug.Log("SetColor ---> " + instID + ":" + c);
            {
                VietLabsRT.Get <Hierarchy2RT>(true).listHL.Add(new h2GOHLInfo {
                    go = go,
                    c  = c
                });
            }
            else     //change color ?
            {
                hlInfo.c = c;
            }

            Refresh();
        }
Exemple #4
0
    static public T Get <T>(bool autoCreate = true) where T : vlbRTBase
    {
        if (_inst == null)
        {
            if (_searched && !autoCreate)
            {
                return(null);
            }

            var all = Resources.FindObjectsOfTypeAll <VietLabsRT>();
            _searched = true;

            if (all.Length > 0)
            {
                _inst = all[0];
            }
            else
            {
                if (!autoCreate)
                {
                    return(null);
                }
                var go = new GameObject {
                    name = "~vietlabs", hideFlags = HideFlags.NotEditable, tag = "EditorOnly"
                };
                _inst = go.AddComponent <VietLabsRT>();
            }
        }

        _inst.gameObject.hideFlags &= ~HideFlags.NotEditable;

        var result = _inst.GetComponent <T>();

        if (autoCreate && result == null)
        {
            result = _inst.gameObject.AddComponent <T>();
            result.Init();
        }
        return(result);
    }