Example #1
0
        private static void AddObject(MenuCommand menuCommand)
        {
            // Create GUI view object
            var main = new GameObject("Empty View");

            EditorGuiUtils.AttachStretchedRect(main);
            main.AddComponent <EmptyView>();
            GameObjectUtility.SetParentAndAlign(main, menuCommand.context as GameObject);

            // Register the creation in the Unity undo system
            Undo.RegisterCreatedObjectUndo(main, "Created an empty view");
            Selection.activeObject = main;
        }
Example #2
0
        private static void AddObject(MenuCommand menuCommand)
        {
            // Create GUI popup object
            var main = new GameObject("Empty Popup");

            EditorGuiUtils.AttachSizedRect(main, 100, 100);
            main.AddComponent <EmptyPopup>();
            GameObjectUtility.SetParentAndAlign(main, menuCommand.context as GameObject);

            var bg = new GameObject("Background Image");

            GameObjectUtility.SetParentAndAlign(bg, main);
            EditorGuiUtils.AttachStretchedRect(bg);
            bg.AddComponent <Image>();

            // Register the creation in the Unity undo system
            Undo.RegisterCreatedObjectUndo(main, "Created an empty view");
            Selection.activeObject = main;
        }
Example #3
0
        private static void AddObject(MenuCommand menuCommand)
        {
            // Create GUI Canvas object
            var main = new GameObject("GUI Canvas");

            var canvas = main.AddComponent <Canvas>();

            canvas.renderMode = RenderMode.ScreenSpaceOverlay;

            main.AddComponent <CanvasScaler>();
            main.AddComponent <GraphicRaycaster>();
            GameObjectUtility.SetParentAndAlign(main, menuCommand.context as GameObject);

            // Create event system
            var eventSystem = new GameObject("Event System");

            eventSystem.AddComponent <EventSystem>();
            eventSystem.AddComponent <StandaloneInputModule>();
            GameObjectUtility.SetParentAndAlign(eventSystem, main);

            // Create view container
            var viewContainer = new GameObject("View Container");

            EditorGuiUtils.AttachStretchedRect(viewContainer);
            GameObjectUtility.SetParentAndAlign(viewContainer, main);

            // Create popup container
            var popupContainer = new GameObject("Popup Container");

            EditorGuiUtils.AttachStretchedRect(popupContainer);
            GameObjectUtility.SetParentAndAlign(popupContainer, main);

            // Register the creation in the Unity undo system
            Undo.RegisterCreatedObjectUndo(main, "Created a GUI Canvas");
            Selection.activeObject = main;
        }
Example #4
0
 public static bool BoolPopup(this EditorGUILayout inEditorGUILayout, bool inValue, GUIStyle inStyle, GUILayoutOption inOptions)
 {
     return(EditorGuiUtils.BoolPopup(inValue, inStyle, inOptions));
 }
Example #5
0
 // this doesn't work ...
 public static bool BoolPopup(this EditorGUILayout inEditorGUILayout, bool inValue)
 {
     return(EditorGuiUtils.BoolPopup(inValue, null, null));
 }