/// <summary>
        /// Creates the context menu used by project library window. New context menu must be created when a new instance
        /// of the project library window is created.
        /// </summary>
        /// <param name="win">Instance of the project library window.</param>
        /// <returns>Context menu bound to the specified instance of the project library window.</returns>
        internal static ContextMenu CreateContextMenu(LibraryWindow win)
        {
            ContextMenu entryContextMenu = new ContextMenu();
            entryContextMenu.AddItem("Create", null);
            entryContextMenu.AddItem("Create/Folder", CreateFolder);
            entryContextMenu.AddItem("Create/Material", CreateEmptyMaterial);
            entryContextMenu.AddItem("Create/Physics material", CreateEmptyPhysicsMaterial);
            entryContextMenu.AddItem("Create/Shader", CreateEmptyShader);
            entryContextMenu.AddItem("Create/C# script", CreateEmptyCSScript);
            entryContextMenu.AddItem("Create/Sprite texture", CreateEmptySpriteTexture);
            entryContextMenu.AddItem("Create/GUI skin", CreateEmptyGUISkin);
            entryContextMenu.AddItem("Create/String table", CreateEmptyStringTable);
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Rename", win.RenameSelection, new ShortcutKey(ButtonModifier.None, ButtonCode.F2));
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Cut", win.CutSelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.X));
            entryContextMenu.AddItem("Copy", win.CopySelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.C));
            entryContextMenu.AddItem("Duplicate", win.DuplicateSelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.D));
            entryContextMenu.AddItem("Paste", win.PasteToSelection, new ShortcutKey(ButtonModifier.Ctrl, ButtonCode.V));
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Delete", win.DeleteSelection, new ShortcutKey(ButtonModifier.None, ButtonCode.Delete));
            entryContextMenu.AddSeparator("");
            entryContextMenu.AddItem("Open externally", OpenExternally);
            entryContextMenu.AddItem("Explore location", ExploreLocation);

            entryContextMenu.SetLocalizedName("Rename", new LocEdString("Rename"));
            entryContextMenu.SetLocalizedName("Cut", new LocEdString("Cut"));
            entryContextMenu.SetLocalizedName("Copy", new LocEdString("Copy"));
            entryContextMenu.SetLocalizedName("Duplicate", new LocEdString("Duplicate"));
            entryContextMenu.SetLocalizedName("Paste", new LocEdString("Paste"));
            entryContextMenu.SetLocalizedName("Delete", new LocEdString("Delete"));

            return entryContextMenu;
        }
 /// <summary>
 /// Constructs a new GUI library content object.
 /// </summary>
 /// <param name="window">Parent window the content area is part of.</param>
 /// <param name="parent">Scroll area the content area is part of.</param>
 public LibraryGUIContent(LibraryWindow window, GUIScrollArea parent)
 {
     this.window = window;
     this.parent = parent;
 }
Exemple #3
0
        /// <summary>
        /// Initializes the drop down window by creating the necessary GUI. Must be called after construction and before
        /// use.
        /// </summary>
        /// <param name="parent">Libary window that this drop down window is a part of.</param>
        internal void Initialize(LibraryWindow parent)
        {
            this.parent = parent;

            GUIToggleGroup group = new GUIToggleGroup();

            GUIToggle list16 = new GUIToggle(new LocEdString("16"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
            GUIToggle grid32 = new GUIToggle(new LocEdString("32"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
            GUIToggle grid48 = new GUIToggle(new LocEdString("48"), group, EditorStyles.Button, GUIOption.FixedWidth(30));
            GUIToggle grid64 = new GUIToggle(new LocEdString("64"), group, EditorStyles.Button, GUIOption.FixedWidth(30));

            ProjectViewType activeType = parent.ViewType;
            switch (activeType)
            {
                case ProjectViewType.List16:
                    list16.Value = true;
                    break;
                case ProjectViewType.Grid32:
                    grid32.Value = true;
                    break;
                case ProjectViewType.Grid48:
                    grid48.Value = true;
                    break;
                case ProjectViewType.Grid64:
                    grid64.Value = true;
                    break;
            }

            list16.OnToggled += (active) =>
            {
                if (active)
                    ChangeViewType(ProjectViewType.List16);
            };

            grid32.OnToggled += (active) =>
            {
                if (active)
                    ChangeViewType(ProjectViewType.Grid32);
            };

            grid48.OnToggled += (active) =>
            {
                if (active)
                    ChangeViewType(ProjectViewType.Grid48);
            };

            grid64.OnToggled += (active) =>
            {
                if (active)
                    ChangeViewType(ProjectViewType.Grid64);
            };

            GUILayoutY vertLayout = GUI.AddLayoutY();

            vertLayout.AddFlexibleSpace();
            GUILayoutX contentLayout = vertLayout.AddLayoutX();
            contentLayout.AddFlexibleSpace();
            contentLayout.AddElement(list16);
            contentLayout.AddElement(grid32);
            contentLayout.AddElement(grid48);
            contentLayout.AddElement(grid64);
            contentLayout.AddFlexibleSpace();
            vertLayout.AddFlexibleSpace();
        }