/// <summary>
        /// Generate a new Timeline asset with the given name in the 'Assets/Timeline' folder of the project
        /// </summary>
        public static TimelineAsset CreateTimelineAsset(string timelineAssetName)
        {
            if (!AssetDatabase.IsValidFolder("Assets/Timeline"))
            {
                AssetDatabase.CreateFolder("Assets", "Timeline");
            }
            var ta = ScriptableObjectUtility.CreateAssetType <TimelineAsset>("Assets/Timeline", timelineAssetName);

            return(ta);
        }
Exemple #2
0
        /// <summary>
        /// Manages the adding of components to generated scene objects. Supports generating sub-assets for those components that need them
        /// </summary>
        private static void AddNewComponent(GameObject go, COMPONENT_TYPE type)
        {
            switch (type)
            {
            case COMPONENT_TYPE.CAMERA:
            {
                var cam = go.GetOrAddComponent <Camera>();
                break;
            }

            case COMPONENT_TYPE.AUDIO_LISTENER:
            {
                go.GetOrAddComponent <AudioListener>();
                break;
            }

            case COMPONENT_TYPE.CINEMACHINE_BRAIN:
            {
                go.GetOrAddComponent <CinemachineBrain>();
                break;
            }

            case COMPONENT_TYPE.PLAYABLE_DIRECTOR:
            {
                var pd = go.GetOrAddComponent <PlayableDirector>();
                if (!AssetDatabase.IsValidFolder("Assets/Timeline"))
                {
                    AssetDatabase.CreateFolder("Assets", "Timeline");
                }
                var ta = ScriptableObjectUtility.CreateAssetType <TimelineAsset>("Assets/Timeline", "MasterTimeline.asset");
                pd.playableAsset = ta;
                break;
            }

            case COMPONENT_TYPE.POST_LAYER:
            {
                var post      = go.GetOrAddComponent <PostProcessLayer>();
                var postLayer = 1 << 8;               // post layer is 8 by default
                post.volumeLayer      = postLayer;    // LayerMask.NameToLayer("PostProcessing"); <= this doesn't work for some reason
                post.antialiasingMode = PostProcessLayer.Antialiasing.TemporalAntialiasing;
                break;
            }

            case COMPONENT_TYPE.POST_VOLUME:
            {
                var post = go.GetOrAddComponent <PostProcessVolume>();
                post.isGlobal = true;
                var targetName = go.name;
                var scene      = go.scene;

                // create a new profile
                var asset = ProfileFactory.CreatePostProcessProfile(scene, scene.name);

                // find & load the template
                // FIXME: should allow for user templates as well
                var templatePath = Settings.TEMPLATECONFIGPATH + "Default_Profiles/Default_PostProfile.asset";
                var template     = AssetDatabase.LoadAssetAtPath(templatePath, typeof(PostProcessProfile)) as PostProcessProfile;

                if (template != null)
                {
                    // add all of the settings to the template
                    foreach (var effect in template.settings)
                    {
                        asset.AddSettings(effect);
                    }
                }
                else
                {
                    Debug.Log("Could not find template post profile?");
                }

                post.profile          = asset;
                post.isGlobal         = true;
                post.gameObject.layer = LayerMask.NameToLayer("PostProcessing");
                break;
            }

            case COMPONENT_TYPE.SCENE_VOLUME:
            {
#if USING_HDRP
                var vol = go.GetOrAddComponent <Volume>();
                vol.isGlobal = true;
                var targetName = go.name;
                var scene      = go.scene;

                // FIXME: should load a volume profile from a template &
                // copy the components from one in the package as a base / starting point
                var asset = VolumeProfileFactory.CreateVolumeProfile(scene, targetName);

                vol.profile  = asset;
                vol.isGlobal = true;
#endif
                break;
            }

            case COMPONENT_TYPE.RENDER_SETTINGS:
            {
                var settings = go.GetOrAddComponent <RenderSettings>();
                // add our basic low / high detail levels to start
                var levels = new List <DetailLevel>()
                {
                    new DetailLevel()
                    {
                        name                   = "Low",
                        reflectionProbes       = false,
                        planarReflectionProbes = false,
                    },
                    new DetailLevel()
                    {
                        name                   = "High",
                        reflectionProbes       = true,
                        planarReflectionProbes = true,
                    }
                };

                settings.detailLevels.AddRange(levels);
                break;
            }

            default:
            {
                Debug.Log("unrecognized component type");
                break;
            }
            }
        }