Пример #1
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);

            Upgrade();

            showSettings = CustomGUILayout.ToggleHeader(showSettings, "Global menu settings");
            if (showSettings)
            {
                drawInEditor = CustomGUILayout.Toggle("Preview in Game window?", drawInEditor, "", "If True, Adventure Creator-sourced menus will be displayed in the Game window in Edit mode so long as a GameEngine prefab is present in the scene.");
                if (drawInEditor)
                {
                    drawOutlines = CustomGUILayout.Toggle("Draw outlines?", drawOutlines, "", "If True, yellow outlines will be drawn around Adventure Creator-sourced menus and elements when previewing");
                    if (drawOutlines && Application.platform == RuntimePlatform.WindowsEditor)
                    {
                        doWindowsPreviewFix = CustomGUILayout.Toggle("Apply outline offset fix?", doWindowsPreviewFix, "", "In some versions of Windows, preview outlines can appear offset. Checking this box should fix this.");
                    }
                }
                scaleTextEffects = CustomGUILayout.Toggle("Scale text effects?", scaleTextEffects, "AC.KickStarter.menuManager.scaleTextEffects", "If True, then the size of text effects (shadows, outlines) will be based on the size of the text, rather than fixed");
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(new GUIContent("Pause background texture:", "A texture to apply full-screen when a 'Pause' Menu is enabled"), GUILayout.Width(255f));
                pauseTexture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (pauseTexture, false, GUILayout.Width(70f), GUILayout.Height(30f), "AC.Kickstarter.menuManager.pauseTexture");
                EditorGUILayout.EndHorizontal();
                globalDepth = CustomGUILayout.IntField("GUI depth:", globalDepth, "AC.KickStarter.menuManager.globalDepth", "The depth at which to draw OnGUI-based (Adventure Creator) menus");
                eventSystem = (UnityEngine.EventSystems.EventSystem)CustomGUILayout.ObjectField <UnityEngine.EventSystems.EventSystem> ("Event system prefab:", eventSystem, false, "AC.KickStarter.menuManager.eventSystem", "The EventSystem to instantiate when Unity UI-based Menus are used. If none is set, a default one will be used");

                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod != InputMethod.TouchScreen)
                {
                    EditorGUILayout.Space();
                    keyboardControlWhenPaused        = CustomGUILayout.ToggleLeft("Directly-navigate Menus when paused?", keyboardControlWhenPaused, "AC.KickStarter.menuManager.keyboardControlWhenPaused", "If True, then Menus will be navigated directly, not with the cursor, when the game is paused");
                    keyboardControlWhenDialogOptions = CustomGUILayout.ToggleLeft("Directly-navigate Menus during Conversations?", keyboardControlWhenDialogOptions, "AC.KickStarter.menuManager.keyboardControlWhenDialogOptions", "If True, then Menus will be navigated directly, not with the cursor, when Conversation dialogue options are shown");

                    if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod == InputMethod.KeyboardOrController)
                    {
                        autoSelectValidRaycasts = CustomGUILayout.ToggleLeft("Auto-select valid UI raycasts?", autoSelectValidRaycasts, "AC.KickStarter.menuManager.autoSelectValidRaycasts", "If True, then the simulated cursor will auto-select valid Unity UI elements");
                    }
                }


                if (drawInEditor && KickStarter.menuPreview == null)
                {
                    EditorGUILayout.HelpBox("A GameEngine is required to display menus while editing - please set up the scene using the Scene Manager.", MessageType.Warning);
                }
                else if (drawInEditor && KickStarter.mainCamera == null)
                {
                    EditorGUILayout.HelpBox("An AC MainCamera is required to display menus while editing - please set up the scene using the Scene Manager.", MessageType.Warning);
                }
                else if (Application.isPlaying)
                {
                    EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            CreateMenusGUI();

            if (selectedMenu != null && menus.Contains(selectedMenu))
            {
                EditorGUILayout.Space();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);

                showMenuProperties = CustomGUILayout.ToggleHeader(showMenuProperties, "Menu " + selectedMenu.id + ": '" + menuTitle + "' properties");
                if (showMenuProperties)
                {
                    selectedMenu.ShowGUI();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                showElementList = CustomGUILayout.ToggleHeader(showElementList, "Menu " + selectedMenu.id + ": '" + menuTitle + "' elements");
                if (showElementList)
                {
                    CreateElementsGUI(selectedMenu);
                }
                EditorGUILayout.EndVertical();

                if (selectedMenuElement != null && selectedMenu.elements.Contains(selectedMenuElement))
                {
                    EditorGUILayout.Space();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType().ToString().Contains(_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                    showElementProperties = CustomGUILayout.ToggleHeader(showElementProperties, elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties");
                    if (showElementProperties)
                    {
                        oldVisibility = selectedMenuElement.IsVisible;
                        selectedMenuElement.ShowGUIStart(selectedMenu);
                    }
                    else
                    {
                        EditorGUILayout.EndVertical();
                    }
                    if (selectedMenuElement.IsVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(this);
            }
        }
Пример #2
0
        /// <summary>
        /// Create the dash and present it
        /// </summary>
        /// <returns></returns>
        private IEnumerator _presentYURGUI(bool UsingYURinteractionSystem)
        {
            Vector3 YUR_Position;
            Vector3 YUR_Direction;

            /// Display the ScreenCoordinator Object and set the background color of the Dash
            YURScreenCoordinator.ScreenCoordinator.gameObject.SetActive(true);
            YURScreenCoordinator.ScreenCoordinator.Background.GetComponent <UnityEngine.UI.Image>().color = YUR.Yur.BackgroundColor;

            GameObject Camera = YUR.Yur.Camera;

            /// If a previously specified gameobject is to be used for the location of dash.
            if (YUR.Yur.GUITransform != null)
            {
                Debug.Log("Displaying on GUITransform", YUR.Yur.GUITransform);
                YUR.Yur.YUR_Dash.transform.localScale = new Vector3(YUR.Yur.YUR_Dash.transform.localScale.x * (YUR.Yur.YURGUIScale + 1), YUR.Yur.YUR_Dash.transform.localScale.y * (YUR.Yur.YURGUIScale + 1), YUR.Yur.YUR_Dash.transform.localScale.z * (YUR.Yur.YURGUIScale + 1));
                YUR.Yur.YUR_Dash.transform.SetParent(YUR.Yur.GUITransform.transform);
                YUR.Yur.YUR_Dash.transform.localPosition    = YUR.Yur.YURGUIPositionOffset;
                YUR.Yur.YUR_Dash.transform.localEulerAngles = YUR.Yur.YURGUIRotationOffset;
            }
            else /// Else, position the dash relative to the camera position;
            {
                YUR_Log.Log("Moving Dash in front of player");
                YUR_Position    = Camera.transform.position;
                YUR_Direction   = Camera.transform.forward;
                YUR_Direction.y = 0;
                YUR_Log.Log("Dash Positioning: \nPosition: " + YUR_Position + "\nDirection: " + YUR_Direction + "\nYUR Dash Position: " + YUR.Yur.YUR_Dash.transform.position, YUR.Yur.YUR_Dash);

                YUR.Yur.YUR_Dash.transform.SetPositionAndRotation(
                    new Vector3(YUR_Position.x + (YUR_Direction.x * 2), YUR_Position.y, YUR_Position.z + (YUR_Direction.z * 2)),
                    Quaternion.LookRotation(YUR_Direction));

                YUR_Log.Log("Dash Positioning: \nPosition: " + YUR_Position + "\nDirection: " + YUR_Direction + "\nYUR Dash Position: " + YUR.Yur.YUR_Dash.transform.position, YUR.Yur.YUR_Dash);
            }

            /// Present the first screen to user
            YURScreenCoordinator.ScreenCoordinator.Hierarchy[0].gameObject.SetActive(true);
            bool leftHanded        = false;
            bool instantiatedUIKit = false;

            int children;

            /// Deteremine the number of children in which the Camera object has, differing counts are for different platforms
            if (Camera.transform.parent)
            {
                children = Camera.transform.parent.childCount;
            }
            else
            {
                children = Camera.transform.childCount;
            }

            if (!UsingYURinteractionSystem) // If Not using YUR Interaction System, stop here
            {
                yield break;
            }

            if (YUR.Yur.YURAssetBundle == null)
            {
                string URI = "file:///" + Application.dataPath + "/AssetBundles/" + YUR.Yur.assetBundleName;
                UnityEngine.Networking.UnityWebRequest request = UnityEngine.Networking.UnityWebRequestAssetBundle.GetAssetBundle(URI, 0);
                yield return(request.SendWebRequest());

                if (request.error != null)
                {
                    yield break;
                }
                else
                {
                    YUR_Log.Log("Local asset bundle found!");
                    yield return(YUR.Yur.YURAssetBundle = DownloadHandlerAssetBundle.GetContent(request));
                }
            }

            ////_____________________________________________________________________________________/
            /// Take Control of the Event System, is returned when YUR Dash is closed.
            //_____________________________________________________________________________________/
            OriginalEventSystem = UnityEngine.EventSystems.EventSystem.current;


            if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.OCULUS)
            {
                GameObject temppp;
                yield return(temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("LaserInputModuleOculus"));

                YUR_Log.Log("Loaded the Laser Input Module for Oculus, instantiating");

                yield return(EventSystem = (Instantiate(temppp) as GameObject));// = EventSystem.gameObject.AddComponent<VRUiKits.Utils.OculusLaserInputModule>();

                EventSystem.name = "Event System";
                UnityEngine.EventSystems.EventSystem.current = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>();
                YUR.Yur.eventSystem = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>();

                yield return(LaserIM = EventSystem.GetComponent <VRUiKits.Utils.LaserInputModule>());

                YUR_Log.Log("Oculus Input Module Added");
            }
            else if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.VIVE_STEAM2)
            {
                var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("LaserInputModuleSteam2");

                yield return(EventSystem = (Instantiate(temppp) as GameObject));// = EventSystem.gameObject.AddComponent<VRUiKits.Utils.OculusLaserInputModule>();

                EventSystem.name = "Event System";
                UnityEngine.EventSystems.EventSystem.current = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>();
                YUR.Yur.eventSystem = EventSystem.GetComponent <UnityEngine.EventSystems.EventSystem>();
                yield return(LaserIM = EventSystem.GetComponent <VRUiKits.Utils.LaserInputModule>());

                YUR_Log.Log("Steam Input Module Added");
            }

            if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.OCULUS) /// If the platform is defined as being Oculus, use the Camera object to locate the Controllers
            {
                YUR_Log.Log("Locating Oculus Controllers...");
                for (int i = 0; i < YUR.Yur.Camera.transform.parent.childCount; i++)
                {
                    if (YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.name.Contains("RightHand"))
                    {
                        var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("OculusUIKitPointer");
                        UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform);
                        //UIPointerKit = (GameObject)Instantiate(Resources.Load("OculusUIKitPointer"), YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform);
                        instantiatedUIKit = true;
                        leftHanded        = false;
                        YUR_Log.Log("Found Oculus Controller Right");
                        break;
                    }
                    else if (YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.name.Contains("LeftHand"))
                    {
                        var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("OculusUIKitPointer");
                        UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform);
                        //UIPointerKit = (GameObject)Instantiate(Resources.Load("OculusUIKitPointer"), YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform);
                        instantiatedUIKit = true;
                        leftHanded        = true;
                        YUR_Log.Log("Found Oculus Controller Left");
                        break;
                    }
                }
            }
            else if (YUR.Yur.platform == VRUiKits.Utils.VRPlatform.VIVE_STEAM2)  /// If the platform is Steam VR 2, find the preferred controller.
            {
                YUR_Log.Log("Locating Steam VR 2 Controllers...");
                for (int i = 0; i < children; i++)
                {
                    Debug.Log("Found Controller: " + Camera.transform.parent.GetChild(i).gameObject.name);
                    if (Camera.transform.parent.GetChild(i).gameObject.name.Contains("right"))
                    {
                        var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("Steam2UIKitPointer");
                        UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform);
                        // UIPointerKit = (GameObject)Instantiate(Resources.Load("Steam2UIKitPointer"), Camera.transform.parent.GetChild(i).gameObject.transform);
                        instantiatedUIKit = true;
                        leftHanded        = false;
                        YUR_Log.Log("Found Steam Controller right");
                        break;
                    }
                    if (Camera.transform.parent.GetChild(i).gameObject.name.Contains("left"))
                    {
                        var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("Steam2UIKitPointer");
                        UIPointerKit = Instantiate(temppp, YUR.Yur.Camera.transform.parent.GetChild(i).gameObject.transform);
                        // UIPointerKit = (GameObject)Instantiate(Resources.Load("Steam2UIKitPointer"), Camera.transform.parent.GetChild(i).gameObject.transform);
                        instantiatedUIKit = true;
                        leftHanded        = true;
                        YUR_Log.Log("Found Steam Controller Left");
                        break;
                    }
                }
            }

            LaserIM.platform = YUR.Yur.platform;
            LaserIM.pointer  = (leftHanded ? VRUiKits.Utils.Pointer.LeftHand : VRUiKits.Utils.Pointer.RightHand);

            if (!instantiatedUIKit) // If UIPointerKit not previously instantiated
            {
                var temppp = YUR.Yur.YURAssetBundle.LoadAsset <GameObject>("UIKitPointer");
                UIPointerKit = Instantiate(temppp);
                //UIPointerKit = (GameObject)Instantiate(Resources.Load("UIKitPointer"));
            }


            //YUR_Log.Log("Checking for event system...");
            //if (YUR.Yur.eventSystem == null) // If there is no event system, create a new gameobject and attach an Event System Component
            //{
            //    YUR_Log.Log("None found, create event system...");
            //    //EventSystem = new GameObject("EventSystem");

            //    //yield return YUR.Yur.eventSystem = EventSystem.AddComponent<UnityEngine.EventSystems.EventSystem>();
            //}
            //else
            //{
            //    YUR_Log.Log("Found event System");
            //    EventSystem = YUR.Yur.eventSystem.gameObject;
            //}

            //if(EventSystem.gameObject.GetComponent<VRUiKits.Utils.VREventSystemHelper>())
            //{
            //    YUR_Log.Log("VR Event System Helper already added to game object");
            //}
            //else
            //{
            //    YUR_Log.Log("Adding Event System Helper and Input Module");
            //    EventSystem.gameObject.AddComponent<VRUiKits.Utils.VREventSystemHelper>();
            //}
        }
Пример #3
0
        /**
         * Shows the GUI.
         */
        public void ShowGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);

            showSettings = CustomGUILayout.ToggleHeader(showSettings, "Global menu settings");
            if (showSettings)
            {
                drawInEditor = EditorGUILayout.Toggle("Preview in Game window?", drawInEditor);
                if (drawInEditor)
                {
                    drawOutlines = EditorGUILayout.Toggle("Draw outlines?", drawOutlines);
                    if (drawOutlines && Application.platform == RuntimePlatform.WindowsEditor)
                    {
                        doWindowsPreviewFix = EditorGUILayout.Toggle("Apply outline offset fix?", doWindowsPreviewFix);
                    }
                }
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Pause background texture:", GUILayout.Width(255f));
                pauseTexture = (Texture2D)CustomGUILayout.ObjectField <Texture2D> (pauseTexture, false, GUILayout.Width(70f), GUILayout.Height(30f), "AC.Kickstarter.menuManager.pauseTexture");
                EditorGUILayout.EndHorizontal();
                scaleTextEffects = CustomGUILayout.Toggle("Scale text effects?", scaleTextEffects, "AC.KickStarter.menuManager.scaleTextEffects");
                globalDepth      = CustomGUILayout.IntField("GUI depth:", globalDepth, "AC.KickStarter.menuManager.globalDepth");
                eventSystem      = (UnityEngine.EventSystems.EventSystem)CustomGUILayout.ObjectField <UnityEngine.EventSystems.EventSystem> ("Event system prefab:", eventSystem, false, "AC.KickStarter.menuManager.eventSystem");

                if (AdvGame.GetReferences().settingsManager != null && AdvGame.GetReferences().settingsManager.inputMethod != InputMethod.TouchScreen)
                {
                    EditorGUILayout.Space();
                    keyboardControlWhenPaused        = CustomGUILayout.ToggleLeft("Directly-navigate Menus when paused?", keyboardControlWhenPaused, "AC.KickStarter.menuManager.keyboardControlWhenPaused");
                    keyboardControlWhenDialogOptions = CustomGUILayout.ToggleLeft("Directly-navigate Menus during Conversations?", keyboardControlWhenDialogOptions, "AC.KickStarter.menuManager.keyboardControlWhenDialogOptions");
                    if (eventSystem == null)
                    {
                        disableMouseIfKeyboardControlling = CustomGUILayout.ToggleLeft("Disable mouse when directly-controlling Unity UI Menus?", disableMouseIfKeyboardControlling, "AC.KickStarter.menuManager.disableMouseIfKeyboardControlling");
                    }
                }

                if (AdvGame.GetReferences().settingsManager == null || AdvGame.GetReferences().settingsManager.inputMethod != InputMethod.KeyboardOrController)
                {
                    if (keyboardControlWhenPaused ||
                        keyboardControlWhenDialogOptions ||
                        (eventSystem == null && disableMouseIfKeyboardControlling))
                    {
                        EditorGUILayout.HelpBox("When the 'Input method' is not 'Keyboard Or Controller', direct navigation of Menus is only available for Unity UI-based Menus.", MessageType.Info);
                    }
                }

                if (drawInEditor && KickStarter.menuPreview == null)
                {
                    EditorGUILayout.HelpBox("A GameEngine prefab is required to display menus while editing - please click Organise Room Objects within the Scene Manager.", MessageType.Warning);
                }
                else if (Application.isPlaying)
                {
                    EditorGUILayout.HelpBox("Changes made to the menus will not be registed by the game until the game is restarted.", MessageType.Info);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            CreateMenusGUI();

            if (selectedMenu != null)
            {
                EditorGUILayout.Space();

                string menuTitle = selectedMenu.title;
                if (menuTitle == "")
                {
                    menuTitle = "(Untitled)";
                }

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);

                showMenuProperties = CustomGUILayout.ToggleHeader(showMenuProperties, "Menu " + selectedMenu.id + ": '" + menuTitle + "' properties");
                if (showMenuProperties)
                {
                    selectedMenu.ShowGUI();
                }
                EditorGUILayout.EndVertical();

                EditorGUILayout.Space();

                EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                showElementList = CustomGUILayout.ToggleHeader(showElementList, "Menu " + selectedMenu.id + ": '" + menuTitle + "' elements");
                if (showElementList)
                {
                    CreateElementsGUI(selectedMenu);
                }
                EditorGUILayout.EndVertical();

                if (selectedMenuElement != null)
                {
                    EditorGUILayout.Space();

                    string elementName = selectedMenuElement.title;
                    if (elementName == "")
                    {
                        elementName = "(Untitled)";
                    }

                    string elementType = "";
                    foreach (string _elementType in elementTypes)
                    {
                        if (selectedMenuElement.GetType().ToString().Contains(_elementType))
                        {
                            elementType = _elementType;
                            break;
                        }
                    }

                    EditorGUILayout.BeginVertical(CustomStyles.thinBox);
                    showElementProperties = CustomGUILayout.ToggleHeader(showElementProperties, elementType + " " + selectedMenuElement.ID + ": '" + elementName + "' properties");
                    if (showElementProperties)
                    {
                        oldVisibility = selectedMenuElement.isVisible;
                        selectedMenuElement.ShowGUIStart(selectedMenu);
                    }
                    else
                    {
                        EditorGUILayout.EndVertical();
                    }
                    if (selectedMenuElement.isVisible != oldVisibility)
                    {
                        if (!Application.isPlaying)
                        {
                            selectedMenu.Recalculate();
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (!Application.isPlaying)
                {
                    SaveAllMenus();
                }
                EditorUtility.SetDirty(this);
            }
        }
Пример #4
0
 /// <summary>
 /// Read the data using the reader.
 /// </summary>
 /// <param name="reader">Reader.</param>
 public override object Read(ISaveGameReader reader)
 {
     UnityEngine.EventSystems.EventSystem eventSystem = SaveGameType.CreateComponent <UnityEngine.EventSystems.EventSystem> ();
     ReadInto(eventSystem, reader);
     return(eventSystem);
 }
Пример #5
0
 void Start()
 {
     _eventSystem = _UI_Controller._eventSystem;
 }
Пример #6
0
 public OVRRayPointerEventData(UnityEngine.EventSystems.EventSystem eventSystem)
     : base(eventSystem)
 {
 }