private static Canvas GetCanvas() { StageHandle handle = StageUtility.GetCurrentStageHandle(); if (!handle.FindComponentOfType <Canvas>()) { EditorApplication.ExecuteMenuItem("GameObject/UI/Canvas"); } Canvas c = handle.FindComponentOfType <Canvas>(); return(c); }
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; } }
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); } }