コード例 #1
0
        public void Show(InstructionSet set)
        {
            titleContent = new GUIContent("Instructions");
            _set         = set;

            BuildTree();

            Show();
        }
コード例 #2
0
ファイル: InstructionDrawer.cs プロジェクト: larsolm/Archives
        // TODO: listen for on set added/removed

        public static void InstructionSetChanged(InstructionSet set)
        {
            foreach (var data in _popups)
            {
                if (data.Set == set)
                {
                    data.FlyoutNames = null;
                }
                data.RootNames = null;
            }
        }
コード例 #3
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);
            }
        }
コード例 #4
0
ファイル: InstructionDrawer.cs プロジェクト: larsolm/Archives
        public static Instruction Draw(Rect position, InstructionSet set, Instruction currentInstruction, GUIContent label)
        {
            if (label != null)
            {
                position = EditorGUI.PrefixLabel(position, label);
            }

            var popup = GetPopup(set);
            var names = popup.GetRootNames();
            var index = popup.GetIndex(currentInstruction);
            var left  = currentInstruction != null ? new Rect(position.x, position.y, position.width * 0.5f, EditorGUIUtility.singleLineHeight) : position;

            using (var changes = new EditorGUI.ChangeCheckScope())
            {
                index = EditorGUI.Popup(left, index, names);

                if (changes.changed)
                {
                    currentInstruction = popup.GetInstruction(index);
                }
            }

            if (currentInstruction != null)
            {
                var edit  = new Rect(left.xMax + 5, position.y, (position.width - left.width - 10) * 0.5f, EditorGUIUtility.singleLineHeight);
                var clear = new Rect(edit.xMax + 5, position.y, edit.width, edit.height);

                if (GUI.Button(edit, EditorHelper.EditContent))
                {
                    InstructionBreadcrumbs.Edit(currentInstruction);
                }

                if (GUI.Button(clear, EditorHelper.ClearContent))
                {
                    currentInstruction = null;
                }
            }

            return(currentInstruction);
        }
コード例 #5
0
ファイル: InstructionDrawer.cs プロジェクト: larsolm/Archives
        public static Instruction Create(InstructionSet set, SerializedProperty property, Type type)
        {
            var existingNames = set.Instructions.Select(i => i.name).ToArray();
            var instruction   = ScriptableObject.CreateInstance(type) as Instruction;

            instruction.name      = ObjectNames.GetUniqueName(existingNames, type.Name);
            instruction.hideFlags = HideFlags.HideInHierarchy;
            instruction.Set       = set;

            set.Instructions.Add(instruction);

            if (property != null)
            {
                property.serializedObject.Update();
                property.objectReferenceValue = instruction;
            }

            AssetDatabase.AddObjectToAsset(instruction, set);
            AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(set));

            InstructionSetChanged(set);

            return(instruction);
        }
コード例 #6
0
ファイル: InstructionDrawer.cs プロジェクト: larsolm/Archives
 private static PopupData GetPopup(InstructionSet set)
 {
     return(GetPopups().Single(p => p.Set == set));
 }
コード例 #7
0
 private void Design(InstructionSet set)
 {
     CreateInstance <InstructionSetWindow>().Show(set);
 }