protected static void DoPicking(Rect rect, SerializedProperty bodyMask, int count)
 {
   if (!(bool) ((Object) BodyMaskEditor.styles.PickingTexture.image))
     return;
   int controlId = GUIUtility.GetControlID(BodyMaskEditor.s_Hint, FocusType.Native, rect);
   Event current = Event.current;
   if (current.GetTypeForControl(controlId) != EventType.MouseDown || !rect.Contains(current.mousePosition))
     return;
   current.Use();
   int x = (int) current.mousePosition.x - (int) rect.x;
   int y = BodyMaskEditor.styles.UnityDude.image.height - ((int) current.mousePosition.y - (int) rect.y);
   Color pixel = (BodyMaskEditor.styles.PickingTexture.image as Texture2D).GetPixel(x, y);
   bool flag1 = false;
   for (int index = 0; index < count; ++index)
   {
     if (BodyMaskEditor.m_MaskBodyPartPicker[index] == pixel)
     {
       GUI.changed = true;
       bodyMask.GetArrayElementAtIndex(index).intValue = bodyMask.GetArrayElementAtIndex(index).intValue != 1 ? 1 : 0;
       flag1 = true;
     }
   }
   if (flag1)
     return;
   bool flag2 = false;
   for (int index = 0; index < count && !flag2; ++index)
     flag2 = bodyMask.GetArrayElementAtIndex(index).intValue == 1;
   for (int index = 0; index < count; ++index)
     bodyMask.GetArrayElementAtIndex(index).intValue = flag2 ? 0 : 1;
   GUI.changed = true;
 }
 public static void Show(SerializedProperty bodyMask, int count)
 {
     if (styles.UnityDude.image != null)
     {
         GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth((float) styles.UnityDude.image.width) };
         Rect position = GUILayoutUtility.GetRect(styles.UnityDude, GUIStyle.none, options);
         position.x += (GUIView.current.position.width - position.width) / 2f;
         Color color = GUI.color;
         GUI.color = (bodyMask.GetArrayElementAtIndex(0).intValue != 1) ? Color.red : Color.green;
         if (styles.BodyPart[0].image != null)
         {
             GUI.DrawTexture(position, styles.BodyPart[0].image);
         }
         GUI.color = new Color(0.2f, 0.2f, 0.2f, 1f);
         GUI.DrawTexture(position, styles.UnityDude.image);
         for (int i = 1; i < count; i++)
         {
             GUI.color = (bodyMask.GetArrayElementAtIndex(i).intValue != 1) ? Color.red : Color.green;
             if (styles.BodyPart[i].image != null)
             {
                 GUI.DrawTexture(position, styles.BodyPart[i].image);
             }
         }
         GUI.color = color;
         DoPicking(position, bodyMask, count);
     }
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if(!property.isArray)
            {
                EditorGUI.PropertyField(position, property, label, false);
                return;
            }

            if (property.arraySize == 0) property.arraySize = 1;

            if (property.arraySize == 1)
            {
                var elementHeight = (_internalDrawer != null) ? _internalDrawer.GetPropertyHeight(property.GetArrayElementAtIndex(0), label) : EditorGUIUtility.singleLineHeight;
                var propArea = new Rect(position.xMin, position.yMin, Mathf.Max(0f, position.width - BTN_WIDTH), elementHeight);
                var btnArea = new Rect(propArea.xMax, position.yMin, Mathf.Min(BTN_WIDTH, position.width), EditorGUIUtility.singleLineHeight);

                if (_internalDrawer != null)
                    _internalDrawer.OnGUI(propArea, property.GetArrayElementAtIndex(0), label);
                else
                    SPEditorGUI.DefaultPropertyField(propArea, property.GetArrayElementAtIndex(0), label);
                if (GUI.Button(btnArea, _moreBtnLabel))
                {
                    property.arraySize = 2;
                }
            }
            else
            {
                var elementArea = new Rect(position.xMin, position.yMin, position.width, EditorGUIUtility.singleLineHeight);

                //draw header
                var leftOverArea = EditorGUI.PrefixLabel(elementArea, label ?? GUIContent.none);
                var sizeArea = new Rect(Mathf.Max(leftOverArea.xMin, leftOverArea.xMax - BTN_WIDTH - SIZE_WIDTH),
                                        leftOverArea.yMin,
                                        Mathf.Min(SIZE_WIDTH, Mathf.Max(0f, leftOverArea.width - BTN_WIDTH)), EditorGUIUtility.singleLineHeight);
                var btnArea = new Rect(sizeArea.xMax, position.yMin, Mathf.Min(BTN_WIDTH, position.width), EditorGUIUtility.singleLineHeight);
                property.arraySize = Mathf.Max(EditorGUI.IntField(sizeArea, property.arraySize), 1);
                if(GUI.Button(btnArea, _oneBtnLabel))
                {
                    property.arraySize = 1;
                }

                EditorGUI.indentLevel++;
                for(int i = 0; i < property.arraySize; i++)
                {
                    var lbl = EditorHelper.TempContent("Element " + i.ToString());
                    var elementHeight = (_internalDrawer != null) ? _internalDrawer.GetPropertyHeight(property.GetArrayElementAtIndex(i), lbl) : EditorGUIUtility.singleLineHeight;
                    elementArea = new Rect(position.xMin, elementArea.yMax, position.width, elementHeight);

                    if (_internalDrawer != null)
                        _internalDrawer.OnGUI(elementArea, property.GetArrayElementAtIndex(i), lbl);
                    else
                        SPEditorGUI.DefaultPropertyField(elementArea, property.GetArrayElementAtIndex(i), lbl);
                }
                EditorGUI.indentLevel--;
            }
        }
 private void DrawList(SerializedProperty list)
 {
     for(int n = 0; n < list.arraySize; n++)
     {
         EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(n));
     }
 }
Example #5
0
 public static void Show(SerializedProperty list)
 {
     EditorGUILayout.PropertyField(list);
     EditorGUI.indentLevel += 1;
     if (list.isExpanded)
     {
         EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
         //EditorGUILayout.BeginHorizontal();
         //EditorGUILayout.IntField("X", 0);
         //EditorGUILayout.IntField("Y", 0);
         //EditorGUILayout.IntField("Z", 0);
         //EditorGUILayout.EndHorizontal();
         if (list.arraySize>0)
             for (int i = 0; i < list.arraySize; i++)
             {
                 EditorGUILayout.BeginHorizontal();
                 EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i),GUIContent.none);
                 ShowButtons(list,i);
                 EditorGUILayout.EndHorizontal();
             }
         else
         {
             if (GUILayout.Button(addButtonContent))
                 list.InsertArrayElementAtIndex(0);
         }
     }
     EditorGUI.indentLevel -= 1;
 }
 public static void DrawListLayout(SerializedProperty property)
 {
     EditorGUILayout.PropertyField (property);
     EditorGUI.indentLevel++;
     if (property.isExpanded) {
         for (int i = 0; i < property.arraySize; i++) {
             EditorGUILayout.BeginHorizontal ();
             EditorGUILayout.PropertyField (property.GetArrayElementAtIndex (i), true);
             if (GUILayout.Button (moveButtonContent, EditorStyles.miniButtonLeft, GUILayout.Width(20))) {
                 property.MoveArrayElement (i, i + 1);
             }
             if (GUILayout.Button (duplicateButtonContent, EditorStyles.miniButtonMid, GUILayout.Width(20))) {
                 property.InsertArrayElementAtIndex (i);
             }
             if (GUILayout.Button (deleteButtonContent, EditorStyles.miniButtonRight, GUILayout.Width(20))) {
                 int oldsize = property.arraySize;
                 property.DeleteArrayElementAtIndex (i);
                 if (oldsize == property.arraySize) {
                     property.DeleteArrayElementAtIndex (i);
                 }
             }
             EditorGUILayout.EndHorizontal ();
         }
         if (GUILayout.Button (addButtonContent, EditorStyles.miniButton)) {
             property.arraySize += 1;
         }
     }
     EditorGUI.indentLevel--;
 }
        private static void ShowList(SerializedProperty list)
        {
            EditorGUILayout.PropertyField(list);
            for (int i = 0; i < list.arraySize; i++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i));

                if (GUILayout.Button("Remove"))
                {
                    int oldSize = list.arraySize;
                    list.DeleteArrayElementAtIndex(i);
                    if (list.arraySize == oldSize)
                    {
                        list.DeleteArrayElementAtIndex(i);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            if (GUILayout.Button("Add required Skill"))
            {
                list.arraySize += 1;
            }
        }
Example #8
0
        private static bool ElementExsists(string name, UnityEditor.SerializedProperty currentList)
        {
            bool elementExsist = false;

            for (int i = 0; i < currentList.arraySize; i++)
            {
                var element = currentList.GetArrayElementAtIndex(i).Copy();

                element.Next(true);
                do
                {
                    if (element.name == "m_Name")
                    {
                        if (element.stringValue == name)
                        {
                            elementExsist = true;
                        }
                        break;
                    }
                } while (element.Next(false));
                if (elementExsist)
                {
                    break;
                }
            }
            return(elementExsist);
        }
		public static float GetPropertyHeight (SerializedProperty _arrayProperty, eArrayOptions _options)
		{
			int _count				= _arrayProperty.arraySize;
			bool _showArraySize		= (_options & eArrayOptions.SHOW_ARRAY_SIZE) != 0;
			float _singleLineHeight	= EditorGUIUtility.singleLineHeight;
			float _totalHeight		= 0f;

			// Height for array name
			_totalHeight		+= _singleLineHeight + kSpacingPixels;

			// Is foldout enabled, then dont show the rest of the elements
			if (_arrayProperty.isExpanded)
			{
				// If we showing array size then we need to consider it
				if (_showArraySize && _count != 0)
					_totalHeight	+= (EditorGUIUtility.singleLineHeight + kSpacingPixels);

				// If there are no elements then we will show button to add elements
				if (_count == 0)
				{
					// Add height of button and extra spacing
					_totalHeight	+= (EditorGUIUtility.singleLineHeight + kSpacingPixels);
				}
				// We do have contents within array
				else
				{
					// Includes height for each element, height of edit bar, spacing
					for (int _iter = 0; _iter < _count; _iter++)
						_totalHeight+= EditorGUI.GetPropertyHeight(_arrayProperty.GetArrayElementAtIndex(_iter)) + EditorGUIUtility.singleLineHeight + kSpacingPixels;
				}
			}
			
			return _totalHeight;
		}
Example #10
0
        void ShowAnimationList(SerializedProperty animations)
        {
            var count = animations.arraySize;

            // FIXME: should be replaced with DelayedIntField in 5.3
            count = EditorGUILayout.IntField("Animation Count", count);
            count = Mathf.Max(count, 1);

            // enlarge/shrink the list when the size is changed
            while (count > animations.arraySize)
                animations.InsertArrayElementAtIndex(animations.arraySize - 1);
            while (count < animations.arraySize)
                animations.DeleteArrayElementAtIndex(animations.arraySize - 1);

            EditorGUI.indentLevel++;

            for (var i = 0; i < animations.arraySize; i++)
            {
                var data = animations.GetArrayElementAtIndex(i);
                var label_i = new GUIContent("Animation " + i);
                EditorGUILayout.PropertyField(data, label_i);
            }

            EditorGUI.indentLevel--;
        }
        public float GetHeight(SerializedProperty property, GUIContent label, bool includeChildren)
        {
            if (_visibleDrawer == null) this.Init();

            property = property.Copy();
            if (label == null) label = EditorHelper.TempContent(property.displayName);

            if (_visibleDrawer is IArrayHandlingPropertyDrawer || !property.isArray)
            {
                return _visibleDrawer.GetPropertyHeight(property, label);
            }
            else
            {
                float h = SPEditorGUI.GetSinglePropertyHeight(property, label);
                if (!includeChildren || !property.isExpanded) return h;

                h += EditorGUIUtility.singleLineHeight + 2f;

                for(int i = 0; i < property.arraySize; i++)
                {
                    var pchild = property.GetArrayElementAtIndex(i);
                    h += _visibleDrawer.GetPropertyHeight(pchild, EditorHelper.TempContent(pchild.displayName)) + 2f;
                }
                return h;
            }
        }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        List1 = property.FindPropertyRelative("CharList1");
        #region FORMATTING (IGNORE IT)
        GUI.Box(position, "");
        position.height = SINGLE_LINE_HEIGHT;
        position.y += HALF_BORDER;
        position.x += BUTTON_WIDTH + FULL_BORDER + HALF_BORDER;
        position.width -= BUTTON_WIDTH + FULL_BORDER + FULL_BORDER;
        #endregion

        for (int i = 0; i < List1.arraySize; i++) {
            Rect deleteButton = new Rect(position.x - BUTTON_WIDTH - FULL_BORDER, position.y, BUTTON_WIDTH, position.height);
            if (GUI.Button(deleteButton, _deleteButtonContent)) {
                List1.DeleteArrayElementAtIndex(i); //This is the line that breaks things...
                return;
            }

            EditorGUI.PropertyField(position, List1.GetArrayElementAtIndex(i), new GUIContent(""));
            position.y += position.height + HALF_BORDER;
        }
        #region Add new element (IGNORE)
        position.x -= BUTTON_WIDTH + FULL_BORDER;
        position.width += BUTTON_WIDTH + FULL_BORDER;
        if (GUI.Button(position, "Add new element")) {
            List1.arraySize++;
        }
        #endregion
    }
Example #13
0
        protected virtual void OnEnable()
        {
            hideFlags = HideFlags.HideAndDontSave;

            instance = target as Gesture;

            advanced = serializedObject.FindProperty("advancedProps");
            friendlyGestures = serializedObject.FindProperty("friendlyGestures");
            requireGestureToFail = serializedObject.FindProperty("requireGestureToFail");
            combineTouches = serializedObject.FindProperty("combineTouches");
            combineTouchesInterval = serializedObject.FindProperty("combineTouchesInterval");
            useSendMessage = serializedObject.FindProperty("useSendMessage");
            sendMessageTarget = serializedObject.FindProperty("sendMessageTarget");
            sendStateChangeMessages = serializedObject.FindProperty("sendStateChangeMessages");

            friendlyGesturesList = new ReorderableList(serializedObject, friendlyGestures, false, false, false, true);
            friendlyGesturesList.headerHeight = 0;
            friendlyGesturesList.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                var gesture = friendlyGestures.GetArrayElementAtIndex(index).objectReferenceValue as Gesture;
                if (gesture == null)
                {
                    // Killing null elements.
                    indexToRemove = index;
                    EditorGUI.LabelField(rect, GUIContent.none);
                    return;
                }
                EditorGUI.LabelField(rect, string.Format("{0} @ {1}", gesture.GetType().Name, gesture.name), GUIElements.BoxLabelStyle);
            };
            friendlyGesturesList.onRemoveCallback += list => { indexToRemove = list.index; };
        }
        protected virtual void OnEnable()
        {
            // String Tables property
            stringTablesProp = serializedObject.FindProperty("stringTables");
            stringTablesList = new ReorderableList(serializedObject, stringTablesProp, true, true, true, true);

            stringTablesList.drawHeaderCallback = (Rect rect) => {  
                EditorGUI.LabelField(rect, "String Tables");
            };

            stringTablesList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { 
                Rect r = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
                SerializedProperty element = stringTablesProp.GetArrayElementAtIndex(index);
                EditorGUI.PropertyField(r, element, new GUIContent(""));
            };

            // Register Types property   
            registerTypesProp = serializedObject.FindProperty("registerTypes");
            registerTypeList = new ReorderableList(serializedObject, registerTypesProp, true, true, true, true);

            registerTypeList.drawHeaderCallback = (Rect rect) => {  
                EditorGUI.LabelField(rect, "Type Lists");
            };

            registerTypeList.drawElementCallback = (Rect rect, int index, bool isActive, bool isFocused) => { 
                Rect r = new Rect(rect.x, rect.y, rect.width, EditorGUIUtility.singleLineHeight);
                SerializedProperty element = registerTypesProp.GetArrayElementAtIndex(index);
                EditorGUI.PropertyField(r, element, new GUIContent(""));
            };
        }
        private void OnEnable()
        {
            instance = target as TouchManager;
            layers = serializedObject.FindProperty("layers");
            displayDevice = serializedObject.FindProperty("displayDevice");
            useSendMessage = serializedObject.FindProperty("useSendMessage");
            sendMessageTarget = serializedObject.FindProperty("sendMessageTarget");
            sendMessageEvents = serializedObject.FindProperty("sendMessageEvents");

            refresh();

            layersList = new ReorderableList(serializedObject, layers, true, true, false, false);
            layersList.drawHeaderCallback += rect => GUI.Label(rect, LAYERS_HEADER);
            layersList.drawElementCallback += (rect, index, active, focused) =>
            {
                rect.height = 16;
                rect.y += 2;
                if (index >= layers.arraySize) return;
                var layer = layers.GetArrayElementAtIndex(index).objectReferenceValue as TouchLayer;
                if (layer == null)
                {
                    EditorGUI.LabelField(rect, "null");
                    return;
                }
                EditorGUI.LabelField(rect, layer.Name);
            };
        }
Example #16
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        position.height = 16f;
        foldout = EditorGUI.Foldout(position, foldout, label);
        if (foldout)
        {
            //EditorGUI.BeginChangeCheck();
            //{
            //    Rect rect = EditorGUI.IndentedRect(position);
            //    int size = property.arraySize;
            //    size = EditorGUI.IntField(rect, size);
            //}
            //if (EditorGUI.EndChangeCheck())
            //{
            //    property.
            //}

            string[] names = Enum.GetNames(nameListAttribute.enumType);
            Rect rect = EditorGUI.IndentedRect(position);
            //rect.height = GetPropertyHeight()
            for (int i = 0; i < names.Length; i++)
            {

                rect.y += rect.height;
                //rect.height = 15f;
                EditorGUI.PropertyField(rect, property.GetArrayElementAtIndex(i), new GUIContent(i >= names.Length ? "" : names[i]));
            }
        }
    }
Example #17
0
 /// <summary>
 /// Adds a new element to an array property.
 /// </summary>
 public static void AddNewElementToProp(SerializedProperty property)
 {
     if (property.isArray) {
         property.arraySize++;
         ClearPropValue(property.GetArrayElementAtIndex(property.arraySize - 1));
     }
 }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (!property.isArray)
            {
                //Debug.LogError("must be an array");
                EditorGUI.PropertyField(position, property, label);
                return;
            }

            int colorCount = property.arraySize;
            if (colorCount == 0) return;

            if (property.GetArrayElementAtIndex(0).propertyType == SerializedPropertyType.Color)
            {
                float width = position.width/5;
                float x = position.x;
                float y = position.y;
                float height = 16;

                var indentLevel = EditorGUI.indentLevel;

                EditorGUI.indentLevel = 0;

                //Only draw 100 colors
                for (int i = 0; i < Mathf.Min(100, colorCount); i++)
                {
                    var colorProp = property.GetArrayElementAtIndex(i);
                    var color = colorProp.colorValue;
                    var rect = new Rect(x, y, width, height);
                    EditorGUI.DrawRect(rect, color);

                    x += width;

                    if ((i + 1)%5 == 0)
                    {
                        x = position.x;
                        y += height;
                    }
                }

                EditorGUI.indentLevel = indentLevel;
            }
            else
            {
                EditorGUI.PropertyField(position, property, label);
            }
        }
Example #19
0
    private void GenerateData()
    {
        List <List <int> > levels = new List <List <int> >();
        List <Vector2Int>  edges  = new List <Vector2Int>();
        int nodeCountInLevel      = 1;
        int nodeIndex             = 0;

        for (int i = 0; i < levelCount; ++i)
        {
            bool lastLevel = (i == levelCount - 1);

            List <int> nodes = new List <int>();
            levels.Add(nodes);

            int splitTimes = 0;
            for (int j = 0; j < nodeCountInLevel; ++j)
            {
                nodes.Add(nodeIndex);

                if (!lastLevel)
                {
                    edges.Add(new Vector2Int(nodeIndex, nodeIndex + nodeCountInLevel + splitTimes));

                    if (Random.value < splitFactor / i)
                    {
                        splitTimes++;
                        edges.Add(new Vector2Int(nodeIndex, nodeIndex + nodeCountInLevel + splitTimes));
                    }
                }

                nodeIndex++;
            }

            nodeCountInLevel += splitTimes;
        }

        float height = yInterval * (levels[levelCount - 1].Count - 1);

        UnityEditor.SerializedProperty spNodes = serializedObject.FindProperty("nodes");
        spNodes.arraySize = nodeIndex;
        for (int i = 0; i < levels.Count; ++i)
        {
            List <int> nodes  = levels[i];
            float      yStart = height * 0.5f - (nodes.Count - 1) * yInterval * 0.5f;
            for (int j = 0; j < nodes.Count; ++j)
            {
                spNodes.GetArrayElementAtIndex(nodes[j]).vector2Value = new Vector2(xInterval * i + j, yStart + yInterval * j);
            }
        }

        UnityEditor.SerializedProperty spEdges = serializedObject.FindProperty("edges");
        spEdges.arraySize = edges.Count;
        for (int i = 0; i < edges.Count; ++i)
        {
            spEdges.GetArrayElementAtIndex(i).vector2IntValue = edges[i];
        }

        serializedObject.ApplyModifiedProperties();
    }
 private string[] GetTags(SerializedProperty prop)
 {
     string[] tags = new string[prop.arraySize];
     for (int i = 0; i < prop.arraySize; i++)
     {
         tags[i] = prop.GetArrayElementAtIndex(i).stringValue;
     }
     return tags;
 }
Example #21
0
 public void AttackPatternField(SerializedProperty attackPatterns)
 {
     Vector3 moveRemove = new Vector3(-1f, -1f, 0f);
     int c = attackPatterns.FindPropertyRelative ("Array.size").intValue;
     if(c < 1)
     {
         attackPatterns.InsertArrayElementAtIndex(0);
         attackPatterns.GetArrayElementAtIndex(0).objectReferenceValue = gameObject.GetComponent<AbstractAttackPattern>();
     }
     for(int i = 0; i < c; i++)
     {
         EditorGUILayout.BeginHorizontal();
         SerializedProperty arrayElement = attackPatterns.GetArrayElementAtIndex(i);
         AbstractAttackPattern ap = (AbstractAttackPattern)arrayElement.objectReferenceValue;
         EditorGUILayout.PropertyField(arrayElement, new GUIContent((ap != null) ? GetAttackPatternName(ap) : i.ToString()));
         moveRemove = DanmakuEditorUtils.UpDownRemoveButtons(moveRemove, c, i, false);
         EditorGUILayout.EndHorizontal();
     }
     if (moveRemove.y >= 0)
     {
         int removeIndex = (int)moveRemove.y;
         if(attackPatterns.GetArrayElementAtIndex(removeIndex).objectReferenceValue != null)
         {
             attackPatterns.DeleteArrayElementAtIndex(removeIndex);
         }
         attackPatterns.DeleteArrayElementAtIndex(removeIndex);
     }
     if (moveRemove.x >= 0)
     {
         int moveIndex = (int)moveRemove.x;
         if (moveRemove.z > 0)
         {
             attackPatterns.MoveArrayElement (moveIndex, moveIndex + 1);
         }
         if (moveRemove.z < 0)
         {
             attackPatterns.MoveArrayElement (moveIndex, moveIndex - 1);
         }
     }
     if (GUILayout.Button("Add"))
     {
         attackPatterns.InsertArrayElementAtIndex(c);
     }
 }
Example #22
0
 System.Type[] GetArray(SerializedProperty field)
 {
     if (field == null)
         return null;
     System.Type[] o = new System.Type[field.arraySize];
     for(int i = 0; i<field.arraySize;i++){
         o[i] = Utils.GetType(field.GetArrayElementAtIndex(i).stringValue);
     }
     return o;
 }
	private void ShowElements (Rect position, SerializedProperty property) 
	{
		for (int i = 0; i < property.arraySize; i++) 
		{
			SerializedProperty element = property.GetArrayElementAtIndex(i);
			position.height = EditorGUI.GetPropertyHeight(element);
			EditorGUI.PropertyField(position, element, GUIContent.none, true);
			position.y += position.height;
		}
	}
        /// <summary>Add a new array element at the end of an array.</summary>
        /// <param name="array">The array to add a new element to.</param>
        /// <param name="index">Index position where to add the array element.</param>
        /// <returns><see cref="SerializedProperty"/> for the new array element.</returns>
        public static SerializedProperty AddArrayElement(SerializedProperty array, int index)
        {
            if (!array.isArray) {
                Debug.LogError("Specified property is not an array");
                return null;
            }
            array.InsertArrayElementAtIndex(index);

            return array.GetArrayElementAtIndex(index - 1);
        }
Example #25
0
        protected void ArrayList(SerializedProperty property, string title, Runnable1<SerializedProperty> renderer)
        {
            if (Foldout(title, false)) {
            Indent(() => {
                if (property.arraySize == 0) {
                    GUILayout.Label("   Use 'Add' button to add items");
                } else {
                    int arrSize = property.arraySize;
                    Separator();
                    for (int i = 0; i < arrSize; ++i) {
                        var go = property.GetArrayElementAtIndex(i);
                        EditorGUILayout.BeginHorizontal();

                        EditorGUILayout.BeginVertical();
                        renderer(go);
                        EditorGUILayout.EndVertical();

                        GUI.color = Color.red;
                        if (GUILayout.Button("X", GUILayout.ExpandWidth(false))) {
                            property.DeleteArrayElementAtIndex(i);
                            arrSize--;
                        }
                        GUI.color = Color.white;
                        EditorGUILayout.EndHorizontal();

                        if (i + 1 < arrSize) {
                            EditorGUILayout.Space();
                        }
                        Separator();
                    }
                }

                GUI.color = Color.green;
                EditorGUILayout.BeginHorizontal();
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) {
                    property.InsertArrayElementAtIndex(property.arraySize);

                    // when creating new array element like this, the color will be initialized with
                    // (0, 0, 0, 0) - zero aplha. This may be confusing for end user so this workaround looks
                    // for color fields and sets them to proper values
                    var element = property.GetArrayElementAtIndex(property.arraySize - 1);
                    var enumerator = element.GetEnumerator();
                    while (enumerator.MoveNext()) {
                        var el = enumerator.Current as SerializedProperty;
                        if (el.type == "ColorRGBA") {
                            el.colorValue = Color.white;
                        }
                    }
                }
                GUI.color = Color.white;
                EditorGUILayout.EndHorizontal();
            });
            }
        }
Example #26
0
    private static void ShowButtons(SerializedProperty list, int index)
    {
        if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth))
        {
            list.InsertArrayElementAtIndex(index);
            if (index < list.arraySize - 2)
            {
                Vector3 vector1 = list.GetArrayElementAtIndex(index).vector3Value;
                Vector3 vector2 = list.GetArrayElementAtIndex(index+2).vector3Value;
                Vector3 newVector = (vector2 + vector1)/2;
                newVector.z = vector1.z;
                list.GetArrayElementAtIndex(index + 1).vector3Value = newVector;
            }

        }
        if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth))
        {
            list.DeleteArrayElementAtIndex(index);
        }
    }
Example #27
0
 public void ParseFields(UnityEditor.SerializedProperty fieldsSet)
 {
     UnityEditor.EditorGUILayout.LabelField("[Extensions]:");
     UnityEditor.EditorGUI.indentLevel++;
     for (int i = 0; i < fieldsSet.arraySize; i++)
     {
         UnityEditor.SerializedProperty property = fieldsSet.GetArrayElementAtIndex(i);
         UnityEditor.EditorGUILayout.PropertyField(property, new UnityEngine.GUIContent($"[] {TargetArea.fields[i].Name}"));
     }
     UnityEditor.EditorGUI.indentLevel--;
 }
 public static void Show(SerializedProperty list)
 {
     EditorGUILayout.PropertyField(list);
     if (list.isExpanded) {
         EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));
         for (int i = 0; i < list.arraySize; i++) {
             GUIContent label = new GUIContent();
             label.text = "Frame" + (i+1);
             EditorGUILayout.PropertyField (list.GetArrayElementAtIndex (i), label);
         }
     }
 }
 public static void Show(SerializedProperty bodyMask, int count)
 {
   if (!(bool) ((Object) BodyMaskEditor.styles.UnityDude.image))
     return;
   Rect rect = GUILayoutUtility.GetRect(BodyMaskEditor.styles.UnityDude, GUIStyle.none, new GUILayoutOption[1]{ GUILayout.MaxWidth((float) BodyMaskEditor.styles.UnityDude.image.width) });
   rect.x += (float) (((double) GUIView.current.position.width - (double) rect.width) / 2.0);
   Color color = GUI.color;
   GUI.color = bodyMask.GetArrayElementAtIndex(0).intValue != 1 ? Color.red : Color.green;
   if ((bool) ((Object) BodyMaskEditor.styles.BodyPart[0].image))
     GUI.DrawTexture(rect, BodyMaskEditor.styles.BodyPart[0].image);
   GUI.color = new Color(0.2f, 0.2f, 0.2f, 1f);
   GUI.DrawTexture(rect, BodyMaskEditor.styles.UnityDude.image);
   for (int index = 1; index < count; ++index)
   {
     GUI.color = bodyMask.GetArrayElementAtIndex(index).intValue != 1 ? Color.red : Color.green;
     if ((bool) ((Object) BodyMaskEditor.styles.BodyPart[index].image))
       GUI.DrawTexture(rect, BodyMaskEditor.styles.BodyPart[index].image);
   }
   GUI.color = color;
   BodyMaskEditor.DoPicking(rect, bodyMask, count);
 }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            if (!property.isArray) return EditorGUIUtility.singleLineHeight;

            if (property.arraySize == 0) property.arraySize = 1;

            if (property.arraySize == 1)
            {
                return (_internalDrawer != null) ? _internalDrawer.GetPropertyHeight(property.GetArrayElementAtIndex(0), EditorHelper.TempContent("Element 0")) : EditorGUIUtility.singleLineHeight;
            }
            else
            {
                var h = EditorGUIUtility.singleLineHeight;
                var lbl = EditorHelper.TempContent("Element 0");
                for (int i = 0; i < property.arraySize; i++)
                {
                    h += (_internalDrawer != null) ? _internalDrawer.GetPropertyHeight(property.GetArrayElementAtIndex(i), lbl) : EditorGUIUtility.singleLineHeight;
                }
                return h;
            }
        }
Example #31
0
 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;
     }
 }
Example #32
0
    //添加新的元素
    public void Add(string key, Object obj)
    {
        UnityEditor.SerializedObject serializedObject = new UnityEditor.SerializedObject(this);
        //根据PropertyPath读取数据
        //如果不知道具体的格式,可以右键用文本编辑器打开一个prefab文件(如Bundles/UI目录中的几个)
        //因为这几个prefab挂载了ReferenceCollector,所以搜索data就能找到存储的数据
        UnityEditor.SerializedProperty dataProperty = serializedObject.FindProperty("data");
        int i;

        //遍历data,看添加的数据是否存在相同key
        for (i = 0; i < data.Count; i++)
        {
            if (data[i].key == key)
            {
                break;
            }
        }
        //不等于data.Count意为已经存在于data List中,直接赋值即可
        if (i != data.Count)
        {
            //根据i的值获取dataProperty,也就是data中的对应ReferenceCollectorData,不过在这里,是对Property进行的读取,有点类似json或者xml的节点
            UnityEditor.SerializedProperty element = dataProperty.GetArrayElementAtIndex(i);
            //对对应节点进行赋值,值为gameobject相对应的fileID
            //fileID独一无二,单对单关系,其他挂载在这个gameobject上的script或组件会保存相对应的fileID
            element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
        }
        else
        {
            //等于则说明key在data中无对应元素,所以得向其插入新的元素
            dataProperty.InsertArrayElementAtIndex(i);
            UnityEditor.SerializedProperty element = dataProperty.GetArrayElementAtIndex(i);
            element.FindPropertyRelative("key").stringValue = key;
            element.FindPropertyRelative("gameObject").objectReferenceValue = obj;
        }
        //应用与更新
        UnityEditor.EditorUtility.SetDirty(this);
        serializedObject.ApplyModifiedProperties();
        serializedObject.UpdateIfRequiredOrScript();
    }
        /// <summary>
        /// Fetch the parameter types from their underlying properties
        /// </summary>
        public static Type[] DeserializeParameterTypes(SerializedProperty parameterTypesProperty)
        {
            Type[] parameterTypes = new Type[parameterTypesProperty.arraySize];

            for (int i = 0; i < parameterTypesProperty.arraySize; i++)
            {
                SerializedProperty parameterTypeProperty = parameterTypesProperty.GetArrayElementAtIndex(i);

                parameterTypes[i] = TypeSerializer.Deserialize(parameterTypeProperty.stringValue);
            }

            return parameterTypes;
        }
    void ShowList(SerializedProperty prop)
    {
        EditorGUILayout.Space();

        if(layerListFold = EditorGUILayout.Foldout(layerListFold,new GUIContent("layers")))
        {
            foreach (var name in LayerManager.layerNameNumber.Keys)
            {
                SerializedProperty elementProperty = prop.GetArrayElementAtIndex(LayerManager.layerNameNumber[name]);
                EditorGUILayout.PropertyField(elementProperty, new GUIContent(name));
            }
        }
    }
        /// <summary>
        /// Draw an element inside the target array property.
        /// </summary>
        /// <param name="arrayProperty">Array property.</param>
        /// <param name="elementIndex">Element index to get the element out of the array property.</param>
        /// <param name="getSelectedIndex">Get selected index.</param>
        /// <param name="setSelectedIndex">Set selected index.</param>
        /// <param name="drawInnerProperties">Action to draw inner properties of the element property.</param>
        void DrawArrayElement(SP arrayProperty, int elementIndex, string minSizeWarning, int minSize,
                              Func <int> getSelectedIndex, Action <int> setSelectedIndex, Action <SP> drawInnerProperties)
        {
            var elementProperty = arrayProperty.GetArrayElementAtIndex(elementIndex);

            EGL.BeginHorizontal();

            EGL.BeginVertical(E_SM.GetCustomStyle("Item Box"));

            if (drawInnerProperties != null)
            {
                drawInnerProperties(elementProperty);
            }

            EGL.EndVertical();

            var deleteIcon           = EditorGUIUtility.IconContent("Toolbar Minus");
            var deleteButtonStyle    = GUIStyle.none;
            var deleteButtonMinWidth = GUILayout.MaxWidth(E_SM.smallButtonWidth);

            /// Draw a button to remove element property from array property.
            bool canDelete = arrayProperty.arraySize > minSize;

            EditorGUI.BeginDisabledGroup(!canDelete); // Disable the "-" button
            if (GUILayout.Button(deleteIcon, deleteButtonStyle, deleteButtonMinWidth))
            {
                if (arrayProperty.arraySize > minSize)
                {
                    if (getSelectedIndex() > elementIndex)
                    {
                        setSelectedIndex(getSelectedIndex() - 1);
                    }

                    arrayProperty.DeleteArrayElementAtIndex(elementIndex);

                    /// We need to return here so the deleted element won't be displayed in the codes below,
                    /// causing unexpected error.
                    return;
                }

                if (!string.IsNullOrEmpty(minSizeWarning))
                {
                    Debug.Log(minSizeWarning);
                }
            }
            EditorGUI.EndDisabledGroup();

            EGL.EndHorizontal();
        }
Example #36
0
        public static void AddTag(string _tag)
        {
#if UNITY_EDITOR
            UnityEngine.Object[] _asset = UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset");
            if ((_asset != null) && (_asset.Length > 0))
            {
                UnityEditor.SerializedObject   _object = new UnityEditor.SerializedObject(_asset[0]);
                UnityEditor.SerializedProperty _tags   = _object.FindProperty("tags");

                for (int i = 0; i < _tags.arraySize; ++i)
                {
                    if (_tags.GetArrayElementAtIndex(i).stringValue == _tag)
                    {
                        return;
                    }
                }

                _tags.InsertArrayElementAtIndex(0);
                _tags.GetArrayElementAtIndex(0).stringValue = _tag;
                _object.ApplyModifiedProperties();
                _object.Update();
            }
#endif
        }
        /// <summary>
        /// Draws the resizable array.
        /// </summary>
        /// <param name="arrayProperty">Array property.</param>
        /// <param name="drawElement">Action to draw target property.</param>
        /// <param name="updateNewElement">
        /// Action to update new element's values
        /// so it won't have same values with the previous one when created.
        /// </param>
        bool DrawResizableArray(SP arrayProperty, bool foldout, string foldoutLabel, Action <SP, int> drawElement, Action <SP> updateNewElement = null, bool noLabel = false, int maxSize = int.MaxValue)
        {
            /// Draw array name and a button to add new element into array.
            GUILayout.BeginHorizontal();

            EditorGUI.indentLevel++;
            foldout = EGL.Foldout(foldout, noLabel ? "" : foldoutLabel, true);
            EditorGUI.indentLevel--;

            GUIContent      plusButtonContent  = EditorGUIUtility.IconContent("Toolbar Plus");
            GUIStyle        plusButtonStyle    = GUIStyle.none;
            GUILayoutOption plusButtonMinWidth = GUILayout.MaxWidth(E_SM.smallButtonWidth);

            if (GUILayout.Button(plusButtonContent, plusButtonStyle, plusButtonMinWidth) && arrayProperty.arraySize < maxSize)
            {
                arrayProperty.arraySize++;

                /// Update new property so it won't have same values with the previous one.
                if (updateNewElement != null)
                {
                    updateNewElement(arrayProperty.GetArrayElementAtIndex(arrayProperty.arraySize - 1));
                }

                /// We should expand the array so user can see
                /// the element that has just been added.
                foldout = true;
            }
            GUILayout.EndHorizontal();

            /// Draw all array's elements.
            if (!foldout || arrayProperty.arraySize <= 0)
            {
                return(foldout);
            }

            for (int i = 0; i < arrayProperty.arraySize; i++)
            {
                drawElement(arrayProperty, i);
                if (i < arrayProperty.arraySize - 1)
                {
                    EGL.Space();
                }
            }

            EGL.Space();
            return(foldout);
        }
Example #38
0
        public static bool AddLayer(string _name)
        {
#if UNITY_EDITOR
            if (LayerMask.NameToLayer(_name) != -1)
            {
                return(true);
            }

            UnityEditor.SerializedObject _tag_manager = new UnityEditor.SerializedObject(UnityEditor.AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/TagManager.asset")[0]);

            UnityEditor.SerializedProperty _layers = _tag_manager.FindProperty("layers");
            if (_layers == null || !_layers.isArray)
            {
                Debug.LogWarning("Sorry, can't set up the layers! It's possible the format of the layers and tags data has changed in this version of Unity. Please add the required layer '" + _name + "' by hand!");
                return(false);
            }

            int _layer_index = -1;
            for (int _i = 8; _i < 32; _i++)
            {
                _layer_index = _i;
                UnityEditor.SerializedProperty _layer = _layers.GetArrayElementAtIndex(_i);

                //Debug.Log( _layer_index + " - " + _layer.stringValue );

                if (_layer.stringValue == "")
                {
                    Debug.Log("Setting up layers.  Layer " + _layer_index + " is now called " + _name);
                    _layer.stringValue = _name;
                    break;
                }
            }

            _tag_manager.ApplyModifiedProperties();

            if (LayerMask.NameToLayer(_name) != -1)
            {
                return(true);
            }
            else
            {
                return(false);
            }
#else
            return(true);
#endif
        }
Example #39
0
        public static void ArrayField(UnityEditor.SerializedProperty list, string label = "")
        {
            UnityEditor.EditorGUILayout.PropertyField(list, new GUIContent((label.Length > 0) ? label : list.displayName));

            if (list.isExpanded)
            {
                UnityEditor.EditorGUI.indentLevel += 1;
                UnityEditor.EditorGUILayout.PropertyField(list.FindPropertyRelative("Array.size"));

                for (int i = 0; i < list.arraySize; i++)
                {
                    UnityEditor.EditorGUILayout.PropertyField(list.GetArrayElementAtIndex(i), true);
                }

                UnityEditor.EditorGUI.indentLevel -= 1;
            }
        }
Example #40
0
        private void ShowAnimationsArray(UnityEditor.SerializedProperty list)
        {
            UnityEditor.EditorGUI.indentLevel += 1;
            for (int i = 0; i < list.arraySize; i++)
            {
                EditorGUILayout.Space();
                using (new GUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    SerializedProperty transformProp = list.GetArrayElementAtIndex(i);

                    SimpleAnimation animation = ((SimpleAnimation)simpleAnimationsManager.animations[i]);

                    string itemName;
                    if (animation.name.IsNullOrEmpty())
                    {
                        itemName = $"Animation [{i}]";
                    }
                    else
                    {
                        itemName = $"'{animation.name}' animation [{i}]";
                    }

                    /*string animType = animation.GetType().Name;
                     * int charSize = 57;
                     * int reaminingChars = charSize - animType.Length - itemName.Length;
                     * for (int j = 0; j < reaminingChars; j++)
                     *  itemName += " ";
                     * itemName += animType;*/
                    EditorGUILayout.PropertyField(transformProp, new GUIContent(itemName), true);

                    DisplayPreview(animation);

                    EditorGUILayout.Space();
                }
                EditorGUILayout.Space();
            }
            UnityEditor.EditorGUI.indentLevel -= 1;
        }
Example #41
0
    public bool Equals(UnityEditor.SerializedProperty prop)
    {
        if (prop == null)
        {
            return(false);
        }

        if (prop.arraySize != _value.Length)
        {
            return(false);
        }

        for (int i = 0; i < prop.arraySize; i++)
        {
            var element = prop.GetArrayElementAtIndex(i);
            if (element.intValue != _value[i])
            {
                return(false);
            }
        }

        return(true);
    }
        public override void OnInspectorGUI()
        {
            if (initializeException != null)
            {
                ShowLoadErrorExceptionGUI(initializeException);
                ApplyRevertGUI();
                return;
            }

            extraDataSerializedObject.Update();

            var platforms = CompilationPipeline.GetAssemblyDefinitionPlatforms();

            using (new EditorGUI.DisabledScope(false))
            {
                if (targets.Length > 1)
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        var value = string.Join(", ", extraDataTargets.Select(t => t.name).ToArray());
                        EditorGUILayout.TextField(Styles.name, value, EditorStyles.textField);
                    }
                }
                else
                {
                    EditorGUILayout.PropertyField(m_AssemblyName, Styles.name);
                }

                GUILayout.Label(Styles.generalOptions, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_AllowUnsafeCode, Styles.allowUnsafeCode);
                EditorGUILayout.PropertyField(m_AutoReferenced, Styles.autoReferenced);
                EditorGUILayout.PropertyField(m_OverrideReferences, Styles.overrideReferences);
                EditorGUILayout.PropertyField(m_NoEngineReferences, Styles.noEngineReferences);

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginHorizontal();
                GUILayout.Label(Styles.defineConstraints, EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
                EditorGUILayout.EndHorizontal();

                if (m_DefineConstraints.serializedProperty.arraySize > 0)
                {
                    var defineConstraintsCompatible = true;

                    var defines = CompilationPipeline.GetDefinesFromAssemblyName(m_AssemblyName.stringValue);

                    if (defines != null)
                    {
                        for (var i = 0; i < m_DefineConstraints.serializedProperty.arraySize && defineConstraintsCompatible; ++i)
                        {
                            var defineConstraint = m_DefineConstraints.serializedProperty.GetArrayElementAtIndex(i).FindPropertyRelative("name").stringValue;

                            if (DefineConstraintsHelper.GetDefineConstraintCompatibility(defines, defineConstraint) != DefineConstraintsHelper.DefineConstraintStatus.Compatible)
                            {
                                defineConstraintsCompatible = false;
                            }
                        }

                        var constraintValidityRect = new Rect(GUILayoutUtility.GetLastRect());
                        constraintValidityRect.x += constraintValidityRect.width - 23;
                        var image   = defineConstraintsCompatible ? Styles.validDefineConstraint : Styles.invalidDefineConstraint;
                        var tooltip = Styles.GetTitleTooltipFromDefineConstraintCompatibility(defineConstraintsCompatible);
                        var content = new GUIContent(image, tooltip);

                        constraintValidityRect.width  = Styles.kValidityIconWidth;
                        constraintValidityRect.height = Styles.kValidityIconHeight;
                        EditorGUI.LabelField(constraintValidityRect, content);
                    }
                }

                m_DefineConstraints.DoLayoutList();

                GUILayout.Label(Styles.references, EditorStyles.boldLabel);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                EditorGUILayout.PropertyField(m_UseGUIDs, Styles.useGUIDs);
                EditorGUILayout.EndVertical();

                m_ReferencesList.DoLayoutList();

                if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).references != null && ((AssemblyDefinitionState)data).references.Any(x => x.asset == null)))
                {
                    EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                }

                if (m_OverrideReferences.boolValue && !m_OverrideReferences.hasMultipleDifferentValues)
                {
                    GUILayout.Label(Styles.precompiledReferences, EditorStyles.boldLabel);

                    UpdatePrecompiledReferenceListEntry();
                    m_PrecompiledReferencesList.DoLayoutList();

                    if (extraDataTargets.Any(data => ((AssemblyDefinitionState)data).precompiledReferences.Any(x => string.IsNullOrEmpty(x.path) && !string.IsNullOrEmpty(x.name))))
                    {
                        EditorGUILayout.HelpBox("The grayed out assembly references are missing and will not be referenced during compilation.", MessageType.Info);
                    }
                }

                GUILayout.Label(Styles.platforms, EditorStyles.boldLabel);
                EditorGUILayout.BeginVertical(GUI.skin.box);

                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    EditorGUILayout.PropertyField(m_CompatibleWithAnyPlatform, Styles.anyPlatform);
                    if (change.changed)
                    {
                        // Invert state include/exclude compatibility of states that have the opposite compatibility,
                        // so all states are either include or exclude.
                        var compatibleWithAny = m_CompatibleWithAnyPlatform.boolValue;
                        var needToSwap        = extraDataTargets.Cast <AssemblyDefinitionState>().Where(p => p.compatibleWithAnyPlatform != compatibleWithAny).ToList();
                        extraDataSerializedObject.ApplyModifiedProperties();
                        foreach (var state in needToSwap)
                        {
                            InversePlatformCompatibility(state);
                        }

                        extraDataSerializedObject.Update();
                    }
                }

                if (!m_CompatibleWithAnyPlatform.hasMultipleDifferentValues)
                {
                    GUILayout.Label(m_CompatibleWithAnyPlatform.boolValue ? Styles.excludePlatforms : Styles.includePlatforms, EditorStyles.boldLabel);

                    for (int i = 0; i < platforms.Length; ++i)
                    {
                        SerializedProperty property;
                        if (i >= m_PlatformCompatibility.arraySize)
                        {
                            m_PlatformCompatibility.arraySize++;
                            property           = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                            property.boolValue = false;
                        }
                        else
                        {
                            property = m_PlatformCompatibility.GetArrayElementAtIndex(i);
                        }

                        EditorGUILayout.PropertyField(property, new GUIContent(platforms[i].DisplayName));
                    }

                    EditorGUILayout.Space();

                    GUILayout.BeginHorizontal();

                    if (GUILayout.Button(Styles.selectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = true;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    if (GUILayout.Button(Styles.deselectAll))
                    {
                        var prop = m_PlatformCompatibility.GetArrayElementAtIndex(0);
                        var end  = m_PlatformCompatibility.GetEndProperty();
                        do
                        {
                            prop.boolValue = false;
                        }while (prop.Next(false) && !SerializedProperty.EqualContents(prop, end));
                    }

                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();
                }

                EditorGUILayout.EndVertical();
                GUILayout.Space(10f);

                EditorGUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label(Styles.versionDefines, EditorStyles.boldLabel);
                m_VersionDefineList.DoLayoutList();
                EditorGUILayout.EndVertical();
            }

            extraDataSerializedObject.ApplyModifiedProperties();

            ApplyRevertGUI();
        }
Example #43
0
 private SerializedProperty GetRowAt(int idx)
 {
     return(cells.GetArrayElementAtIndex(idx).FindPropertyRelative("row"));
 }
 private void DoApply(SerializedObject so)
 {
     if (this.multipleSprites)
     {
         List <string>      list  = new List <string>();
         List <string>      list2 = new List <string>();
         SerializedProperty serializedProperty = so.FindProperty("m_SpriteSheet.m_Sprites");
         for (int i = 0; i < this.m_RectsCache.Count; i++)
         {
             SpriteRect spriteRect = this.m_RectsCache.RectAt(i);
             if (string.IsNullOrEmpty(spriteRect.name))
             {
                 spriteRect.name = "Empty";
             }
             if (!string.IsNullOrEmpty(spriteRect.originalName))
             {
                 list.Add(spriteRect.originalName);
                 list2.Add(spriteRect.name);
             }
             if (serializedProperty.arraySize < this.m_RectsCache.Count)
             {
                 serializedProperty.InsertArrayElementAtIndex(serializedProperty.arraySize);
             }
             SerializedProperty arrayElementAtIndex = serializedProperty.GetArrayElementAtIndex(i);
             spriteRect.ApplyToSerializedProperty(arrayElementAtIndex);
             EditorUtility.DisplayProgressBar(SpriteEditorWindow.SpriteEditorWindowStyles.saveProgressTitle.text, string.Format(SpriteEditorWindow.SpriteEditorWindowStyles.saveContentText.text, i, this.m_RectsCache.Count), (float)i / (float)this.m_RectsCache.Count);
         }
         while (this.m_RectsCache.Count < serializedProperty.arraySize)
         {
             serializedProperty.DeleteArrayElementAtIndex(this.m_RectsCache.Count);
         }
         if (list.Count > 0)
         {
             PatchImportSettingRecycleID.PatchMultiple(so, 213, list.ToArray(), list2.ToArray());
         }
     }
     else if (this.m_RectsCache.Count > 0)
     {
         SpriteRect spriteRect2 = this.m_RectsCache.RectAt(0);
         so.FindProperty("m_Alignment").intValue                  = (int)spriteRect2.alignment;
         so.FindProperty("m_SpriteBorder").vector4Value           = spriteRect2.border;
         so.FindProperty("m_SpritePivot").vector2Value            = spriteRect2.pivot;
         so.FindProperty("m_SpriteTessellationDetail").floatValue = spriteRect2.tessellationDetail;
         SerializedProperty serializedProperty2 = so.FindProperty("m_SpriteSheet.m_Outline");
         if (spriteRect2.outline != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty2, spriteRect2.outline);
         }
         else
         {
             serializedProperty2.ClearArray();
         }
         SerializedProperty serializedProperty3 = so.FindProperty("m_SpriteSheet.m_PhysicsShape");
         if (spriteRect2.physicsShape != null)
         {
             SpriteRect.ApplyOutlineChanges(serializedProperty3, spriteRect2.physicsShape);
         }
         else
         {
             serializedProperty3.ClearArray();
         }
     }
     EditorUtility.ClearProgressBar();
 }
        private void CheckList(UnityEditor.SerializedProperty targets)
        {
            if (targetsList == null)
            {
                targetsList = new UnityEditorInternal.ReorderableList(serializedObject, targets);

                targetsList.drawHeaderCallback = position => EditorGUI.LabelField(position, "Renderers. All renderers that will be included to outline rendering should be in the list.");

                targetsList.drawElementCallback = (position, item, isActive, isFocused) =>
                {
                    var renderPosition = position;
                    var element        = targets.GetArrayElementAtIndex(item);
                    var rendererItem   = element.FindPropertyRelative("Renderer");
                    var reference      = rendererItem.objectReferenceValue;

                    EditorGUI.PropertyField(renderPosition, element, new GUIContent(reference == null ? "Null" : reference.name), true);
                };

                targetsList.elementHeightCallback = (index) => EditorGUI.GetPropertyHeight(targets.GetArrayElementAtIndex(index));

                targetsList.onRemoveCallback = (list) =>
                {
                    var index = list.index;
                    targets.DeleteArrayElementAtIndex(index);
                    targets.serializedObject.ApplyModifiedProperties();
                };

                targetsList.onAddDropdownCallback = (buttonRect, targetList) =>
                {
                    var outlinable = target as Outlinable;
                    var items      = outlinable.gameObject.GetComponentsInChildren <Renderer>(true);
                    var menu       = new GenericMenu();

                    if (!Application.isPlaying)
                    {
                        menu.AddItem(new GUIContent("Add all"), false, () =>
                        {
                            (target as Outlinable).AddAllChildRenderersToRenderingList();

                            EditorUtility.SetDirty(target);
                        });
                    }

                    menu.AddItem(new GUIContent("Empty"), false, () =>
                    {
                        (target as Outlinable).OutlineTargets.Add(new OutlineTarget());

                        EditorUtility.SetDirty(target);
                    });

                    foreach (var item in items)
                    {
                        var found = false;
                        for (var index = 0; index < targets.arraySize; index++)
                        {
                            var element         = targets.GetArrayElementAtIndex(index);
                            var elementRenderer = element.FindPropertyRelative("Renderer");
                            if (elementRenderer.objectReferenceValue == item)
                            {
                                found = true;
                                break;
                            }
                        }

                        var path = string.Empty;
                        if (item.transform != outlinable.transform)
                        {
                            var parent = item.transform;
                            do
                            {
                                path   = string.Format("{0}/{1}", parent.ToString(), path);
                                parent = parent.transform.parent;
                            }while (parent != outlinable.transform);

                            path = string.Format("{0}/{1}", parent.ToString(), path);

                            path = path.Substring(0, path.Length - 1);
                        }
                        else
                        {
                            path = item.ToString();
                        }

                        GenericMenu.MenuFunction function = () =>
                        {
                            var index = targets.arraySize;
                            targets.InsertArrayElementAtIndex(index);
                            var arrayItem = targets.GetArrayElementAtIndex(index);
                            var renderer  = arrayItem.FindPropertyRelative("Renderer");
                            arrayItem.FindPropertyRelative("CutoutThreshold").floatValue = 0.5f;
                            renderer.objectReferenceValue = item;

                            serializedObject.ApplyModifiedProperties();
                        };

                        if (found)
                        {
                            function = null;
                        }

                        menu.AddItem(new GUIContent(path), found, function);
                    }

                    menu.ShowAsContext();
                };
            }
        }
        private void ShowMaterialGUI()
        {
            serializedObject.UpdateIfRequiredOrScript();

            EditorGUILayout.Popup(m_MaterialLocation, Styles.MaterialLocationOpt, Styles.MaterialLocation);

            string materialHelp = string.Empty;

            if (!m_MaterialLocation.hasMultipleDifferentValues)
            {
                if (m_Materials.arraySize > 0 && HasEmbeddedMaterials())
                {
                    // we're generating materials inside the prefab
                    materialHelp = Styles.InternalMaterialHelp.text;
                }

                if (targets.Length == 1 && m_Materials.arraySize > 0 && m_MaterialLocation.intValue != 0)
                {
                    materialHelp += " " + Styles.MaterialAssignmentsHelp.text;
                }

                // display the extract buttons
                if (m_MaterialLocation.intValue != 0)
                {
                    if (ExtractMaterialsGUI())
                    {
                        return;
                    }
                }
            }

            if (!string.IsNullOrEmpty(materialHelp))
            {
                EditorGUILayout.HelpBox(materialHelp, MessageType.Info);
            }

            if ((targets.Length == 1 || m_SupportsEmbeddedMaterials.hasMultipleDifferentValues == false) && m_SupportsEmbeddedMaterials.boolValue == false &&
                m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues)
            {
                EditorGUILayout.Space();
                EditorGUILayout.HelpBox(Styles.NoMaterialMappingsHelp.text, MessageType.Warning);
            }

            // The material remap list
            if (targets.Length == 1 && m_Materials.arraySize > 0 && m_MaterialLocation.intValue != 0 && !m_MaterialLocation.hasMultipleDifferentValues)
            {
                GUILayout.Label(Styles.ExternalMaterialMappings, EditorStyles.boldLabel);

                if (MaterialRemapOptons())
                {
                    return;
                }

                // The list of material names is immutable, whereas the map of external objects can change based on user actions.
                // For each material name, map the external object associated with it.
                // The complexity comes from the fact that we may not have an external object in the map, so we can't make a property out of it
                for (int materialIdx = 0; materialIdx < m_Materials.arraySize; ++materialIdx)
                {
                    var id       = m_Materials.GetArrayElementAtIndex(materialIdx);
                    var name     = id.FindPropertyRelative("name").stringValue;
                    var type     = id.FindPropertyRelative("type").stringValue;
                    var assembly = id.FindPropertyRelative("assembly").stringValue;

                    SerializedProperty materialProp = null;
                    Material           material     = null;
                    var propertyIdx = 0;

                    for (int externalObjectIdx = 0, count = m_ExternalObjects.arraySize; externalObjectIdx < count; ++externalObjectIdx)
                    {
                        var pair         = m_ExternalObjects.GetArrayElementAtIndex(externalObjectIdx);
                        var externalName = pair.FindPropertyRelative("first.name").stringValue;
                        var externalType = pair.FindPropertyRelative("first.type").stringValue;

                        if (externalName == name && externalType == type)
                        {
                            materialProp = pair.FindPropertyRelative("second");
                            material     = materialProp != null ? materialProp.objectReferenceValue as Material : null;
                            propertyIdx  = externalObjectIdx;
                            break;
                        }
                    }

                    GUIContent nameLabel = EditorGUIUtility.TextContent(name);
                    nameLabel.tooltip = name;
                    if (materialProp != null)
                    {
                        EditorGUI.BeginChangeCheck();
                        EditorGUILayout.ObjectField(materialProp, typeof(Material), nameLabel);
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (materialProp.objectReferenceValue == null)
                            {
                                m_ExternalObjects.DeleteArrayElementAtIndex(propertyIdx);
                            }
                        }
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        material = EditorGUILayout.ObjectField(nameLabel, material, typeof(Material), false) as Material;
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (material != null)
                            {
                                var newIndex = m_ExternalObjects.arraySize++;
                                var pair     = m_ExternalObjects.GetArrayElementAtIndex(newIndex);
                                pair.FindPropertyRelative("first.name").stringValue      = name;
                                pair.FindPropertyRelative("first.type").stringValue      = type;
                                pair.FindPropertyRelative("first.assembly").stringValue  = assembly;
                                pair.FindPropertyRelative("second").objectReferenceValue = material;
                            }
                        }
                    }
                }
            }
        }
Example #47
0
        internal List <LODGroupGUI.LODInfo> GetLODInfoArray(Rect area)
        {
            int lodCount = m_LODSettings.arraySize;

            return(LODGroupGUI.CreateLODInfos(
                       lodCount, area,
                       i => i == lodCount - 1 && (target as SpeedTreeImporter).hasBillboard ? "Billboard" : String.Format("LOD {0}", i),
                       i => m_LODSettings.GetArrayElementAtIndex(i).FindPropertyRelative("height").floatValue));
        }
        private void DrawAreaListElement(Rect rect, int index, bool selected, bool focused)
        {
            SerializedProperty areaProp = m_Areas.GetArrayElementAtIndex(index);

            if (areaProp == null)
            {
                return;
            }
            SerializedProperty nameProp = areaProp.FindPropertyRelative("name");
            SerializedProperty costProp = areaProp.FindPropertyRelative("cost");

            if (nameProp == null || costProp == null)
            {
                return;
            }

            rect.height -= 2; // nicer looking with selected list row and a text field in it

            bool builtInLayer    = false;
            bool allowChangeName = true;
            bool allowChangeCost = true;

            switch (index)
            {
            case 0:     // Default
                builtInLayer    = true;
                allowChangeName = false;
                allowChangeCost = true;
                break;

            case 1:     // NonWalkable
                builtInLayer    = true;
                allowChangeName = false;
                allowChangeCost = false;
                break;

            case 2:     // Jump
                builtInLayer    = true;
                allowChangeName = false;
                allowChangeCost = true;
                break;

            default:
                builtInLayer    = false;
                allowChangeName = true;
                allowChangeCost = true;
                break;
            }

            Rect stripeRect, labelRect, nameRect, costRect;

            GetAreaListRects(rect, out stripeRect, out labelRect, out nameRect, out costRect);

            bool  oldEnabled = GUI.enabled;
            Color color      = GetAreaColor(index);
            Color dimmed     = new Color(color.r * 0.1f, color.g * 0.1f, color.b * 0.1f, 0.6f);

            EditorGUI.DrawRect(stripeRect, color);

            EditorGUI.DrawRect(new Rect(stripeRect.x, stripeRect.y, 1, stripeRect.height), dimmed);
            EditorGUI.DrawRect(new Rect(stripeRect.x + stripeRect.width - 1, stripeRect.y, 1, stripeRect.height), dimmed);
            EditorGUI.DrawRect(new Rect(stripeRect.x + 1, stripeRect.y, stripeRect.width - 2, 1), dimmed);
            EditorGUI.DrawRect(new Rect(stripeRect.x + 1, stripeRect.y + stripeRect.height - 1, stripeRect.width - 2, 1), dimmed);

            if (builtInLayer)
            {
                GUI.Label(labelRect, EditorGUIUtility.TempContent("Built-in " + index));
            }
            else
            {
                GUI.Label(labelRect, EditorGUIUtility.TempContent("User " + index));
            }

            int oldIndent = EditorGUI.indentLevel;

            EditorGUI.indentLevel = 0;

            GUI.enabled = oldEnabled && allowChangeName;
            EditorGUI.PropertyField(nameRect, nameProp, GUIContent.none);

            GUI.enabled = oldEnabled && allowChangeCost;
            EditorGUI.PropertyField(costRect, costProp, GUIContent.none);

            GUI.enabled = oldEnabled;

            EditorGUI.indentLevel = oldIndent;
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_Sprite, Contents.spriteLabel);

            EditorGUILayout.PropertyField(m_Color, Contents.colorLabel, true);

            FlipToggles();

            Rect r = GUILayoutUtility.GetRect(
                EditorGUILayout.kLabelFloatMinW, EditorGUILayout.kLabelFloatMaxW,
                EditorGUI.kSingleLineHeight, EditorGUI.kSingleLineHeight);

            EditorGUI.showMixedValue = m_Material.hasMultipleDifferentValues;
            Object currentMaterialRef  = m_Material.GetArrayElementAtIndex(0).objectReferenceValue;
            Object returnedMaterialRef = EditorGUI.ObjectField(r, Contents.materialLabel, currentMaterialRef, typeof(Material), false);

            if (returnedMaterialRef != currentMaterialRef)
            {
                m_Material.GetArrayElementAtIndex(0).objectReferenceValue = returnedMaterialRef;
            }
            EditorGUI.showMixedValue = false;

            EditorGUILayout.PropertyField(m_DrawMode, Contents.drawModeLabel);

            m_ShowDrawMode.target = ShouldShowDrawMode();
            if (EditorGUILayout.BeginFadeGroup(m_ShowDrawMode.faded))
            {
                string notFullRectWarning = GetSpriteNotFullRectWarning();
                if (notFullRectWarning != null)
                {
                    EditorGUILayout.HelpBox(notFullRectWarning, MessageType.Warning);
                }

                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.PrefixLabel(Contents.sizeLabel);
                EditorGUI.showMixedValue = m_Size.hasMultipleDifferentValues;
                FloatFieldLabelAbove(Contents.widthLabel, m_Size.FindPropertyRelative("x"));
                FloatFieldLabelAbove(Contents.heightLabel, m_Size.FindPropertyRelative("y"));
                EditorGUI.showMixedValue = false;
                EditorGUILayout.EndHorizontal();

                m_ShowTileMode.target = ShouldShowTileMode();
                if (EditorGUILayout.BeginFadeGroup(m_ShowTileMode.faded))
                {
                    EditorGUILayout.PropertyField(m_SpriteTileMode, Contents.fullTileLabel);

                    m_ShowAdaptiveThreshold.target = ShouldShowAdaptiveThreshold();
                    if (EditorGUILayout.BeginFadeGroup(m_ShowAdaptiveThreshold.faded))
                    {
                        EditorGUI.indentLevel++;
                        EditorGUILayout.Slider(m_AdaptiveModeThreshold, 0.0f, 1.0f, Contents.fullTileThresholdLabel);
                        EditorGUI.indentLevel--;
                    }
                    EditorGUILayout.EndFadeGroup();
                }
                EditorGUILayout.EndFadeGroup();
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.EndFadeGroup();

            RenderSortingLayerFields();

            EditorGUILayout.PropertyField(m_MaskInteraction, Contents.maskInteractionLabel);

            EditorGUILayout.PropertyField(m_SpriteSortPoint, Contents.spriteSortPointLabel);

            RenderRenderingLayer();

            CheckForErrors();

            serializedObject.ApplyModifiedProperties();
        }
Example #50
0
        void SynchronizeSceneBindings()
        {
            if (targets.Length > 1)
            {
                return;
            }

            var director      = (PlayableDirector)target;
            var playableAsset = m_PlayableAsset.objectReferenceValue as PlayableAsset;

            hasUnused = false;
            m_BindingItems.Clear();
            UpdatePlayableBindingsIfRequired(playableAsset, director);

            var mainAssetPath = AssetDatabase.GetAssetPath(director.playableAsset);

            for (int i = 0; i < m_SceneBindings.arraySize; ++i)
            {
                var property  = m_SceneBindings.GetArrayElementAtIndex(i);
                var keyObject = property.FindPropertyRelative("key").objectReferenceValue;

                // Don't show completely null keys.
                if (((object)keyObject) == null)
                {
                    continue;
                }

                var assetPath  = AssetDatabase.GetAssetPath(keyObject);
                var cacheValue = new BindingItem()
                {
                    property      = property,
                    AssetPath     = assetPath,
                    IsMainAsset   = !string.IsNullOrEmpty(assetPath) && mainAssetPath == assetPath,
                    masterAsset   = !string.IsNullOrEmpty(assetPath) ? AssetDatabase.LoadMainAssetAtPath(assetPath) as PlayableAsset : null,
                    propertyIndex = i,
                };
                cacheValue.binding = FindBinding(cacheValue.masterAsset, keyObject);

                hasUnused |= !cacheValue.IsMainAsset;

                if (showUnused || cacheValue.IsMainAsset)
                {
                    m_BindingItems.Add(cacheValue);
                }
            }

            m_BindingItems.Sort((a, b) =>
            {
                if (a.IsMainAsset == b.IsMainAsset)
                {
                    return(-string.CompareOrdinal(a.AssetPath, b.AssetPath));
                }
                if (a.IsMainAsset)
                {
                    return(-1);
                }
                return(1);
            }
                                );

            if (showUnused)
            {
                bool addHeader = false;
                for (int i = 0; i < m_BindingItems.Count - 1; i++)
                {
                    if (m_BindingItems[i].masterAsset != m_BindingItems[i + 1].masterAsset)
                    {
                        m_BindingItems.Insert(i + 1, new BindingItem()
                        {
                            masterAsset = m_BindingItems[i + 1].masterAsset, propertyIndex = -1
                        }
                                              );
                        addHeader = true;
                    }
                }

                if (addHeader && m_BindingItems.Count > 0)
                {
                    m_BindingItems.Insert(0, new BindingItem()
                    {
                        masterAsset   = m_BindingItems[0].masterAsset,
                        propertyIndex = -1,
                        IsMainAsset   = m_BindingItems[0].masterAsset == director.playableAsset,
                    }
                                          );
                }
            }
        }
Example #51
0
        public void OnBlendShapeUI()
        {
            SkinnedMeshRenderer renderer = (SkinnedMeshRenderer)target;
            int blendShapeCount          = renderer.sharedMesh == null ? 0 : renderer.sharedMesh.blendShapeCount;

            if (blendShapeCount == 0)
            {
                return;
            }

            GUIContent content = new GUIContent();

            content.text = "BlendShapes";

            EditorGUILayout.PropertyField(m_BlendShapeWeights, content, false);
            if (!m_BlendShapeWeights.isExpanded)
            {
                return;
            }

            EditorGUI.indentLevel++;

            if (PlayerSettings.legacyClampBlendShapeWeights)
            {
                EditorGUILayout.HelpBox(Styles.legacyClampBlendShapeWeightsInfo.text, MessageType.Info);
            }

            Mesh m = renderer.sharedMesh;

            int arraySize = m_BlendShapeWeights.arraySize;

            for (int i = 0; i < blendShapeCount; i++)
            {
                content.text = m.GetBlendShapeName(i);

                // Calculate the min and max values for the slider from the frame blendshape weights
                float sliderMin = 0f, sliderMax = 0f;

                int frameCount = m.GetBlendShapeFrameCount(i);
                for (int j = 0; j < frameCount; j++)
                {
                    float frameWeight = m.GetBlendShapeFrameWeight(i, j);
                    sliderMin = Mathf.Min(frameWeight, sliderMin);
                    sliderMax = Mathf.Max(frameWeight, sliderMax);
                }

                // The SkinnedMeshRenderer blendshape weights array size can be out of sync with the size defined in the mesh
                // (default values in that case are 0)
                // The desired behaviour is to resize the blendshape array on edit.

                // Default path when the blend shape array size is big enough.
                if (i < arraySize)
                {
                    EditorGUILayout.Slider(m_BlendShapeWeights.GetArrayElementAtIndex(i), sliderMin, sliderMax, float.MinValue, float.MaxValue, content);
                }
                // Fall back to 0 based editing &
                else
                {
                    EditorGUI.BeginChangeCheck();

                    float value = EditorGUILayout.Slider(content, 0f, sliderMin, sliderMax, float.MinValue, float.MaxValue);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_BlendShapeWeights.arraySize = blendShapeCount;
                        arraySize = blendShapeCount;
                        m_BlendShapeWeights.GetArrayElementAtIndex(i).floatValue = value;
                    }
                }
            }

            EditorGUI.indentLevel--;
        }
Example #52
0
        private static void AddAxe(InputAxis axe, ref UnityEditor.SerializedProperty currentList)
        {
            var index            = currentList.arraySize++;
            var newItem          = currentList.GetArrayElementAtIndex(index);
            var iteratorProperty = newItem.Copy();

            iteratorProperty.Next(true);
            do
            {
                switch (iteratorProperty.name)
                {
                case "m_Name":
                    iteratorProperty.stringValue = axe.name;
                    break;

                case "descriptiveName":
                    iteratorProperty.stringValue = axe.descriptiveName;
                    break;

                case "descriptiveNegativeName":
                    iteratorProperty.stringValue = axe.descriptiveNegativeName;
                    break;

                case "negativeButton":
                    iteratorProperty.stringValue = axe.negativeButton;
                    break;

                case "positiveButton":
                    iteratorProperty.stringValue = axe.positiveButton;
                    break;

                case "altNegativeButton":
                    iteratorProperty.stringValue = axe.altNegativeButton;
                    break;

                case "altPositiveButton":
                    iteratorProperty.stringValue = axe.altPositiveButton;
                    break;

                case "gravity":
                    iteratorProperty.floatValue = axe.gravity;
                    break;

                case "dead":
                    iteratorProperty.floatValue = axe.dead;
                    break;

                case "sensitivity":
                    iteratorProperty.floatValue = axe.sensitivity;
                    break;

                case "snap":
                    iteratorProperty.boolValue = axe.snap;
                    break;

                case "invert":
                    iteratorProperty.boolValue = axe.invert;
                    break;

                case "type":
                    iteratorProperty.intValue = axe.type;
                    break;

                case "axis":
                    iteratorProperty.intValue = axe.axis - 1;
                    break;

                case "joyNum":
                    iteratorProperty.intValue = axe.joyNum;
                    break;
                }
            } while (iteratorProperty.Next(false));
        }