示例#1
0
        private void DrawInstruction(Rect rect, SerializedProperty property, int index)
        {
            var element     = property.GetArrayElementAtIndex(index);
            var instruction = element.objectReferenceValue as Instruction;

            if (instruction != null)
            {
                var nameRect = new Rect(rect.x, rect.y, rect.width * 0.8f, EditorGUIUtility.singleLineHeight);
                var editRect = new Rect(nameRect.xMax + 5, rect.y, rect.width * 0.2f - 5, nameRect.height);

                using (var changes = new EditorGUI.ChangeCheckScope())
                {
                    instruction.name = EditorGUI.DelayedTextField(nameRect, instruction.name);

                    if (changes.changed)
                    {
                        InstructionDrawer.InstructionSetChanged(instruction.Set);
                    }
                }

                if (GUI.Button(editRect, EditorHelper.EditContent))
                {
                    _toEdit = instruction;
                }
            }
        }
示例#2
0
        private void Remove(InstructionSet set, int index)
        {
            using (new UndoScope(set))
            {
                var instruction = set.Instructions[index];
                if (instruction != null)
                {
                    Undo.DestroyObjectImmediate(instruction);
                }

                set.Instructions.RemoveAt(index);

                AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(set));
                InstructionDrawer.InstructionSetChanged(set);
            }
        }