Esempio n. 1
0
        public override void OnInspectorGUI()
        {
            UtilityEditor.PropertyField("Normal", Normal);
            UtilityEditor.PropertyField("Choose", Choose);

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Normal"))
            {
                ToggleButtonComponent.SetToggleEditor(false);
            }
            if (GUILayout.Button("Choose"))
            {
                ToggleButtonComponent.SetToggleEditor(true);
            }
            GUILayout.EndHorizontal();

            //base.OnInspectorGUI();
            if (!ToggleButtonComponent.bInit)
            {
                ToggleButtonComponent.bInit = true;
                SetDefaultValue(ToggleButtonComponent);
            }

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
            }
        }
Esempio n. 2
0
        public static QRawImage AddComponent()
        {
            QRawImage component = UtilityEditor.ExtensionComponentWhenCreate <QRawImage>(typeof(QRawImage).Name.ToString());

            //设置默认值
            SetDefaultValue(component);
            return(component);
        }
Esempio n. 3
0
        public static QText AddComponent()
        {
            QText component = UtilityEditor.ExtensionComponentWhenCreate <QText>(typeof(QText).Name.ToString());

            //设置默认值
            SetDefaultValue(component);
            return(component);
        }
Esempio n. 4
0
        public static QButton AddComponent()
        {
            QImageBox image     = UtilityEditor.ExtensionComponentWhenCreate <QImageBox>(typeof(QButton).Name.ToString());
            QButton   component = Utility.GetOrAddCompoment <QButton>(image.gameObject);

            //设置默认值
            SetDefaultValue(component);
            return(component);
        }
Esempio n. 5
0
 public override void OnInspectorGUI()
 {
     base.OnInspectorGUI();
     UtilityEditor.PropertyField("KEY", key);
     if (GUI.changed)
     {
         serializedObject.ApplyModifiedProperties();
     }
     if (!RawImageComponent.bInit)
     {
         RawImageComponent.bInit = true;
         SetDefaultValue(RawImageComponent);
     }
 }
Esempio n. 6
0
        public static QToggleButtonGroup AddComponent()
        {
            QToggleButtonGroup component = UtilityEditor.ExtensionComponentWhenCreate <QToggleButtonGroup>(typeof(QToggleButtonGroup).Name.ToString());

            component.list.Clear();

            for (int i = 0; i < 2; i++)
            {
                Selection.activeObject = component;
                QToggleButton button = QToggleButtonEditor.AddComponent();
                component.list.Add(button);
            }
            Selection.activeObject = component;
            return(component);
        }
Esempio n. 7
0
        public void GenerateCodeEditor()
        {
            transformGroup.Clear();
            Transform[] children = CacheTransform.GetComponentsInChildren <Transform>(true);
            for (int i = 0; i < children.Length; i++)
            {
                Transform child    = children[i];
                string    fullName = child.name;
                string[]  tmpName  = fullName.Split('_');
                if (tmpName.Length > 1)
                {
                    Type type;
                    if (name_type.TryGetValue(tmpName[0], out type))
                    {
                        transformGroup.Add(child, type);
                    }
                }
            }

            //读取
            StreamReader streamReader = new StreamReader(UI_TEMPLATE_PATH, Encoding.UTF8);
            string       ClassText    = streamReader.ReadToEnd();

            streamReader.Close();

            //生成
            UIBase       uIBase       = GetComponent <UIBase>();
            string       uiBasePath   = StringUtility.Format(Application.dataPath + "/Lemon/Scripts/UI/{0}/{1}_Generate.cs", uIBase.name, uIBase.name);
            StreamWriter streamWriter = new StreamWriter(uiBasePath, false, Encoding.UTF8);

            //添加自动化的变量
            StringBuilder stringBuilder = StringUtility.GetStringBuilder();

            stringBuilder.Append("\n");
            Dictionary <Transform, Type> .Enumerator enumerator = transformGroup.GetEnumerator();
            while (enumerator.MoveNext())
            {
                string name = enumerator.Current.Key.name;
                Type   type = enumerator.Current.Value;
                stringBuilder.Append("        public " + type.Name + " " + name + "; ");
                stringBuilder.Append("\n");
            }

            ClassText = ClassText.Replace("UITemplate", uIBase.name);
            ClassText = ClassText.Replace(KEY_VARIABLE, KEY_VARIABLE + stringBuilder.ToString());

            //添加自动化的变量路径
            stringBuilder = StringUtility.GetStringBuilder();
            stringBuilder.Append("\n");
            enumerator = transformGroup.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Transform childTransform = enumerator.Current.Key;
                Type      type           = enumerator.Current.Value;
                stringBuilder.Append("            " + childTransform.name + " = " + "CacheTransform.Find(\"" + UtilityEditor.GetPath(childTransform, CacheTransform) + "\").GetComponent<" + type.Name + ">();\n");
            }

            ClassText = ClassText.Replace(KEY_PATH, KEY_PATH + stringBuilder.ToString());

            streamWriter.Write(ClassText);
            streamWriter.Close();

            UnityEditor.AssetDatabase.Refresh();
        }