Beispiel #1
0
    //导出传入节点的层级,直到某个子节点挂有UIHierarchy组件
    private static void GetChildComponentUtilHierarchy(Transform transRoot, List <UIHierarchy.EffectItemInfo> fxFields, List <UIHierarchy.ItemInfo> fields)
    {
        for (int i = 0; i < transRoot.childCount; i++)
        {
            Transform trans = transRoot.GetChild(i);

            UIHierarchy hrchy = trans.GetComponent <UIHierarchy>();
            if (hrchy != null)
            {
                fields.Add(new UIHierarchy.ItemInfo(hrchy.name, hrchy));
                continue;
            }

            //FxExportItem fxItem = trans.GetComponent<FxExportItem>();
            //if(fxItem != null)
            //{
            //    Object fieldItem = GetChildComponent(fxItem.gameObject) ?? fxItem.transform;
            //    fxFields.Add(new UIHierarchy.EffectItemInfo(fxItem.name, fieldItem, fxItem.transform.parent));
            //}
            //else
            //{
            UIExportItem uiItem = trans.GetComponent <UIExportItem>();
            if (uiItem != null)
            {
                Object fieldItem = GetChildComponent(uiItem.gameObject);
                if (fieldItem == null)
                {
                    fieldItem = uiItem.transform;
                }
                fields.Add(new UIHierarchy.ItemInfo(uiItem.name, fieldItem));
            }
            //}
            GetChildComponentUtilHierarchy(trans, fxFields, fields);
        }
    }
    static void IsExportItem(GameObject go, Rect selectionRect)
    {
        Rect r = new Rect(selectionRect);

        r.x    += r.width - 55f;
        r.width = 25f;

        UIHierarchy uiHierarchy = go.GetComponent <UIHierarchy>();

        if (uiHierarchy)
        {
            return;
        }

        UIExportItem uiExportItem = go.GetComponent <UIExportItem>();

        if (uiExportItem)
        {
            if (GUI.Button(r, "-"))
            {
                GameObject.DestroyImmediate(uiExportItem);
            }
        }
        else
        {
            if (GUI.Button(r, "+"))
            {
                go.AddComponent <UIExportItem>();
            }
        }
    }