Esempio n. 1
0
        void OnGUI()
        {
            m_ScrollViewPos = EditorGUILayout.BeginScrollView(m_ScrollViewPos);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Load", GUILayout.Width(100)))
            {
                DoLoad();
            }

            if (GUILayout.Button("Convert", GUILayout.Width(100)))
            {
                DoConvert();
            }

            YHEditorTools.PushLabelWidth(70);
            m_AllInOne = EditorGUILayout.Toggle("All In One", m_AllInOne, GUILayout.Width(100));
            YHEditorTools.PopLabelWidth();

            YHEditorTools.PushLabelWidth(60);
            m_BeautifyJson = EditorGUILayout.Toggle("Beautify", m_BeautifyJson, GUILayout.Width(100));
            YHEditorTools.PopLabelWidth();

            YHEditorTools.PushLabelWidth(40);
            m_KeyField = EditorGUILayout.TextField("Key", m_KeyField, GUILayout.Width(100));
            YHEditorTools.PopLabelWidth();

            EditorGUILayout.EndHorizontal();

            ShowLangGUI();

            EditorGUILayout.EndScrollView();
        }
Esempio n. 2
0
        void OnGUI()
        {
            m_ScrollViewPos = EditorGUILayout.BeginScrollView(m_ScrollViewPos);

            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Load", GUILayout.Width(100)))
            {
                DoLoad();
            }

            if (GUILayout.Button("Convert", GUILayout.Width(100)))
            {
                DoConvert();
            }

            YHEditorTools.PushLabelWidth(60);
            m_BeautifyJson = EditorGUILayout.Toggle("Beautify", m_BeautifyJson, GUILayout.Width(100));
            YHEditorTools.PopLabelWidth();

            EditorGUILayout.EndHorizontal();

            ShowSheetGUI();

            EditorGUILayout.EndScrollView();
        }
Esempio n. 3
0
        void ShowSheetGUI()
        {
            if (m_Workbook != null)
            {
                for (int i = 0; i < m_SheetConverts.Length; ++i)
                {
                    EditorGUILayout.BeginHorizontal();

                    YHEditorTools.PushLabelWidth(40);
                    m_SheetConverts[i].tableName = EditorGUILayout.TextField("Table:", m_SheetConverts[i].tableName, GUILayout.Width(200));
                    YHEditorTools.PopLabelWidth();

                    m_SheetConverts[i].convertable = EditorGUILayout.Toggle(m_SheetConverts[i].convertable, GUILayout.Width(50));

                    float oldWidth = EditorGUIUtility.labelWidth;
                    EditorGUIUtility.labelWidth = 40;
                    m_SheetConverts[i].dataType = (ConvertSheetDataType)EditorGUILayout.EnumPopup("type", m_SheetConverts[i].dataType, GUILayout.MaxWidth(180));

                    if (m_SheetConverts[i].dataType == ConvertSheetDataType.Dictionary)
                    {
                        m_SheetConverts[i].dictKey = EditorGUILayout.TextField("key", m_SheetConverts[i].dictKey);
                    }

                    EditorGUIUtility.labelWidth = oldWidth;

                    EditorGUILayout.EndHorizontal();
                }
            }
        }
Esempio n. 4
0
        public override void Draw()
        {
            m_Foldout = EditorGUILayout.Foldout(m_Foldout, m_Label);

            if (m_Foldout)
            {
                YHEditorTools.PushIndentLevel(m_Deep + 1);
                YHEditorTools.PushLabelWidth(80);

                GUILayout.BeginVertical();

                //显示元素
                for (int i = 0; i < m_Elements.Count; ++i)
                {
                    object oldElementValue = m_Elements[i].value;
                    m_Elements[i].Draw();
                    if (m_Elements[i].value != oldElementValue)
                    {
                        ReflectionUtils.SetValue(m_Accesses[i], m_Value, m_Elements[i].value);
                    }
                }
                GUILayout.EndVertical();

                YHEditorTools.PopLabelWidth();
                YHEditorTools.PopIndentLevel();
            }
        }
Esempio n. 5
0
        public static object DrawArray(object value, Type type, ref bool foldout, string label)
        {
            int len = 0;

            if (value == null)
            {
                value = ReflectionUtils.InvokeConstructor(type, new object[] { 0 });
            }
            else
            {
                len = ReflectionUtils.GetLength(value);
            }

            foldout = EditorGUILayout.Foldout(foldout, label);

            if (foldout)
            {
                YHEditorTools.PushLabelWidth(80);

                //数组大小
                int newLen = EditorGUILayout.IntField("size", len);
                if (newLen != len)
                {
                    object newValue = ReflectionUtils.InvokeConstructor(type, new object[] { newLen });;

                    for (int i = 0; i < newLen; ++i)
                    {
                        object ele = ReflectionUtils.InvokeMethod(value, "GetValue", new object[] { i < len ? i : len - 1 });
                        ReflectionUtils.InvokeMethod(newValue, "SetValue", new object[] { ele, i });
                    }

                    value = newValue;
                }

                //数组元素
                Type elementType = type.GetElementType();
                for (int i = 0; i < newLen; ++i)
                {
                    object ele    = type.GetMethod("GetValue", new Type[] { typeof(int) }).Invoke(value, new object[] { i });
                    object newEle = YHGUI.DrawElement(ele, elementType, "Element " + i);
                    if (ele != newEle)
                    {
                        ReflectionUtils.InvokeMethod(value, "SetValue", new object[] { newEle, i });
                    }
                }

                YHEditorTools.PopLabelWidth();
            }
            return(value);
        }
Esempio n. 6
0
        void ShowSheetGUI()
        {
            if (m_Workbook != null)
            {
                for (int i = 0; i < m_SheetGens.Length; ++i)
                {
                    EditorGUILayout.BeginHorizontal();

                    YHEditorTools.PushLabelWidth(40);
                    m_SheetGens[i].name = EditorGUILayout.TextField("Class:", m_SheetGens[i].name, GUILayout.Width(200));
                    YHEditorTools.PopLabelWidth();
                    m_SheetGens[i].convertable = EditorGUILayout.Toggle(m_SheetGens[i].convertable, GUILayout.Width(50));

                    EditorGUILayout.EndHorizontal();
                }
            }
        }
Esempio n. 7
0
        public override void Draw()
        {
            int len = m_Elements.Count;

            m_Foldout = EditorGUILayout.Foldout(m_Foldout, m_Label);


            if (m_Foldout)
            {
                YHEditorTools.PushIndentLevel(m_Deep + 1);
                YHEditorTools.PushLabelWidth(80);

                GUILayout.BeginVertical();
                //数组大小
                int newLen = EditorGUILayout.IntField("size", len);
                if (newLen != len)
                {
                    ChangeLength(newLen);
                }

                //数组元素
                for (int i = 0; i < m_Elements.Count; ++i)
                {
                    object oldElementValue = m_Elements[i].value;
                    m_Elements[i].Draw();
                    if (m_Elements[i].value != oldElementValue)
                    {
                        ReflectionUtils.InvokeMethod(m_Value, "SetValue", new object[] { m_Elements[i].value, i });
                    }
                }
                GUILayout.EndVertical();

                YHEditorTools.PopLabelWidth();
                YHEditorTools.PopIndentLevel();
            }
        }
Esempio n. 8
0
 public override void Draw()
 {
     YHEditorTools.PushIndentLevel(m_Deep);
     m_Value = YHGUI.DrawElement(m_Value, m_Type, m_Label);
     YHEditorTools.PopIndentLevel();
 }