示例#1
0
        public static void CreateSequenceAsset()
        {
            // DirectoryCopy.CopyPluginsAndGizmosToAssetsFolder();
            Sequence asset = CustomAssetUtility.CreateAsset <Sequence>();

            Selection.activeObject = asset;
        }
示例#2
0
        void Finish()
        {
            TrueSkyCamera trueSkyCamera;

            if (sequence == null)
            {
                // Build asset path and name (it has to be relative)
                string relativePath = UnityEngine.SceneManagement.SceneManager.GetActiveScene().path;

                string sequenceFilename = relativePath.Replace(".unity", "_sq.asset");
                sequence = CustomAssetUtility.CreateAsset <Sequence>(sequenceFilename);
            }
            if (trueSky == null)
            {
                GameObject g = new GameObject("trueSky");
                trueSky = g.AddComponent <trueSKY>();
            }
            if (createAMainCamera)                  // if user has requested a main camera to be created (as none already)
            {
                GameObject MainCam = new GameObject("Main Camera");
                MainCam.gameObject.AddComponent <Camera>();
                MainCam.tag = "MainCamera";
                mainCamera  = MainCam.GetComponent <Camera>();
            }
            if (multipleCameras)                                    // if user has requested the script o be assigned to cameras
            {
                Camera[] cams = new Camera[Camera.allCamerasCount]; // find all cameras
                if (Camera.allCamerasCount >= 1)
                {
                    Array.Copy(Camera.allCameras, cams, Camera.allCamerasCount);
                }

                for (int i = 0; i < cams.Length; i++)
                {
                    trueSkyCamera = cams[i].gameObject.GetComponent <TrueSkyCamera>();
                    if (trueSkyCamera == null)
                    {
                        cams[i].gameObject.AddComponent <TrueSkyCamera>();
                    }
                }
            }
            if (mainCamera == null)                                 // if mainCamera still = null, inform user script wasn't assigned + how to assign it
            {
                if (Camera.allCamerasCount < 1)
                {
                    UnityEngine.Debug.LogWarning("Can't find any cameras for trueSky Camera script. Please add a camera manually and repeat the wizard to assign the script to the camera of your choice/all cameras. Alternatively, check the option to automatically create a main camera with the script assigned.");
                }
                else if (!multipleCameras)
                {
                    UnityEngine.Debug.LogWarning("Can't find a main camera for trueSKy Camera script, but other cameras found. Repeat the wizard and assign the script to the camera of your choice/all cameras");
                }
            }
            else
            {
#if USING_HDRP
                simul.TrueSkyHDRPCustomPass trueSKYPreRefraction           = new simul.TrueSkyHDRPCustomPass();
                simul.TrueSkyHDRPCustomPass trueSKYPrePostProcess          = new simul.TrueSkyHDRPCustomPass();
                CustomPassVolume            trueSKYPassBeforePreRefraction = trueSky.gameObject.GetComponent <CustomPassVolume>();
                if (trueSKYPassBeforePreRefraction == null)
                {
                    trueSKYPreRefraction.name      = "trueSKY - Before Pre Refraction(Main Render)";
                    trueSKYPassBeforePreRefraction = trueSky.gameObject.AddComponent <CustomPassVolume>();
                    trueSKYPassBeforePreRefraction.injectionPoint = CustomPassInjectionPoint.BeforePreRefraction;
                    trueSKYPassBeforePreRefraction.customPasses.Add(trueSKYPreRefraction);

                    CustomPassVolume trueSKYPassBeforePostProcess;
                    trueSKYPrePostProcess.name   = "trueSKY - Before Post Process(Translucent Effects)";
                    trueSKYPassBeforePostProcess = trueSky.gameObject.AddComponent <CustomPassVolume>();
                    trueSKYPassBeforePostProcess.injectionPoint = CustomPassInjectionPoint.BeforePostProcess;
                    trueSKYPassBeforePostProcess.customPasses.Add(trueSKYPrePostProcess);
                }
                if (UnityEngine.Rendering.GraphicsSettings.allConfiguredRenderPipelines.Length > 0)
                {
                    trueSky.HDRP_RenderPipelineAsset = UnityEngine.Rendering.GraphicsSettings.allConfiguredRenderPipelines[0];
                }
#else
                trueSkyCamera = mainCamera.gameObject.GetComponent <TrueSkyCamera>();
                if (trueSkyCamera == null)
                {
                    mainCamera.gameObject.AddComponent <TrueSkyCamera>();
                }
#endif
            }
            if (createCubemapProbe)
            {                       // must be after trueSKY obj assigned, in case assigning probe to this instead of mainCam
                UnityEngine.Object[] objects = FindObjectsOfType(typeof(TrueSkyCubemapProbe));

                if (trueSky.gameObject.GetComponent <TrueSkyCubemapProbe>() != null)
                {
                    DestroyImmediate(trueSky.gameObject.GetComponent <TrueSkyCubemapProbe>());
                }

                trueSky.gameObject.AddComponent <TrueSkyCubemapProbe>();

                Material trueSKYSkyboxMat = Resources.Load("trueSKYSkybox", typeof(Material)) as Material;
                RenderSettings.skybox = trueSKYSkyboxMat;
            }
            // If there is not light on the scene, add one:
            if (lightGameObject == null)
            {
                lightGameObject = new GameObject("TrueSkyDirectionalLight");
                Light dirLight = lightGameObject.AddComponent <Light>();
                dirLight.type  = LightType.Directional;
                lightComponent = lightGameObject.AddComponent <TrueSkyDirectionalLight>();
            }
            // If there is a light, but without the component, add it:
            if (lightComponent == null)
            {
                lightComponent = lightGameObject.AddComponent <TrueSkyDirectionalLight>();
            }
            RenderSettings.sun = lightGameObject.GetComponent <Light>();

#if USING_HDRP
            lightComponent.Units = TrueSkyDirectionalLight.LightUnits.Photometric;
#else
            lightComponent.Units = TrueSkyDirectionalLight.LightUnits.Radiometric;
#endif
            if (removeFog)
            {
                RenderSettings.fog = false;
            }
            if (removeSkybox && mainCamera != null)
            {
                if (mainCamera.clearFlags != CameraClearFlags.SolidColor)
                {
                    mainCamera.clearFlags      = CameraClearFlags.SolidColor;
                    mainCamera.backgroundColor = Color.black;
                }
            }
            // Set the Near and Far clipping planes on the main camera.
            mainCamera.nearClipPlane = 0.1f;
            mainCamera.farClipPlane  = 300000.0f;

            // Now the sequence must be assigned to the trueSKY object.
            trueSky.sequence    = sequence;
            trueSky.TrueSKYTime = 12.0F;
        }