当前位置: 首页>>代码示例>>C#>>正文


C# SerializedProperty.DeleteArrayElementAtIndex方法代码示例

本文整理汇总了C#中UnityEditor.SerializedProperty.DeleteArrayElementAtIndex方法的典型用法代码示例。如果您正苦于以下问题:C# SerializedProperty.DeleteArrayElementAtIndex方法的具体用法?C# SerializedProperty.DeleteArrayElementAtIndex怎么用?C# SerializedProperty.DeleteArrayElementAtIndex使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEditor.SerializedProperty的用法示例。


在下文中一共展示了SerializedProperty.DeleteArrayElementAtIndex方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ShowList

        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;
            }
        }
开发者ID:SHEePYTaGGeRNeP,项目名称:ProftaakMobileGDT,代码行数:25,代码来源:EnhancementEditor.cs

示例2: OnGUI

    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
    }
开发者ID:SquarePieStudios,项目名称:BrokenInspector,代码行数:29,代码来源:BrokenInspectorEditor.cs

示例3: ShowButtons

 static void ShowButtons(SerializedProperty list, int index)
 {
     if (GUILayout.Button(moveButtonContent, EditorStyles.miniButtonLeft, miniButtonWidth)) {
         list.MoveArrayElement(index, index + 1);
     }
     if (GUILayout.Button(duplicateButtonContent, EditorStyles.miniButtonMid, miniButtonWidth)) {
         list.InsertArrayElementAtIndex(index);
     }
     if (GUILayout.Button(deleteButtonContent, EditorStyles.miniButtonRight, miniButtonWidth)) {
         int oldSize = list.arraySize;
         list.DeleteArrayElementAtIndex(index);
         if (list.arraySize == oldSize) {
             list.DeleteArrayElementAtIndex(index);
         }
     }
 }
开发者ID:SethSR,项目名称:Mech-Game,代码行数:16,代码来源:EditorList.cs

示例4: ShowAnimationList

        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--;
        }
开发者ID:cupsster,项目名称:Klak,代码行数:25,代码来源:ValueAnimationEditor.cs

示例5: AttackPatternField

 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);
     }
 }
开发者ID:james7132,项目名称:Hysteria,代码行数:44,代码来源:BossEditor.cs

示例6: ArrayList

        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();
            });
            }
        }
开发者ID:hagura,项目名称:unity_chiruno04,代码行数:55,代码来源:EditorBase.cs

示例7: DrawList

 public static void DrawList(ref Rect position, SerializedProperty property)
 {
     position.height = 16;
     EditorGUI.PropertyField (position, property);
     position.y += 18;
     EditorGUI.indentLevel++;
     if (property.isExpanded) {
         Rect buttonPosition;
         for (int i = 0; i < property.arraySize; i++) {
             buttonPosition = position;
             buttonPosition.height = 16;
             buttonPosition.width = 20;
             buttonPosition.x += position.width - 62;
             if (GUI.Button (buttonPosition, moveButtonContent, EditorStyles.miniButtonLeft)) {
                 property.MoveArrayElement (i, i + 1);
             }
             buttonPosition.x += 20;
             if (GUI.Button (buttonPosition, duplicateButtonContent, EditorStyles.miniButtonMid)) {
                 property.InsertArrayElementAtIndex (i);
             }
             buttonPosition.x += 20;
             if (GUI.Button (buttonPosition, deleteButtonContent, EditorStyles.miniButtonRight)) {
                 int oldsize = property.arraySize;
                 property.DeleteArrayElementAtIndex (i);
                 if (oldsize == property.arraySize) {
                     property.DeleteArrayElementAtIndex (i);
                 }
             } else {
                 DrawProperty (ref position, property.GetArrayElementAtIndex (i), true);
             }
         }
         buttonPosition = position;
         buttonPosition.height = 16;
         buttonPosition.width -= EditorGUI.indentLevel * 16;
         buttonPosition.x += EditorGUI.indentLevel * 16;
         if (GUI.Button (buttonPosition, addButtonContent, EditorStyles.miniButton)) {
             property.arraySize += 1;
         }
         position.y += 18;
     }
     EditorGUI.indentLevel--;
 }
开发者ID:tdroesch,项目名称:Trials-of-the-Damned,代码行数:42,代码来源:EditorUtilities.cs

示例8: CreateArrayPropertyField

    private void CreateArrayPropertyField(SerializedProperty arrayObject, string text, string tooltipText)
    {
        if(CreateButton("Add", "Add element to list.") == true)
            arrayObject.arraySize += 1;

        int objectCount = arrayObject.arraySize;
        for(int i = 0; i < objectCount; ++i)
        {
            EditorGUILayout.BeginHorizontal();
            CreatePropertyField(arrayObject.GetArrayElementAtIndex(i), text, tooltipText);
            bool removeButtonIsPressed = CreateButton("Remove", "Removes the current element from the list.");
            EditorGUILayout.EndHorizontal();
            if(removeButtonIsPressed == true)
            {
                arrayObject.DeleteArrayElementAtIndex(i);
                break;
            }
        }
    }
开发者ID:DevMikaelNilsson,项目名称:MovingTileMatchPuzzle,代码行数:19,代码来源:CreateObjectListEditor.cs

示例9: ShowButtons

    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);
        }
    }
开发者ID:cyberimp,项目名称:Dark-Invaders,代码行数:20,代码来源:EditorList.cs

示例10: Draw

		public static void Draw (Rect _position, SerializedProperty _arrayProperty, GUIContent _label, eArrayOptions _options)
		{
			int _originalIndentLevel	= EditorGUI.indentLevel;
			int _count					= _arrayProperty.arraySize;
			bool _showNameWithFoldout	= (_options & eArrayOptions.SHOW_NAME_WITH_FOLDOUT) != 0;
			bool _showArraySize			= (_options & eArrayOptions.SHOW_ARRAY_SIZE) != 0;

			// Height used for primitive properties and buttons
			float _singleLineHeight		= EditorGUIUtility.singleLineHeight;
			
			// Calculate rect
			float _positionY			= _position.y;

			// Rect for array name
			Rect _nameRect				= new Rect(_position.x, _positionY, _position.width, _singleLineHeight);
			_positionY					+= (_singleLineHeight + kSpacingPixels);
			
			// Show array name
			if (_showNameWithFoldout)
			{
				_arrayProperty.isExpanded	= EditorGUI.Foldout(_nameRect, _arrayProperty.isExpanded, _label);

				// Indent to next level
				EditorGUI.indentLevel++;
			}
			else
			{
				EditorGUI.LabelField(_nameRect, _label);
			}

			// Is foldout enabled, then dont show the rest of the elements
			if (!_arrayProperty.isExpanded)
			{
				// Reset indentation level
				EditorGUI.indentLevel	= _originalIndentLevel;
				return;
			}

			// Show array size
			if (_showArraySize && _count != 0)
			{
				// Rect for array Length
				Rect _sizeRect		= new Rect(_position.x, _positionY, _position.width, _singleLineHeight);
				_positionY			+= (_singleLineHeight + kSpacingPixels);

				// Check if size value changes
				EditorGUI.BeginChangeCheck();
				int _newSize		= EditorGUI.IntField(_sizeRect, "Size", _count);

				if (EditorGUI.EndChangeCheck())
					_arrayProperty.arraySize	= _newSize;
			}			

			// If there are no elements then we will show button to add elements
			if (_count == 0)
			{
				// Rect for add button
				Rect _addButtonRect	= new Rect(_position.x, _positionY, _position.width, _singleLineHeight);
				_positionY			+= (_singleLineHeight + kSpacingPixels);

				if (GUI.Button(_addButtonRect, "Add"))
					_arrayProperty.InsertArrayElementAtIndex(0);
			}
			else
			{
				// If there are elements then we will show its contents
				for (int _iter = 0; _iter < _count; _iter++)
				{
					// Get element property
					SerializedProperty _elementProperty	= _arrayProperty.GetArrayElementAtIndex(_iter);
					float _elementHeight				= EditorGUI.GetPropertyHeight(_elementProperty);

					// Rect for element, edit buttons
					Rect _elementRect		= new Rect(_position.x, _positionY, _position.width, _elementHeight);
					_positionY				+= _elementHeight;
					Rect _deleteButtonRect	= new Rect(_position.x + _position.width - kEditButtonWidth, _positionY, 
					                                  kEditButtonWidth, _singleLineHeight);
					Rect _addButtonRect		= new Rect(_deleteButtonRect.x - kEditButtonWidth, _positionY, 
					                                kEditButtonWidth, _singleLineHeight);
					_positionY				+= _singleLineHeight + kSpacingPixels;

					// Grouping element and buttons
					EditorGUI.PropertyField(_elementRect,
					                        _elementProperty, 
					                        new GUIContent("# " + (_iter + 1).ToString() + ":"), 
					                        true);
					
					if (GUI.Button(_addButtonRect, "+"))
					{
						_arrayProperty.InsertArrayElementAtIndex(0);
						break;
					}
					
					if (GUI.Button(_deleteButtonRect, "-"))
					{
						_arrayProperty.DeleteArrayElementAtIndex(_iter);
						break;
					}
				}
			}
//.........这里部分代码省略.........
开发者ID:noahzaozao,项目名称:UnityAdmobAppEventDemo,代码行数:101,代码来源:ArrayDrawer.cs

示例11: DrawMultipleSurface

    void DrawMultipleSurface(SerializedProperty surfaceList)
    {
        GUILayout.BeginVertical();
        EditorGUILayout.PropertyField(surfaceList);
        if (surfaceList.isExpanded)
        {
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Add"))
            {
                surfaceList.arraySize++;
            }
            if (GUILayout.Button("Clear"))
            {
                surfaceList.arraySize = 0;
            }
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            for (int i = 0; i < surfaceList.arraySize; i++)
            {
                GUILayout.BeginHorizontal();
                GUILayout.BeginHorizontal("box");

                EditorGUILayout.Space();
                if (i < surfaceList.arraySize && i >= 0)
                {
                    EditorGUILayout.BeginVertical();
                    EditorGUILayout.PropertyField(surfaceList.GetArrayElementAtIndex(i));
                    if (surfaceList.GetArrayElementAtIndex(i).isExpanded)
                    DrawSingleSurface(surfaceList.GetArrayElementAtIndex(i), true);
                    EditorGUILayout.Space();
                    GUILayout.EndVertical();
                }
                GUILayout.EndHorizontal();

                if (GUILayout.Button("-"))
                {
                    surfaceList.DeleteArrayElementAtIndex(i);
                }
                GUILayout.EndHorizontal();
            }
        }
        GUILayout.EndVertical();
    }
开发者ID:yenv672,项目名称:thesis,代码行数:43,代码来源:FootStepEditor.cs

示例12: ClearMaterialArray

	void ClearMaterialArray(PropType type, SerializedProperty props) {
		for (int i = 0; i < props.arraySize; ++i) {
			var prop = props.GetArrayElementAtIndex(i);
			var nameProp = prop.FindPropertyRelative("first.name");
			string propName = nameProp.stringValue;

			if (!MaterialPropNames.ContainsKey(propName) || MaterialPropNames[propName].type != type) {
				props.DeleteArrayElementAtIndex(i);
				--i;
			}
		}

		MatEditor.OnEnable();
	}
开发者ID:jharger,项目名称:globalgamejam2016,代码行数:14,代码来源:AlloyInspectorBase.cs

示例13: DrawListLayout

 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--;
 }
开发者ID:tdroesch,项目名称:Trials-of-the-Damned,代码行数:29,代码来源:EditorUtilities.cs

示例14: DrawInputBehaviorSettings

        private void DrawInputBehaviorSettings(SerializedProperty settingsArray) {
            if(settingsArray == null || !settingsArray.isArray) return;

            EditorGUILayout.Space();

            EditorGUILayout.HelpBox(
                "You can define a list of Input Behaviors to be shown to the user for modification. If enabled, new controls will be displayed so the user can modify these settings. " +
                "This is useful if you need to allow the user to set certain per-Action sensitivity levels such as Mouse Look Sensitivity."
            , MessageType.Info);

            EditorGUILayout.Space();

            int[] inputBehaviorIds = userData.GetInputBehaviorIds();
            string[] inputBehaviorNames = userData.GetInputBehaviorNames();

            int count = settingsArray.arraySize;
            for(int i = 0; i < count; i++) {

                using(new EditorGUILayoutSection(true, style_mapSetBkg)) {

                    SerializedProperty setting = settingsArray.GetArrayElementAtIndex(i);
                    if(setting == null) continue;

                    GUILayout.Space(20f);
                    SerializedProperty inputBehaviorId = setting.FindPropertyRelative("_inputBehaviorId");
                    DrawPopupProperty(new GUIContent("Input Behavior", "The Input Behavior that will be displayed to the user for modification."), inputBehaviorIds, inputBehaviorNames, inputBehaviorId); // NOTE: mapCategoryId tool tip from Attribute is always NULL!
                    int selectedIndex = System.Array.IndexOf<int>(inputBehaviorIds, inputBehaviorId.intValue);
                    if(selectedIndex < 0) continue;

                    // Display settings

                    SerializedProperty labelLanguageKey = setting.FindPropertyRelative("_labelLanguageKey");

                    SerializedProperty showJoystickAxisSensitivity = setting.FindPropertyRelative("_showJoystickAxisSensitivity");
                    SerializedProperty showMouseXYAxisSensitivity = setting.FindPropertyRelative("_showMouseXYAxisSensitivity");

                    SerializedProperty joystickAxisSensitivityLabelLanguageKey = setting.FindPropertyRelative("_joystickAxisSensitivityLabelLanguageKey");
                    SerializedProperty mouseXYAxisSensitivityLabelLanguageKey = setting.FindPropertyRelative("_mouseXYAxisSensitivityLabelLanguageKey");

                    SerializedProperty joystickAxisSensitivityIcon = setting.FindPropertyRelative("_joystickAxisSensitivityIcon");
                    SerializedProperty mouseXYAxisSensitivityIcon = setting.FindPropertyRelative("_mouseXYAxisSensitivityIcon");

                    SerializedProperty joystickAxisSensitivityMin = setting.FindPropertyRelative("_joystickAxisSensitivityMin");
                    SerializedProperty joystickAxisSensitivityMax = setting.FindPropertyRelative("_joystickAxisSensitivityMax");
                    SerializedProperty mouseXYAxisSensitivityMin = setting.FindPropertyRelative("_mouseXYAxisSensitivityMin");
                    SerializedProperty mouseXYAxisSensitivityMax = setting.FindPropertyRelative("_mouseXYAxisSensitivityMax");

                    EditorGUILayout.PropertyField(labelLanguageKey);
                    
                    EditorGUILayout.PropertyField(showJoystickAxisSensitivity);
                    if(showJoystickAxisSensitivity.boolValue) {
                        EditorGUILayout.PropertyField(joystickAxisSensitivityLabelLanguageKey);
                        EditorGUILayout.PropertyField(joystickAxisSensitivityIcon);
                        DrawFloatProperty(joystickAxisSensitivityMin, 0f, 10000f);
                        DrawFloatProperty(joystickAxisSensitivityMax, 0f, 10000f);
                    }

                    EditorGUILayout.PropertyField(showMouseXYAxisSensitivity);
                    if(showMouseXYAxisSensitivity.boolValue) {
                        EditorGUILayout.PropertyField(mouseXYAxisSensitivityLabelLanguageKey);
                        EditorGUILayout.PropertyField(mouseXYAxisSensitivityIcon);
                        DrawFloatProperty(mouseXYAxisSensitivityMin, 0f, 10000f);
                        DrawFloatProperty(mouseXYAxisSensitivityMax, 0f, 10000f);
                    }
                    
                    EditorGUILayout.Space();

                    // Array control butons
                    GUILayout.Space(20f);
                    using(new EditorGUILayoutSection(false)) {
                        GUILayout.FlexibleSpace();
                        if(GUILayout.Button("Delete", GUILayout.ExpandWidth(false), GUILayout.Width(100f))) {
                            settingsArray.DeleteArrayElementAtIndex(i);
                            break; // exit now to avoid issues
                        }
                    }
                }

                GUILayout.Space(20f);
            }

            EditorGUILayout.Space();
            if(GUILayout.Button("+ Add Input Behavior")) {
                settingsArray.InsertArrayElementAtIndex(settingsArray.arraySize);
                SerializedProperty setting = settingsArray.GetArrayElementAtIndex(settingsArray.arraySize - 1);
                // Clear to defaults
                setting.FindPropertyRelative("_inputBehaviorId").intValue = 0;
                setting.FindPropertyRelative("_labelLanguageKey").stringValue = string.Empty;
                setting.FindPropertyRelative("_showJoystickAxisSensitivity").boolValue = false;
                setting.FindPropertyRelative("_showMouseXYAxisSensitivity").boolValue = false;
                setting.FindPropertyRelative("_joystickAxisSensitivityLabelLanguageKey").stringValue = string.Empty;
                setting.FindPropertyRelative("_mouseXYAxisSensitivityLabelLanguageKey").stringValue = string.Empty;
                setting.FindPropertyRelative("_joystickAxisSensitivityIcon").objectReferenceValue = (Sprite)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("0c9ce4e64fb83764aa394faeeed56210"), typeof(Sprite));
                setting.FindPropertyRelative("_mouseXYAxisSensitivityIcon").objectReferenceValue = (Sprite)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath("fc88ce24a47f4014cb0ad237abc8d1dd"), typeof(Sprite));
                setting.FindPropertyRelative("_joystickAxisSensitivityMin").floatValue = 0.0f;
                setting.FindPropertyRelative("_joystickAxisSensitivityMax").floatValue = 2.0f;
                setting.FindPropertyRelative("_mouseXYAxisSensitivityMin").floatValue = 0.0f;
                setting.FindPropertyRelative("_mouseXYAxisSensitivityMax").floatValue = 2.0f;
            }
            EditorGUILayout.Space();
//.........这里部分代码省略.........
开发者ID:nkornek,项目名称:RocketShips,代码行数:101,代码来源:ControlMapperInspector.cs

示例15: RemoveRect

 //removes rect from the font settings and lists
 void RemoveRect()
 {
     ReFocusBlank = true;
     CharCount -= 1;
     SO = new SerializedObject( FontList[Rects[ClickedRectInd].fontIndex] );
     p = SO.FindProperty( "m_CharacterRects" );
     p.Next( true );
     p.DeleteArrayElementAtIndex( Rects[ClickedRectInd].CIIndex );
     SO.ApplyModifiedProperties(); //remove it from the actual font
     for ( int i = 0; i < Rects.Count; i++ ) { //Shift down all the CIindex for all rects in this font
         if ( Rects[i].fontIndex == Rects[ClickedRectInd].fontIndex && Rects[i].CIIndex > Rects[ClickedRectInd].CIIndex ) {
             Rects[i].CIIndex--;
         }
     }
     Rects.RemoveAt( ClickedRectInd ); //delete from the rect list
     if ( SpriteEditor ) { //check if removing has changed dupes
         CheckSprites();
     } else {
         CheckDupeChars();
     }
     ClickedRectInd--;
     ChrL--;
     if ( Rects.Count > 0 && ClickedRectInd == -1 ) {
         ClickedRectInd = 0;
     }
     if ( Rects.Count > 0 ) {
         GetFontInfoToGUI( Rects[ClickedRectInd].CIIndex, Rects[ClickedRectInd].fontIndex );
     } else {
         SpriteIndex = 0;
         SpriteIndexOld = 0;
     }
 }
开发者ID:mutatis,项目名称:cthulhu-free-iphone,代码行数:33,代码来源:FontEditorCs.cs


注:本文中的UnityEditor.SerializedProperty.DeleteArrayElementAtIndex方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。