Exemplo n.º 1
0
    public override void OnInspectorGUI()
    {
        UISubBase ui = (UISubBase)target;

        if (GUILayout.Button("设置引用对象"))
        {
            ui.SetAllMemberValue();
        }
        base.OnInspectorGUI();
    }
Exemplo n.º 2
0
    private static void GetComponents(Transform root, string parentPath)
    {
        if (root.name.StartsWith("!"))
        {
            return;
        }

        string transName = GetRightName(root.name);

        if (!uniName.Contains(transName))
        {
            uniName.Add(transName);
            //attrList.Add("    public GameObject " + transName + ";\n");
            MonoBehaviour[]          monos = root.GetComponents <MonoBehaviour>();
            Dictionary <string, int> map   = GetMonoBehavNum(monos);

            foreach (string tpe in map.Keys)
            {
                string name = GetRightName(tpe);
                if (IsIgnore(name))
                {
                    continue;
                }

                int count = map[tpe];
                if (count > 1)
                {
                    attrList.Add("    public " + tpe + "[] " + transName + "_" + name + "s;\n");
                }
                else
                {
                    attrList.Add("    public " + tpe + " " + transName + "_" + name + ";\n");
                }
            }
        }

        string thisPath = root.name;

        if (string.IsNullOrEmpty(parentPath) == false)
        {
            thisPath = parentPath + "/" + root.name;
        }

        UISubBase subUI = root.GetComponent <UISubBase>();

        if (null == subUI)
        {
            foreach (Transform child in root)
            {
                GetComponents(child, thisPath);
            }
        }

        GetMethod(root, thisPath);
    }