Beispiel #1
0
        private static Canvas GetCanvas()
        {
            StageHandle handle = StageUtility.GetCurrentStageHandle();

            if (!handle.FindComponentOfType <Canvas>())
            {
                EditorApplication.ExecuteMenuItem("GameObject/UI/Canvas");
            }

            Canvas c = handle.FindComponentOfType <Canvas>();

            return(c);
        }
Beispiel #2
0
        private static void CreateEventSystem(bool select, GameObject parent)
        {
            StageHandle stage = parent == null?StageUtility.GetCurrentStageHandle() : StageUtility.GetStageHandle(parent);

            var esys = stage.FindComponentOfType <EventSystem>();

            if (esys == null)
            {
                var eventSystem = ObjectFactory.CreateGameObject("EventSystem");
                if (parent == null)
                {
                    StageUtility.PlaceGameObjectInCurrentStage(eventSystem);
                }
                else
                {
                    SetParentAndAlign(eventSystem, parent);
                }
                esys = ObjectFactory.AddComponent <EventSystem>(eventSystem);
                ObjectFactory.AddComponent <StandaloneInputModule>(eventSystem);

                Undo.RegisterCreatedObjectUndo(eventSystem, "Create " + eventSystem.name);
            }

            if (select && esys != null)
            {
                Selection.activeGameObject = esys.gameObject;
            }
        }
Beispiel #3
0
    private static void CreateEventSystem()
    {
        StageHandle stage = StageUtility.GetCurrentStageHandle();
        var         esys  = stage.FindComponentOfType <EventSystem>();

        if (esys == null)
        {
            var eventSystem = ObjectFactory.CreateGameObject("EventSystem");
            StageUtility.PlaceGameObjectInCurrentStage(eventSystem);
            esys = ObjectFactory.AddComponent <EventSystem>(eventSystem);
            ObjectFactory.AddComponent <StandaloneInputModule>(eventSystem);

            Undo.RegisterCreatedObjectUndo(eventSystem, "Create " + eventSystem.name);
        }
    }