Esempio n. 1
0
        void DoAdvanvedView(Type canvasType, bool includeSimple)
        {
            SerializedProperty mainDivisions = serializedObject.FindProperty("mainDivisions");
            SerializedProperty subDivisions  = serializedObject.FindProperty("subDivisions");

            mMain = mainDivisions.isExpanded = EditorGUILayout.Foldout(mainDivisions.isExpanded, "Main Divisions");
            if (mMain)
            {
                EditorGUI.indentLevel++;

                SerializedProperty end = mainDivisions.GetEndProperty();
                while (mainDivisions.NextVisible(true) && SerializedProperty.EqualContents(mainDivisions, end) == false)
                {
                    if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), mainDivisions.name, canvasType) == false)
                    {
                        if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), mainDivisions.name, canvasType) == false)
                        {
                            continue;
                        }
                    }
                    if (includeSimple == false)
                    {
                        if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), mainDivisions.name, typeof(SimpleAttribute)))
                        {
                            continue;
                        }
                    }
                    EditorGUILayout.PropertyField(mainDivisions);
                }
                EditorGUI.indentLevel--;
            }
            mSub = subDivisions.isExpanded = EditorGUILayout.Foldout(subDivisions.isExpanded, "Sub Divisions");
            if (mSub)
            {
                EditorGUI.indentLevel++;
                SerializedProperty end = subDivisions.GetEndProperty();
                while (subDivisions.NextVisible(true) && SerializedProperty.EqualContents(subDivisions, end) == false)
                {
                    if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), subDivisions.name, canvasType) == false)
                    {
                        if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), subDivisions.name, canvasType) == false)
                        {
                            continue;
                        }
                    }
                    if (includeSimple == false)
                    {
                        if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), subDivisions.name, typeof(SimpleAttribute)))
                        {
                            continue;
                        }
                    }
                    EditorGUILayout.PropertyField(subDivisions);
                }
                EditorGUI.indentLevel--;
            }
        }
Esempio n. 2
0
        void DoSimpleView(Type canvasType)
        {
            SerializedProperty it           = serializedObject.FindProperty("mainDivisions");
            SerializedProperty SubDivisions = serializedObject.FindProperty("subDivisions");
            object             mainDivision = ((AxisBase)target).MainDivisions;
            object             subDivision  = ((AxisBase)target).SubDivisions;

            if (it == null || SubDivisions == null)
            {
                return;
            }
            SerializedProperty end = it.GetEndProperty();

            while (it.NextVisible(true) && SerializedProperty.EqualContents(end, it) == false)
            {
                if (it.name == "SimpleView")
                {
                    continue;
                }
                if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), it.name, canvasType) == false)
                {
                    if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), it.name, canvasType) == false)
                    {
                        continue;
                    }
                }
                if (ChartEditorCommon.HasAttributeOfType(typeof(AxisBase), it.name, typeof(SimpleAttribute)) == false)
                {
                    if (ChartEditorCommon.HasAttributeOfType(typeof(ChartDivisionInfo), it.name, typeof(SimpleAttribute)) == false)
                    {
                        continue;
                    }
                }
                SerializedProperty clone = SubDivisions.FindPropertyRelative(it.name);
                if (clone == null)
                {
                    Debug.LogWarning("can't find property " + it.name);
                }
                bool equal = CompareValues(typeof(ChartDivisionInfo), clone.name, mainDivision, subDivision);
                Type t     = getTypeFromField(typeof(ChartDivisionInfo), clone.name);
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = !equal;
                DoMixedFiled(it, t);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    SetValue(clone, it);
                }
            }
            DoAdvanvedView(canvasType, false);
        }
Esempio n. 3
0
        void OnGUI()
        {
            EditorGUILayout.LabelField(string.Format("Select a new {0} name", mType));
            mValue = EditorGUILayout.TextField(mValue);
            bool disabled = false;

            if (mValue.Trim().Length == 0)
            {
                mMessage = null;
                EditorGUILayout.LabelField("Name can't be empty");
                disabled = true;
            }
            else
            if (ChartEditorCommon.IsAlphaNum(mValue) == false)
            {
                mMessage = null;
                EditorGUILayout.LabelField("Name contains invalid charecters");
                disabled = true;
            }
            if (mMessage != null)
            {
                EditorGUILayout.LabelField(mMessage);
            }
            EditorGUILayout.BeginHorizontal();
            GUI.enabled = !disabled;
            if (GUILayout.Button("Rename"))
            {
                if (mStartName == mValue)
                {
                    Close();
                }
                else
                {
                    if (mRenameMethod(mStartName, mValue))
                    {
                        Close();
                    }
                    else
                    {
                        mMessage = string.Format("A {0} by the name {1} already exists", mType, mValue);
                    }
                }
            }
            GUI.enabled = true;
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Cancel"))
            {
                Close();
            }
            EditorGUILayout.EndHorizontal();
        }