Example #1
0
        //Controller Setup
        /// <summary>
        /// Sets the current controller type
        /// </summary>
        /// <param name="type"></param>
        public static void SetCurrentControllerType(GaiaConstants.EnvironmentControllerType type)
        {
            LocationSystem system = FindObjectOfType <LocationSystem>();

            if (system != null)
            {
                if (system.m_locationProfile != null)
                {
                    system.m_locationProfile.m_currentControllerType = type;
                }
            }
        }
Example #2
0
        private void GlobalSettings(bool helpEnabled)
        {
            if (GaiaGlobal.Instance.SceneProfile.m_lightingProfiles.Count > 0)
            {
                if (m_profile.m_selectedLightingProfileValuesIndex != -99)
                {
                    profile = GaiaGlobal.Instance.SceneProfile.m_lightingProfiles[m_profile.m_selectedLightingProfileValuesIndex];
                }
            }

            if (m_gaiaSettings.m_currentRenderer == GaiaConstants.EnvironmentRenderer.BuiltIn)
            {
                bool postfx = m_profile.m_setupPostFX;
                m_profile.m_setupPostFX = m_editorUtils.Toggle("SetupPostFX", m_profile.m_setupPostFX, helpEnabled);
                if (postfx != m_profile.m_setupPostFX)
                {
                    if (m_profile.m_setupPostFX)
                    {
                        if (profile != null)
                        {
                            GaiaLighting.SetupPostProcessing(profile, m_profile, GaiaUtils.GetActivePipeline(), true);
                        }
                    }
                    else
                    {
                        GaiaLighting.RemoveAllPostProcessV2CameraLayer();
                    }
                }
            }
            m_profile.m_spawnPlayerAtCurrentLocation = m_editorUtils.Toggle("SpawnPlayerAtCurrentLocation", m_profile.m_spawnPlayerAtCurrentLocation, helpEnabled);

            GaiaConstants.EnvironmentControllerType controller = m_profile.m_controllerType;
            controller = (GaiaConstants.EnvironmentControllerType)m_editorUtils.EnumPopup("ControllerType", controller, helpEnabled);
            if (controller != m_profile.m_controllerType)
            {
                m_gaiaSettings.m_currentController = controller;
                switch (controller)
                {
                case GaiaConstants.EnvironmentControllerType.FirstPerson:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerFirstPersonName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.FlyingCamera:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerFlyCamName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.ThirdPerson:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.playerThirdPersonName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.Car:
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, GaiaConstants.m_carPlayerPrefabName, m_profile.m_spawnPlayerAtCurrentLocation, null, null, true);
                    break;

                case GaiaConstants.EnvironmentControllerType.XRController:
#if GAIA_XR
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, "XRController", m_profile.m_spawnPlayerAtCurrentLocation);
#else
                    EditorUtility.DisplayDialog("XR Support not enabled", "The XR Controller is a default player for Virtual / Augmented Reality projects. Please open the Setup Panel in the Gaia Manager Standard Tab to enable XR Support in order to use the XR Player Controller. Please also make sure you have the Unity XR Interaction Toolkit package installed before doing so.", "OK");
                    controller = GaiaConstants.EnvironmentControllerType.FlyingCamera;
                    m_gaiaSettings.m_currentController = GaiaConstants.EnvironmentControllerType.FlyingCamera;
#endif
                    break;
                }

                SetPostProcessing(profile);
#if GAIA_PRO_PRESENT
                if (GaiaUtils.HasDynamicLoadedTerrains())
                {
                    TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren <TerrainLoader>();
                    if (tl != null)
                    {
                        m_profile.UpdateTerrainLoaderFromProfile(ref tl);
                    }
                }
#endif
                m_profile.m_controllerType = controller;
            }

            if (controller == GaiaConstants.EnvironmentControllerType.Custom)
            {
                m_profile.m_customPlayer = (GameObject)m_editorUtils.ObjectField("MainPlayer", m_profile.m_customPlayer, typeof(GameObject), true, helpEnabled);
                m_profile.m_customCamera = (Camera)m_editorUtils.ObjectField("MainCamera", m_profile.m_customCamera, typeof(Camera), true, helpEnabled);

                if (m_editorUtils.Button("ApplySetup"))
                {
                    GaiaSceneManagement.CreatePlayer(m_gaiaSettings, "Custom", m_profile.m_spawnPlayerAtCurrentLocation, m_profile.m_customPlayer, m_profile.m_customCamera, true);
                    SetPostProcessing(profile);
#if GAIA_PRO_PRESENT
                    if (GaiaUtils.HasDynamicLoadedTerrains())
                    {
                        TerrainLoader tl = ((GaiaScenePlayer)target).GetComponentInChildren <TerrainLoader>();
                        if (tl != null)
                        {
                            m_profile.UpdateTerrainLoaderFromProfile(ref tl);
                        }
                    }
#endif
                }
            }

            EditorGUILayout.BeginHorizontal();

            if (m_editorUtils.Button("MoveCameraToPlayer"))
            {
                GaiaSceneManagement.MoveCameraToPlayer(m_gaiaSettings);
            }

            if (m_editorUtils.Button("MovePlayerToCamera"))
            {
                GaiaSceneManagement.MovePlayerToCamera(m_gaiaSettings);
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            m_editorUtils.Panel("AutoDepthOfFieldSettings", AutoDepthOfField);
            m_editorUtils.Panel("LocationManagerSettings", LocationManagerSettings);
            m_editorUtils.Panel("PlayerCameraCullingSettings", CameraCullingSettings);
            if (GaiaUtils.HasDynamicLoadedTerrains())
            {
                m_editorUtils.Panel("TerrainLoadingSettings", TerrainLoadingSettings);
            }
        }