コード例 #1
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default, string elementsLabel = "")
    {
        bool
            showListLabel = (options & EditorListOption.ListLabel) != 0,
            showListSize  = (options & EditorListOption.ListSize) != 0;


        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
            if (showListSize && list.isExpanded)
            {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
        }

        if (!showListLabel || list.isExpanded)
        {
            if (showListSize & !showListLabel)
            {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"), GUIContent.none);
            }

            ShowElements(list, options, elementsLabel);
        }

        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #2
0
    //---------------------------------------------------------------------------------------------------------
    private static void DisplayElements(SerializedProperty _list, EditorListOption _options)
    {
        bool showLabels  = (_options & EditorListOption.ElementLabels) != 0;
        bool showButtons = (_options & EditorListOption.ElementButtons) != 0;

        for (int i = 0; i < _list.arraySize; i++)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
            }

            var element = _list.GetArrayElementAtIndex(i);
            if (showLabels)
            {
                EditorGUILayout.PropertyField(element, true);
            }
            else
            {
                EditorGUILayout.PropertyField(element, GUIContent.none, true);
            }

            if (showButtons)
            {
                DrawAndHandleElementButtons(_list, i);
                EditorGUILayout.EndHorizontal();
            }
        }
    }
コード例 #3
0
    public static void Show(SerializedProperty list, string str_lbl, string tooltip, EditorListOption options = EditorListOption.Default)
    {
        bool showListLabel = (options & EditorListOption.ListLabel) != 0;
        bool showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list, new GUIContent(str_lbl, tooltip));
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded)
        {
            SerializedProperty size = list.FindPropertyRelative("Array.size");
            if (showListSize)
            {
                EditorGUILayout.PropertyField(size);
            }
            if (size.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
            }
            else
            {
                ShowElements(list, options);
            }
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #4
0
ファイル: EditorList.cs プロジェクト: dzakwan1101/tugas
    private static void ShowElements(SerializedProperty list, EditorListOption options)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;
        bool showButtons       = (options & EditorListOption.Buttons) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
            }
            if (showElementLabels)
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), true);
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
            }
            if (showButtons && GUILayout.Button(deleteButtonContent, EditorStyles.miniButton, GUILayout.Width(20)))
            {
                list.DeleteArrayElementAtIndex(i);
            }
            if (showButtons)
            {
                EditorGUILayout.EndHorizontal();
            }
        }
    }
コード例 #5
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default)
    {
        bool
            showListLabel = (options & EditorListOption.ListLabel) != 0,
            showListSize  = (options & EditorListOption.ListSize) != 0;


        Debug.Log(list.isArray);

        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded)
        {
            if (showListSize)
            {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
            ShowElements(list, options);
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #6
0
ファイル: EditorList.cs プロジェクト: HernanMGC/ArkanoidXaloc
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default, string helpBox = "")
    {
        if (!list.isArray)
        {
            EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
            return;
        }

        bool showListLabel = (options & EditorListOption.ListLabel) != 0;
        bool showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }

        if (helpBox.Length > 0)
        {
            EditorGUILayout.HelpBox(helpBox, MessageType.Info);
        }

        if (!showListLabel || list.isExpanded)
        {
            if (showListSize)
            {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
            ShowElements(list, options);
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #7
0
    // Function to ovveride and display custom object array in inspector
    public void ArrayGUI(string label, string name, EditorListOption options = EditorListOption.Default)
    {
        bool showListLabel      = (options & EditorListOption.ListLabel) != 0;
        bool showListSize       = (options & EditorListOption.ListSize) != 0;
        SerializedProperty list = serializedObject.FindProperty(name);

        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list, new GUIContent(label));
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded)
        {
            if (showListSize)
            {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
            for (int i = 0; i < list.arraySize; i++)
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
            }
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #8
0
ファイル: EditorList.cs プロジェクト: SethSR/Mech-Game
    public static void Show(SerializedProperty list,
	                        EditorListOption options = EditorListOption.Default)
    {
        if (!list.isArray) {
            EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
            return;
        }
        bool showListLabel = (options & EditorListOption.ListLabel) != 0;
        bool showListSize  = (options & EditorListOption.ListSize)  != 0;
        if (showListLabel) {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded) {
            SerializedProperty size = list.FindPropertyRelative("Array.size");
            if (showListSize) {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
            if (size.hasMultipleDifferentValues) {
                EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
            } else {
                ShowElements(list, options);
            }
        }
        if (showListLabel) {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #9
0
    private static void ShowElements(SerializedProperty list, EditorListOption options)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0,
             showButtons       = (options & EditorListOption.Buttons) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
            }
            if (showElementLabels)
            {
                var prop = list.GetArrayElementAtIndex(i);
                EditorGUILayout.PropertyField(prop, true);
            }
            else
            {
                Debug.Log("No element labels.");
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
            }
            if (showButtons)
            {
                ShowButtons(list, i);
                EditorGUILayout.EndHorizontal();
            }
        }
    }
コード例 #10
0
    private static void ShowElements(SerializedProperty list, EditorListOption options)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0,
             showButtons       = (options & EditorListOption.Buttons) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
            }
            if (showElementLabels)
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
            }
            if (showButtons)
            {
                ShowButtons(list, i);
                EditorGUILayout.EndHorizontal();
            }
        }
        if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton))
        {
            list.arraySize += 1;
        }
    }
コード例 #11
0
        public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default)
        {
            if (list == null)
            {
                EditorGUILayout.HelpBox("The list provided is null", MessageType.Error);
                return;
            }
            if (!list.isArray)
            {
                EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
                return;
            }

            bool showListLabel       = (options & EditorListOption.ListLabel) != 0,
                 showListSize        = (options & EditorListOption.ListSize) != 0,
                 showListOverride    = (options & EditorListOption.ShowMultiListOverride) != 0,
                 showListSizeInLabel = (options & EditorListOption.ShowListSizeInLabel) != 0;


            if (showListLabel)
            {
                if (showListSizeInLabel)
                {
                    EditorGUILayout.PropertyField(list);
                }
                else
                if (list.hasMultipleDifferentValues && showListOverride)
                {
                    EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
                }
                else
                {
                    EditorGUILayout.PropertyField(list, new GUIContent(list.name + " [" + list.arraySize + "]"));
                }
                EditorGUI.indentLevel += 1;
            }
            if (!showListLabel || list.isExpanded)
            {
                SerializedProperty size = list.FindPropertyRelative("Array.size");
                if (showListSize)
                {
                    EditorGUILayout.PropertyField(size);
                }
                if (size.hasMultipleDifferentValues && showListOverride)
                {
                    EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
                }
                else
                {
                    ShowElements(list, options);
                }
            }
            if (showListLabel)
            {
                EditorGUI.indentLevel -= 1;
            }
        }
コード例 #12
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default, ElementCondition condition = null)
    {
        ConditionFullfiled = true;
        InvalidElements.Clear();

        if (!list.isArray)
        {
            EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
            return;
        }

        bool showListLabel = (options & EditorListOption.ListLabel) != 0,
             showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }

        if (!showListLabel || list.isExpanded)
        {
            //if (showListSize)
            //	EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            //ShowElements(list, options);
            SerializedProperty size = list.FindPropertyRelative("Array.size");
            if (showListSize)
            {
                EditorGUILayout.PropertyField(size);
            }
            if (size.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
            }
            else
            {
                ShowElements(list, options, condition);
            }
        }

        if (!ConditionFullfiled)
        {
            string number = "";
            foreach (int i in InvalidElements)
            {
                number += i + ", ";
            }

            EditorGUILayout.HelpBox("Elements: " + number + "are not fulfiling given conditions!", MessageType.Error);
        }

        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #13
0
ファイル: Tools.cs プロジェクト: yazici/SurvivalGame
        private static void ShowElement(SerializedProperty element, EditorListOption options)
        {
            var tagProperty = element.FindPropertyRelative("Tag");

            tagProperty.stringValue = EditorGUILayout.TextField(tagProperty.stringValue);

            var weightProperty = element.FindPropertyRelative("Weight");

            weightProperty.floatValue = EditorGUILayout.FloatField(weightProperty.floatValue);
        }
コード例 #14
0
    static void ShowElements(SerializedProperty list, EditorListOption options, Func <SerializedProperty, int, string> getCustomLabel)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;
        bool showButtons       = (options & EditorListOption.Buttons) != 0;
        bool buttonsAreBelow   = (options & EditorListOption.ButtonsBelow) != 0;

        for (int index = 0; index < list.arraySize; index++)
        {
            if (showButtons && !buttonsAreBelow)
            {
                EditorGUILayout.BeginHorizontal();
            }

            /// the array item
            if (showElementLabels)
            {
                if (getCustomLabel != null)
                {
                    SerializedProperty element = list.GetArrayElementAtIndex(index);
                    EditorGUILayout.PropertyField(element, new GUIContent(getCustomLabel(element, index)));
                }
                else
                {
                    EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(index));
                }
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(index), GUIContent.none);
            }

            /// for showing the buttons
            if (showButtons && list.GetArrayElementAtIndex(index).isExpanded)
            {
                if (buttonsAreBelow)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.Space(10);
                }
                ShowButtons(list, index);
                EditorGUILayout.EndHorizontal();
            }
        }

        if (showButtons && GUILayout.Button(AddButtonContent, EditorStyles.miniButton))
        {
            list.arraySize += 1;
        }
    }
コード例 #15
0
    private static void ShowElements(SerializedProperty list, EditorListOption options, string elementsLabel)
    {
        bool
            showElementLabels = (options & EditorListOption.ElementLabels) != 0,
            showButtons       = (options & EditorListOption.Buttons) != 0,
            showChildren      = (options & EditorListOption.Children) != 0,
            moveButton        = (options & EditorListOption.MoveButton) != 0,
            showListSize      = (options & EditorListOption.ListSize) != 0;

        if (showButtons && !showListSize && list.arraySize < 1)
        {
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(EditorGUI.indentLevel * 15);
            if (GUILayout.Button(duplicateButtonContent, GUILayout.Width(60f)))
            {
                list.InsertArrayElementAtIndex(0);
            }
            EditorGUILayout.EndHorizontal();
        }

        for (int i = 0; i < list.arraySize; i++)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
            }
            if (showElementLabels)
            {
                if (elementsLabel == "")
                {
                    EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), showChildren);
                }
                else
                {
                    EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), new GUIContent(elementsLabel + " " + i.ToString()), showChildren);
                }
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none, showChildren);
            }
            if (showButtons)
            {
                ShowButtons(list, i, moveButton);
                EditorGUILayout.EndHorizontal();
            }
        }
    }
コード例 #16
0
    private static void ShowElements(SerializedProperty list, EditorListOption options)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (showElementLabels)
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
            }
        }
    }
コード例 #17
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default)
    {
        if (!list.isArray)
        {
            EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
            return;
        }

        bool
            showListLabel = (options & EditorListOption.ListLabel) != 0,
            showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            list.isExpanded = true;
            EditorGUILayout.LabelField(list.displayName);
            //EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }

        if (showListLabel)
        {
        }

        if (!showListLabel || list.isExpanded)
        {
            SerializedProperty size = list.FindPropertyRelative("Array.size");
            if (showListSize)
            {
                EditorGUILayout.PropertyField(size);
            }
            if (size.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
            }
            else
            {
                ShowElements(list, options);
            }
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #18
0
    //---------------------------------------------------------------------------------------------------------
    public static void Display(SerializedProperty _list, EditorListOption _options = EditorListOption.Default)
    {
        bool showLabel   = (_options & EditorListOption.ListLabel) != 0;
        bool showSize    = (_options & EditorListOption.ListSize) != 0;
        bool showButtons = (_options & EditorListOption.ListButtons) != 0;

        if (showLabel)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(_list);
                if (GUILayout.Button(BtnAddNew, EditorStyles.miniButtonLeft, miniButtonWidth))
                {
                    _list.arraySize++;
                }
                if (GUILayout.Button(BtnClearAll, EditorStyles.miniButtonRight, miniButtonWidth))
                {
                    _list.ClearArray();
                }
                EditorGUILayout.EndHorizontal();
                EditorGUI.indentLevel++;
            }
            else
            {
                EditorGUILayout.PropertyField(_list);
                EditorGUI.indentLevel++;
            }
        }

        if (!_list.isExpanded)
        {
            if (showSize)
            {
                EditorGUILayout.PropertyField(_list.FindPropertyRelative("Array.size"));
            }

            DisplayElements(_list, _options);
        }

        if (showLabel)
        {
            EditorGUI.indentLevel--;
        }
    }
コード例 #19
0
        private void ShowGestureListElements(SerializedProperty list, EditorListOption options)
        {
            if (!list.isArray)
            {
                EditorGUILayout.HelpBox(list.name + " is neither an array nor a list", MessageType.Error);
                return;
            }

            bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;
            bool showButtons       = (options & EditorListOption.Buttons) != 0;

            // render the list
            for (int i = 0; i < list.arraySize; i++)
            {
                string controlName = "Gesture Control " + i;

                if (showButtons)
                {
                    EditorGUILayout.BeginHorizontal();
                }
                if (showElementLabels)
                {
                    EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
                }
                else
                {
                    //Was is this one?
                    GUI.SetNextControlName(controlName);
                    EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
                }
                if (showButtons)
                {
                    ShowGestureListTotalExamples(list, i);
                    ShowGestureListButtons(list, i);
                    EditorGUILayout.EndHorizontal();
                }
            }

            // if the list is empty show the plus + button
            if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton))
            {
                vrGestureManager.CreateGesture("Gesture 1");
            }
        }
コード例 #20
0
    private static void ShowElements(SerializedProperty list, EditorListOption options)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            SerializedProperty li = list.GetArrayElementAtIndex(i);
            if (li.isArray)
            {
                Debug.Log("Es array");
                Show(list.GetArrayElementAtIndex(i), options);
            }
            else
            {
                Debug.Log("No es array");
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
            }
        }
    }
コード例 #21
0
    private static void ShowElements(SerializedProperty list, EditorListOption options, ElementCondition condition)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0,
             showButtons       = (options & EditorListOption.Buttons) != 0,
             showAdd           = (options & EditorListOption.AddButton) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (condition != null && !condition(list.GetArrayElementAtIndex(i)))
            {
                ConditionFullfiled = false;
                InvalidElements.Add(i);
            }

            EditorGUILayout.BeginVertical();

            if (showButtons)
            {
                GUILayout.BeginHorizontal();
            }
            if (showElementLabels)
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUILayout.ExpandWidth(true));
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none, GUILayout.ExpandWidth(true));
            }
            if (showButtons)
            {
                ShowButtons(list, i);
                GUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
        }
        if (((showButtons && list.arraySize == 0) || showAdd) && GUILayout.Button(addButtonContent, EditorStyles.miniButton))
        {
            list.arraySize++;
        }
    }
コード例 #22
0
	private static void ShowElements (SerializedProperty list, EditorListOption options) {

		bool showButtons = (options & EditorListOption.Buttons) != 0;
		/*
		 * Loop through each element in the array
		 */
		for (int i = 0; i < list.arraySize; i++) {
				//Place the objects side by side
				EditorGUILayout.BeginHorizontal();
				//Create an Input Slot
				EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));

				//Show both buttons plus and minus
				ShowButtons(list, i);
				EditorGUILayout.EndHorizontal();
				//Continue placing the objects below
		}
		if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton)) {
			list.arraySize += 1;
		}
	}
コード例 #23
0
        private static void ShowElements(SerializedProperty list, EditorListOption options)
        {
            bool showButtons = (options & EditorListOption.Buttons) != 0;

            Type elementType = null;

            for (int i = 0; i < list.arraySize; i++)
            {
                if (showButtons)
                {
                    EditorGUILayout.BeginHorizontal();
                }

                var element = list.GetArrayElementAtIndex(i);
                if (elementType == null)
                {
                    elementType = list.GetFieldType().GetGenericArguments()[0];
                }

                if (elementType.IsSubclassOf(typeof(Object)))
                {
                    EditorGUILayout.ObjectField(ObjectNames.NicifyVariableName(elementType.Name) + " " + i, element.objectReferenceValue, elementType, true);
                }
                else
                {
                    EditorGUILayout.PropertyField(element, new GUIContent(ObjectNames.NicifyVariableName(elementType.Name) + " " + i), true);
                }

                if (showButtons)
                {
                    ShowButtons(list, i);
                    EditorGUILayout.EndHorizontal();
                }
            }

            if (showButtons && list.arraySize == 0 && GUILayout.Button(AddButtonContent, EditorStyles.miniButton))
            {
                list.arraySize += 1;
            }
        }
コード例 #24
0
ファイル: WMG_E_Util.cs プロジェクト: Vivek-sagar/PhysicsGame
    // Function to ovveride and display custom object array in inspector
    public void ArrayGUI(string label, string name, EditorListOption options = EditorListOption.Default)
    {
        bool showListLabel = (options & EditorListOption.ListLabel) != 0;
        bool showListSize = (options & EditorListOption.ListSize) != 0;
        SerializedProperty list = serializedObject.FindProperty(name);

        if (showListLabel) {
            EditorGUILayout.PropertyField(list, new GUIContent(label));
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded) {
            if (showListSize) {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
            for (int i = 0; i < list.arraySize; i++) {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
            }
        }
        if (showListLabel) {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #25
0
ファイル: EditorList.cs プロジェクト: SethSR/Mech-Game
 static void ShowElements(SerializedProperty list, EditorListOption options)
 {
     bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;
     bool showButtons       = (options & EditorListOption.Buttons)       != 0;
     for (int i = 0; i < list.arraySize; ++i) {
         if (showButtons) {
             EditorGUILayout.BeginHorizontal();
         }
         if (showElementLabels) {
             EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));
         } else {
             EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
         }
         if (showButtons) {
             ShowButtons(list, i);
             EditorGUILayout.EndHorizontal();
         }
     }
     if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton)) {
         list.arraySize += 1;
     }
 }
コード例 #26
0
        public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default,
                                string elementLabel = null, string addButtonText = "+", string addButtonToolTip = "Add Element")
        {
            if (!list.isArray)
            {
                EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
                return;
            }

            bool
                showListLabel = (options & EditorListOption.ListLabel) != 0,
                showListSize  = (options & EditorListOption.ListSize) != 0;

            if (showListLabel)
            {
                EditorGUILayout.PropertyField(list);
                EditorGUI.indentLevel += 1;
            }
            if (!showListLabel || list.isExpanded)
            {
                SerializedProperty size = list.FindPropertyRelative("Array.size");
                if (showListSize)
                {
                    EditorGUILayout.PropertyField(size);
                }
                if (size.hasMultipleDifferentValues)
                {
                    EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
                }
                else
                {
                    ShowElements(list, options, elementLabel, addButtonText, addButtonToolTip);
                }
            }
            if (showListLabel)
            {
                EditorGUI.indentLevel -= 1;
            }
        }
コード例 #27
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Defalut)
    {
        if (!list.isArray)
        {
            EditorGUILayout.HelpBox(list.name + "는 배열이나 리스트가 아니므로 Inspector에 표시할 수 없습니다. EditorGUILayout.PropertyField 함수의 사용을 추천합니다!", MessageType.Error);
            return;
        }

        bool
            showListLabel = (options & EditorListOption.ListLabel) != 0,
            showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel++;
        }
        if (!showListLabel || list.isExpanded)
        {
            SerializedProperty size = list.FindPropertyRelative("Array.size");
            if (showListSize)
            {
                EditorGUILayout.PropertyField(size);
            }
            if (size.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
            }
            else
            {
                ShowElements(list, options);
            }
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel--;
        }
    }
コード例 #28
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default)
    {
        if (!list.isArray)
        {
            EditorGUILayout.HelpBox("Not a List nor array!", MessageType.Error);
        }
        bool showListLabel = (options & EditorListOption.ListLabel) != 0;
        bool showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            //EditorGUILayout.PropertyField (list,true);
            EditorGUILayout.PropertyField(list);
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded)
        {
            SerializedProperty size = list.FindPropertyRelative("Array.size");

            if (showListSize)
            {
                EditorGUILayout.PropertyField(size);
            }
            if (size.hasMultipleDifferentValues)
            {
                EditorGUILayout.HelpBox("Different size!", MessageType.Warning);
            }
            else
            {
                ShowElements(list, options);
            }
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #29
0
	public static void Show (SerializedProperty list, string str_lbl, string tooltip, EditorListOption options = EditorListOption.Default) {

		bool showListLabel = (options & EditorListOption.ListLabel) != 0;
		bool showListSize = (options & EditorListOption.ListSize) != 0;
		if (showListLabel) {
			EditorGUILayout.PropertyField(list, new GUIContent(str_lbl, tooltip));
			EditorGUI.indentLevel += 1;
		}
		if (!showListLabel || list.isExpanded) {
			SerializedProperty size = list.FindPropertyRelative("Array.size");
			if (showListSize) {
				EditorGUILayout.PropertyField(size);
			}
			if (size.hasMultipleDifferentValues) {
				EditorGUILayout.HelpBox("Not showing lists with different sizes.", MessageType.Info);
			}
			else {
				ShowElements(list, options);
			}
		}
		if (showListLabel) {
			EditorGUI.indentLevel -= 1;
		}
	}
コード例 #30
0
    public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.Default, Func <SerializedProperty, int, string> getCustomLabel = null, string customTitle = "")
    {
        if (!list.isArray)
        {
            EditorGUILayout.HelpBox(list.name + " is neither an array nor a list!", MessageType.Error);
            return;
        }

        bool showListLabel = (options & EditorListOption.ListLabel) != 0;
        bool showListSize  = (options & EditorListOption.ListSize) != 0;

        if (showListLabel)
        {
            if (customTitle != "")
            {
                EditorGUILayout.PropertyField(list, new GUIContent(customTitle), false);
            }
            else
            {
                EditorGUILayout.PropertyField(list, false);
            }
            EditorGUI.indentLevel += 1;
        }
        if (!showListLabel || list.isExpanded)
        {
            if (showListSize)
            {
                EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
            }
            ShowElements(list, options, getCustomLabel);
        }
        if (showListLabel)
        {
            EditorGUI.indentLevel -= 1;
        }
    }
コード例 #31
0
    private static void ShowElements(SerializedProperty list, EditorListOption options)
    {
        bool showButtons = (options & EditorListOption.Buttons) != 0;

        /*
         * Loop through each element in the array
         */
        for (int i = 0; i < list.arraySize; i++)
        {
            //Place the objects side by side
            EditorGUILayout.BeginHorizontal();
            //Create an Input Slot
            EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));

            //Show both buttons plus and minus
            ShowButtons(list, i);
            EditorGUILayout.EndHorizontal();
            //Continue placing the objects below
        }
        if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton))
        {
            list.arraySize += 1;
        }
    }
コード例 #32
0
ファイル: Tools.cs プロジェクト: yazici/SurvivalGame
            public static void Show(SerializedProperty list, EditorListOption options = EditorListOption.All)
            {
                bool showListLabel = (options & EditorListOption.ListLabel) != 0;
                bool showListSize  = (options & EditorListOption.ListSize) != 0;

                int oldIndentLevel = EditorGUI.indentLevel;

                if (showListLabel)
                {
                    EditorGUILayout.PropertyField(list);
                    EditorGUI.indentLevel += 1;
                }
                if (!showListLabel || list.isExpanded)
                {
                    if (showListSize)
                    {
                        EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
                    }

                    ShowElements(list, options);
                }

                EditorGUI.indentLevel = oldIndentLevel;
            }
コード例 #33
0
	public void ArrayGUIoc<T>(WMG_List<T> observableCollection, string label, string name, SerializedObject serObj, EditorListOption options = EditorListOption.Default) {
		bool showListLabel = (options & EditorListOption.ListLabel) != 0;
		bool showListSize = (options & EditorListOption.ListSize) != 0;
		SerializedProperty list = serObj.FindProperty(name);
		
		if (showListLabel) {
			EditorGUILayout.PropertyField(list, new GUIContent(label));
			EditorGUI.indentLevel += 1;
		}
		if (!showListLabel || list.isExpanded) {
			int prevSize = list.arraySize;
			if (showListSize) {
				EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
			}
			// The size changed notify observableCollection of this change
			if (prevSize != list.arraySize) {
				if (Application.isPlaying) {
					list.serializedObject.ApplyModifiedProperties ();
					observableCollection.SizeChangedViaEditor();
				}
			}

			for (int i = 0; i < list.arraySize; i++) {
				SerializedProperty prop = list.GetArrayElementAtIndex(i);
				if (prop.propertyType == SerializedPropertyType.String) {
					string prev = prop.stringValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.stringValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Float) {
					float prev = prop.floatValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.floatValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Color) {
					Color prev = prop.colorValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.colorValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Vector2) {
					Vector2 prev = prop.vector2Value;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.vector2Value) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.ObjectReference) {
					UnityEngine.Object prev = prop.objectReferenceValue;
					EditorGUILayout.PropertyField(prop);
					if (prev != prop.objectReferenceValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor(i);
					}
				}
				else if (prop.propertyType == SerializedPropertyType.Boolean) {
					bool prev = prop.boolValue;
					EditorGUILayout.PropertyField (prop);
					if (prev != prop.boolValue) {
						list.serializedObject.ApplyModifiedProperties ();
						observableCollection.ValueChangedViaEditor (i);
					}
				}
			}
		}
		if (showListLabel) {
			EditorGUI.indentLevel -= 1;
		}
	}
コード例 #34
0
    private static void ShowElements(SerializedProperty moves, SerializedProperty list, EditorListOption options)
    {
        bool showElementLabels = (options & EditorListOption.ElementLabels) != 0;
        bool showButtons       = (options & EditorListOption.Buttons) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (showButtons)
            {
                EditorGUILayout.BeginHorizontal();
            }
            if (showElementLabels)
            {
                SerializedProperty tileConfiguration = list.GetArrayElementAtIndex(i);
                SerializedProperty position          = tileConfiguration.FindPropertyRelative("position");
                SerializedProperty xPosition         = position.FindPropertyRelative("x");
                SerializedProperty yPosition         = position.FindPropertyRelative("y");
                SerializedProperty personality       = tileConfiguration.FindPropertyRelative("personalityIndex");

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField("X", GUILayout.Width(30.0f));
                xPosition.floatValue = EditorGUILayout.FloatField(xPosition.floatValue);
                EditorGUILayout.LabelField("Y", GUILayout.Width(30.0f));
                yPosition.floatValue = EditorGUILayout.FloatField(yPosition.floatValue);

                EditorGUILayout.LabelField("Personality", GUILayout.Width(100.0f));
                personality.intValue = EditorGUILayout.IntField(personality.intValue);

                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), GUIContent.none);
            }
            if (showButtons)
            {
                ShowButtons(list, i);
                EditorGUILayout.EndHorizontal();
            }
            if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButtonMid))
            {
                list.arraySize += 1;
            }
        }
    }
    private static void ShowElements(SerializedProperty list, GUIStyle toggled, GUIStyle untoggled, EditorListOption options)
    {
        bool
            showElementLabels = (options & EditorListOption.ElementLabels) != 0,
            showButtons       = (options & EditorListOption.Buttons) != 0;

        for (int i = 0; i < list.arraySize; i++)
        {
            if (list.GetArrayElementAtIndex(i).objectReferenceValue != null)
            {
                PlayerMovementRailV1 rail = (PlayerMovementRailV1)list.GetArrayElementAtIndex(i).objectReferenceValue;

                if (targetScript.isEditing == true)
                {
                    if (rail.isEditing)
                    {
                        HorizontalLine(Color.red);
                        GUIStyle s = new GUIStyle(EditorStyles.boldLabel);
                        EditorGUILayout.LabelField("Rail Name: " + rail.name + "", s);

                        if (showButtons)
                        {
                            EditorGUILayout.BeginHorizontal();
                        }
                        if (showElementLabels)
                        {
                            EditorGUILayout.ObjectField("Rail Object", list.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject), true);
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                        }
                        else
                        {
                            EditorGUILayout.ObjectField("Rail Object", list.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject), true);
                            EditorGUILayout.EndHorizontal();
                        }

                        EditorGUI.BeginDisabledGroup(false);
                        rail.railSwitchColliderSize = EditorGUILayout.Vector3Field("Switch collider size:", rail.railSwitchColliderSize);
                        DrawFields(list.GetArrayElementAtIndex(i));
                        EditorGUI.EndDisabledGroup();
                        EditorGUILayout.BeginHorizontal();
                        if (showButtons)
                        {
                            ShowButtons(list, toggled, untoggled, i);
                            EditorGUILayout.EndHorizontal();
                            GUILayout.Space(10f);
                        }
                        HorizontalLine(Color.red);
                    }
                }
                else
                {
                    HorizontalLine(Color.grey);
                    GUIStyle s = new GUIStyle(EditorStyles.boldLabel);
                    EditorGUILayout.LabelField("Rail Name: " + rail.name + "", s);
                    rail.editorCollapsed = EditorGUILayout.Foldout(rail.editorCollapsed, "Parameters", true);


                    if (rail.editorCollapsed)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        if (showButtons)
                        {
                            EditorGUILayout.BeginHorizontal();
                        }
                        if (showElementLabels)
                        {
                            EditorGUILayout.ObjectField("Rail Object", list.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject), true);
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                        }
                        else
                        {
                            EditorGUILayout.ObjectField("Rail Object", list.GetArrayElementAtIndex(i).objectReferenceValue, typeof(GameObject), true);
                            EditorGUILayout.EndHorizontal();
                        }
                        DrawFields(list.GetArrayElementAtIndex(i));

                        EditorGUI.EndDisabledGroup();
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (showButtons)
                    {
                        ShowButtons(list, toggled, untoggled, i);
                        EditorGUILayout.EndHorizontal();
                        GUILayout.Space(10f);
                    }
                }
            }
        }
        //if (showButtons && list.arraySize == 0 && GUILayout.Button(addButtonContent, EditorStyles.miniButton))
        //{
        //    list.arraySize += 1;
        //}
    }