diff options
| author | Tom Harley | 2018-09-03 23:34:21 +0100 |
|---|---|---|
| committer | Tom Harley | 2018-09-03 23:36:01 +0100 |
| commit | 5440734d820606b29a795c46172ade5d7eba8efb (patch) | |
| tree | 85867f40afb02cfa2a5028b515ed0a195866b7e9 /Assets/Cinemachine/PostFX | |
| download | powerless-5440734d820606b29a795c46172ade5d7eba8efb.tar.gz powerless-5440734d820606b29a795c46172ade5d7eba8efb.zip | |
Initial commit
Diffstat (limited to 'Assets/Cinemachine/PostFX')
12 files changed, 750 insertions, 0 deletions
diff --git a/Assets/Cinemachine/PostFX/CinemachinePostFX.cs b/Assets/Cinemachine/PostFX/CinemachinePostFX.cs new file mode 100644 index 0000000..9d0ac89 --- /dev/null +++ b/Assets/Cinemachine/PostFX/CinemachinePostFX.cs @@ -0,0 +1,161 @@ +using UnityEngine; + +// NOTE: If you are getting errors of the sort that say something like: +// "The type or namespace name `PostProcessing' does not exist in the namespace" +// it is because the PostProcessing v1 module has been removed from your project. +// +// To make the errors go away, you can either: +// 1 - Download PostProcessing V1 and install it into your project +// or +// 2 - Go into PlayerSettings/OtherSettings and remove the Scripting Define for UNITY_POST_PROCESSING_STACK_V1 +// + +namespace Cinemachine.PostFX +{ +#if UNITY_POST_PROCESSING_STACK_V1 && !UNITY_POST_PROCESSING_STACK_V2 + /// <summary> + /// This behaviour is a liaison between Cinemachine with the Post-Processing v1 module. You must + /// have the Post-Processing V1 stack asset store package installed in order to use this behaviour. + /// + /// It's used in 2 ways: + /// + /// * As a component on the Unity Camera: it serves as the liaison + /// between the camera's CinemachineBrain and the camera's Post-Processing behaviour. + /// It listens for camera Cut events and resets the Post-Processing stack when they occur. + /// If you are using Post-Processing, then you should add this behaviour to your + /// camera alongside the CinemachineBrain, always. + /// + /// * As a component on the Virtual Camera: In this capacity, it holds + /// a Post-Processing Profile asset that will be applied to the Unity camera whenever + /// the Virtual camera is live. It also has the (temporary) optional functionality of animating + /// the Focus Distance and DepthOfField properties of the Camera State, and + /// applying them to the current Post-Processing profile. + /// </summary> + [DocumentationSorting(100, DocumentationSortingAttribute.Level.UserRef)] + [ExecuteInEditMode] + [DisallowMultipleComponent] + [AddComponentMenu("Cinemachine/CinemachinePostFX")] + [SaveDuringPlay] + public class CinemachinePostFX : MonoBehaviour + { + // Just for the Enabled checkbox + void Update() {} + + [Tooltip("When this behaviour is on a Unity Camera, this setting is the default Post-Processing profile for the camera, and will be applied whenever it is not overridden by a virtual camera. When the behaviour is on a virtual camera, then this is the Post-Processing profile that will become active whenever this virtual camera is live")] + public UnityEngine.PostProcessing.PostProcessingProfile m_Profile; + + [Tooltip("If checked, then the Focus Distance will be set to the distance between the camera and the LookAt target.")] + public bool m_FocusTracksTarget; + + [Tooltip("Offset from target distance, to be used with Focus Tracks Target.")] + public float m_FocusOffset; + + // These are used if this behaviour is on a Unity Camera + CinemachineBrain mBrain; + UnityEngine.PostProcessing.PostProcessingBehaviour mPostProcessingBehaviour; + + void ConnectToBrain() + { + // If I am a component on the Unity camera, connect to its brain + // and to its post-processing behaviour + mBrain = GetComponent<CinemachineBrain>(); + if (mBrain != null) + { + mBrain.m_CameraCutEvent.RemoveListener(OnCameraCut); + mBrain.m_CameraCutEvent.AddListener(OnCameraCut); + } + // Must have one of these if connected to a brain + mPostProcessingBehaviour = GetComponent<UnityEngine.PostProcessing.PostProcessingBehaviour>(); + if (mPostProcessingBehaviour == null && mBrain != null) + mPostProcessingBehaviour = gameObject.AddComponent<UnityEngine.PostProcessing.PostProcessingBehaviour>(); + } + + void OnDestroy() + { + if (mBrain != null) + mBrain.m_CameraCutEvent.RemoveListener(OnCameraCut); + } + + // CinemachineBrain callback used when this behaviour is on the Unity Camera + internal void PostFXHandler(CinemachineBrain brain) + { + //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostFX.PostFXHandler"); + ICinemachineCamera vcam = brain.ActiveVirtualCamera; + if (enabled && mBrain != null && mPostProcessingBehaviour != null) + { + // Look for the vcam's PostFX behaviour + CinemachinePostFX postFX = GetEffectivePostFX(vcam); + if (postFX == null) + postFX = this; // vcam does not define a profile - apply the default + if (postFX.m_Profile != null) + { + // Adjust the focus distance + CameraState state = brain.CurrentCameraState; + UnityEngine.PostProcessing.DepthOfFieldModel.Settings dof + = postFX.m_Profile.depthOfField.settings; + if (postFX.m_FocusTracksTarget && state.HasLookAt) + dof.focusDistance = (state.FinalPosition - state.ReferenceLookAt).magnitude + + postFX.m_FocusOffset; + postFX.m_Profile.depthOfField.settings = dof; + } + // Apply the profile + if (mPostProcessingBehaviour.profile != postFX.m_Profile) + { + mPostProcessingBehaviour.profile = postFX.m_Profile; + mPostProcessingBehaviour.ResetTemporalEffects(); + } + } + //UnityEngine.Profiling.Profiler.EndSample(); + } + + CinemachinePostFX GetEffectivePostFX(ICinemachineCamera vcam) + { + while (vcam != null && vcam.LiveChildOrSelf != vcam) + vcam = vcam.LiveChildOrSelf; + CinemachinePostFX postFX = null; + while (vcam != null && postFX == null) + { + CinemachineVirtualCameraBase vcamBase = vcam as CinemachineVirtualCameraBase; + if (vcamBase != null) + postFX = vcamBase.GetComponent<CinemachinePostFX>(); + if (postFX != null && !postFX.enabled) + postFX = null; + vcam = vcam.ParentCamera; + } + return postFX; + } + + void OnCameraCut(CinemachineBrain brain) + { + if (mPostProcessingBehaviour != null) + { + //Debug.Log("CinemachinePostFX.OnCameraCut()"); + mPostProcessingBehaviour.ResetTemporalEffects(); + } + } + + static void StaticPostFXHandler(CinemachineBrain brain) + { + CinemachinePostFX postFX = brain.PostProcessingComponent as CinemachinePostFX; + if (postFX == null) + { + brain.PostProcessingComponent = brain.GetComponent<CinemachinePostFX>(); + postFX = brain.PostProcessingComponent as CinemachinePostFX; + if (postFX != null) + postFX.ConnectToBrain(); + } + if (postFX != null) + postFX.PostFXHandler(brain); + } + + /// <summary>Internal method called by editor module</summary> + [RuntimeInitializeOnLoadMethod] + public static void InitializeModule() + { + // When the brain pushes the state to the camera, hook in to the PostFX + CinemachineBrain.sPostProcessingHandler.RemoveListener(StaticPostFXHandler); + CinemachineBrain.sPostProcessingHandler.AddListener(StaticPostFXHandler); + } + } +#endif +} diff --git a/Assets/Cinemachine/PostFX/CinemachinePostFX.cs.meta b/Assets/Cinemachine/PostFX/CinemachinePostFX.cs.meta new file mode 100644 index 0000000..770bb45 --- /dev/null +++ b/Assets/Cinemachine/PostFX/CinemachinePostFX.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 360979aafebd332448626a2236bafdb4 +timeCreated: 1493845370 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 5f2a108eb023faf43a809979fd3d38f2, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Cinemachine/PostFX/CinemachinePostProcessing.cs b/Assets/Cinemachine/PostFX/CinemachinePostProcessing.cs new file mode 100644 index 0000000..4fc6241 --- /dev/null +++ b/Assets/Cinemachine/PostFX/CinemachinePostProcessing.cs @@ -0,0 +1,231 @@ +#if UNITY_POST_PROCESSING_STACK_V2 + +// NOTE: If you are getting errors of the sort that say something like: +// "The type or namespace name `PostProcessing' does not exist in the namespace" +// it is because the PostProcessing v2 module has been removed from your project. +// +// To make the errors go away, you can either: +// 1 - Download PostProcessing V2 and install it into your project +// or +// 2 - Go into PlayerSettings/OtherSettings and remove the Scripting Define for UNITY_POST_PROCESSING_STACK_V2 +// + +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Rendering.PostProcessing; + +namespace Cinemachine.PostFX +{ + /// <summary> + /// This behaviour is a liaison between Cinemachine with the Post-Processing v2 module. You must + /// have the Post-Processing V2 stack asset store package installed in order to use this behaviour. + /// + /// As a component on the Virtual Camera, it holds + /// a Post-Processing Profile asset that will be applied to the Unity camera whenever + /// the Virtual camera is live. It also has the optional functionality of animating + /// the Focus Distance and DepthOfField properties of the Camera State, and + /// applying them to the current Post-Processing profile, provided that profile has a + /// DepthOfField effect that is enabled. + /// </summary> + [DocumentationSorting(101, DocumentationSortingAttribute.Level.UserRef)] + [ExecuteInEditMode] + [AddComponentMenu("")] // Hide in menu + [SaveDuringPlay] + public class CinemachinePostProcessing : CinemachineExtension + { + [Tooltip("If checked, then the Focus Distance will be set to the distance between the camera and the LookAt target. Requires DepthOfField effect in the Profile")] + public bool m_FocusTracksTarget; + + [Tooltip("Offset from target distance, to be used with Focus Tracks Target. Offsets the sharpest point away from the LookAt target.")] + public float m_FocusOffset; + + [Tooltip("This Post-Processing profile will be applied whenever this virtual camera is live")] + public PostProcessProfile m_Profile; + + bool mCachedProfileIsInvalid = true; + PostProcessProfile mProfileCopy; + public PostProcessProfile Profile { get { return mProfileCopy != null ? mProfileCopy : m_Profile; } } + + /// <summary>True if the profile is enabled and nontrivial</summary> + public bool IsValid { get { return m_Profile != null && m_Profile.settings.Count > 0; } } + + /// <summary>Called by the editor when the shared asset has been edited</summary> + public void InvalidateCachedProfile() { mCachedProfileIsInvalid = true; } + + void CreateProfileCopy() + { + DestroyProfileCopy(); + PostProcessProfile profile = ScriptableObject.CreateInstance<PostProcessProfile>(); + if (m_Profile != null) + { + foreach (var item in m_Profile.settings) + { + var itemCopy = Instantiate(item); + profile.settings.Add(itemCopy); + } + } + mProfileCopy = profile; + mCachedProfileIsInvalid = false; + } + + void DestroyProfileCopy() + { + if (mProfileCopy != null) + DestroyImmediate(mProfileCopy); + mProfileCopy = null; + } + + protected override void OnDestroy() + { + base.OnDestroy(); + DestroyProfileCopy(); + } + + protected override void PostPipelineStageCallback( + CinemachineVirtualCameraBase vcam, + CinemachineCore.Stage stage, ref CameraState state, float deltaTime) + { + //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.PostPipelineStageCallback"); + // Set the focus after the camera has been fully positioned. + // GML todo: what about collider? + if (stage == CinemachineCore.Stage.Aim) + { + if (!IsValid) + DestroyProfileCopy(); + else + { + // Handle Follow Focus + if (!m_FocusTracksTarget || !state.HasLookAt) + DestroyProfileCopy(); + else + { + if (mProfileCopy == null || mCachedProfileIsInvalid) + CreateProfileCopy(); + DepthOfField dof; + if (mProfileCopy.TryGetSettings(out dof)) + dof.focusDistance.value + = (state.FinalPosition - state.ReferenceLookAt).magnitude + m_FocusOffset; + } + + // Apply the post-processing + state.AddCustomBlendable(new CameraState.CustomBlendable(this, 1)); + } + } + //UnityEngine.Profiling.Profiler.EndSample(); + } + + static void OnCameraCut(CinemachineBrain brain) + { + // Debug.Log("Camera cut event"); + PostProcessLayer postFX = brain.PostProcessingComponent as PostProcessLayer; + if (postFX == null) + brain.PostProcessingComponent = null; // object deleted + else + postFX.ResetHistory(); + } + + static void ApplyPostFX(CinemachineBrain brain) + { + //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.ApplyPostFX"); + PostProcessLayer ppLayer = brain.GetComponent<PostProcessLayer>(); + if (ppLayer == null || !ppLayer.enabled || ppLayer.volumeLayer == 0) + return; + + CameraState state = brain.CurrentCameraState; + int numBlendables = state.NumCustomBlendables; + List<PostProcessVolume> volumes = GetDynamicBrainVolumes(brain, ppLayer, numBlendables); + for (int i = 0; i < volumes.Count; ++i) + { + volumes[i].weight = 0; + volumes[i].sharedProfile = null; + volumes[i].profile = null; + } + for (int i = 0; i < numBlendables; ++i) + { + var b = state.GetCustomBlendable(i); + CinemachinePostProcessing src = b.m_Custom as CinemachinePostProcessing; + if (!(src == null)) // in case it was deleted + { + PostProcessVolume v = volumes[i]; + v.sharedProfile = src.Profile; + v.isGlobal = true; + v.priority = float.MaxValue-1; + v.weight = b.m_Weight; + } + } + //UnityEngine.Profiling.Profiler.EndSample(); + } + + static string sVolumeOwnerName = "__CMVolumes"; + static List<PostProcessVolume> sVolumes = new List<PostProcessVolume>(); + static List<PostProcessVolume> GetDynamicBrainVolumes( + CinemachineBrain brain, PostProcessLayer ppLayer, int minVolumes) + { + //UnityEngine.Profiling.Profiler.BeginSample("CinemachinePostProcessing.GetDynamicBrainVolumes"); + // Locate the camera's child object that holds our dynamic volumes + GameObject volumeOwner = null; + Transform t = brain.transform; + int numChildren = t.childCount; + + sVolumes.Clear(); + for (int i = 0; volumeOwner == null && i < numChildren; ++i) + { + GameObject child = t.GetChild(i).gameObject; + if (child.hideFlags == HideFlags.HideAndDontSave) + { + child.GetComponents(sVolumes); + if (sVolumes.Count > 0) + volumeOwner = child; + } + } + + if (minVolumes > 0) + { + if (volumeOwner == null) + { + volumeOwner = new GameObject(sVolumeOwnerName); + volumeOwner.hideFlags = HideFlags.HideAndDontSave; + volumeOwner.transform.parent = t; + } + // Update the volume's layer so it will be seen + int mask = ppLayer.volumeLayer.value; + for (int i = 0; i < 32; ++i) + { + if ((mask & (1 << i)) != 0) + { + volumeOwner.layer = i; + break; + } + } + while (sVolumes.Count < minVolumes) + sVolumes.Add(volumeOwner.gameObject.AddComponent<PostProcessVolume>()); + } + //UnityEngine.Profiling.Profiler.EndSample(); + return sVolumes; + } + + /// <summary>Internal method called by editor module</summary> + [RuntimeInitializeOnLoadMethod] + public static void InitializeModule() + { + // When the brain pushes the state to the camera, hook in to the PostFX + CinemachineBrain.sPostProcessingHandler.RemoveListener(StaticPostFXHandler); + CinemachineBrain.sPostProcessingHandler.AddListener(StaticPostFXHandler); + } + + static void StaticPostFXHandler(CinemachineBrain brain) + { + PostProcessLayer postFX = brain.PostProcessingComponent as PostProcessLayer; + if (postFX == null) + { + brain.PostProcessingComponent = brain.GetComponent<PostProcessLayer>(); + postFX = brain.PostProcessingComponent as PostProcessLayer; + if (postFX != null) + brain.m_CameraCutEvent.AddListener(CinemachinePostProcessing.OnCameraCut); + } + if (postFX != null) + CinemachinePostProcessing.ApplyPostFX(brain); + } + } +} +#endif diff --git a/Assets/Cinemachine/PostFX/CinemachinePostProcessing.cs.meta b/Assets/Cinemachine/PostFX/CinemachinePostProcessing.cs.meta new file mode 100644 index 0000000..081dc26 --- /dev/null +++ b/Assets/Cinemachine/PostFX/CinemachinePostProcessing.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 729aad4491e915a41bda2b8325cf757a +timeCreated: 1504838447 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {fileID: 2800000, guid: 5f2a108eb023faf43a809979fd3d38f2, type: 3} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Cinemachine/PostFX/Editor.meta b/Assets/Cinemachine/PostFX/Editor.meta new file mode 100644 index 0000000..d5517ec --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8656080a6ad58f046abadcd6f2c0fb4f +folderAsset: yes +timeCreated: 1493832945 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Cinemachine/PostFX/Editor/CinemachinePostProcessingEditor.cs b/Assets/Cinemachine/PostFX/Editor/CinemachinePostProcessingEditor.cs new file mode 100644 index 0000000..7306d53 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/CinemachinePostProcessingEditor.cs @@ -0,0 +1,180 @@ +#if UNITY_POST_PROCESSING_STACK_V2 + +// NOTE: If you are getting errors of the sort that say something like: +// "The type or namespace name `PostProcessing' does not exist in the namespace" +// it is because the PostProcessing v2 module has been removed from your project. +// +// To make the errors go away, you can either: +// 1 - Download PostProcessing V2 and install it into your project +// or +// 2 - Go into PlayerSettings and remove the define for UNITY_POST_PROCESSING_STACK_V2 +// + +using UnityEngine; +using UnityEditor; +using UnityEngine.Rendering.PostProcessing; +using UnityEditor.Rendering.PostProcessing; + +namespace Cinemachine.PostFX.Editor +{ + [CustomEditor(typeof(CinemachinePostProcessing))] + public sealed class CinemachinePostProcessingEditor + : Cinemachine.Editor.BaseEditor<CinemachinePostProcessing> + { + SerializedProperty m_Profile; + SerializedProperty m_FocusTracksTarget; + SerializedProperty m_FocusOffset; + + EffectListEditor m_EffectList; + GUIContent m_ProfileLabel; + + void OnEnable() + { + Texture textue = Resources.Load("PostProcessLayer") as Texture; + m_ProfileLabel = new GUIContent("Profile", textue, "A reference to a profile asset"); + + m_FocusTracksTarget = FindProperty(x => x.m_FocusTracksTarget); + m_FocusOffset = FindProperty(x => x.m_FocusOffset); + m_Profile = FindProperty(x => x.m_Profile); + + m_EffectList = new EffectListEditor(this); + RefreshEffectListEditor(Target.m_Profile); + } + + void OnDisable() + { + m_EffectList.Clear(); + } + + void RefreshEffectListEditor(PostProcessProfile asset) + { + m_EffectList.Clear(); + if (asset != null) + m_EffectList.Init(asset, new SerializedObject(asset)); + } + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + var rect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight); rect.y += 2; + float checkboxWidth = rect.height + 5; + rect = EditorGUI.PrefixLabel(rect, new GUIContent(m_FocusTracksTarget.displayName)); + EditorGUI.PropertyField(new Rect(rect.x, rect.y, checkboxWidth, rect.height), m_FocusTracksTarget, GUIContent.none); + rect.x += checkboxWidth; rect.width -= checkboxWidth; + if (m_FocusTracksTarget.boolValue) + { + GUIContent offsetText = new GUIContent("Offset "); + var textDimensions = GUI.skin.label.CalcSize(offsetText); + float oldWidth = EditorGUIUtility.labelWidth; + EditorGUIUtility.labelWidth = textDimensions.x; + EditorGUI.PropertyField(rect, m_FocusOffset, offsetText); + EditorGUIUtility.labelWidth = oldWidth; + + bool valid = false; + DepthOfField dof; + if (Target.m_Profile != null && Target.m_Profile.TryGetSettings<DepthOfField>(out dof)) + valid = dof.enabled && dof.active && dof.focusDistance.overrideState + && Target.VirtualCamera.LookAt != null; + if (!valid) + EditorGUILayout.HelpBox( + "Focus Tracking requires a LookAt target on the Virtual Camera, and an active DepthOfField/FocusDistance effect in the profile", + MessageType.Warning); + } + + DrawProfileInspectorGUI(); + Target.InvalidateCachedProfile(); + + serializedObject.ApplyModifiedProperties(); + } + + void DrawProfileInspectorGUI() + { + EditorGUILayout.Space(); + + bool assetHasChanged = false; + bool showCopy = m_Profile.objectReferenceValue != null; + + // The layout system sort of break alignement when mixing inspector fields with custom + // layouted fields, do the layout manually instead + int buttonWidth = showCopy ? 45 : 60; + float indentOffset = EditorGUI.indentLevel * 15f; + var lineRect = GUILayoutUtility.GetRect(1, EditorGUIUtility.singleLineHeight); + var labelRect = new Rect(lineRect.x, lineRect.y, EditorGUIUtility.labelWidth - indentOffset, lineRect.height); + var fieldRect = new Rect(labelRect.xMax, lineRect.y, lineRect.width - labelRect.width - buttonWidth * (showCopy ? 2 : 1), lineRect.height); + var buttonNewRect = new Rect(fieldRect.xMax, lineRect.y, buttonWidth, lineRect.height); + var buttonCopyRect = new Rect(buttonNewRect.xMax, lineRect.y, buttonWidth, lineRect.height); + + EditorGUI.PrefixLabel(labelRect, m_ProfileLabel); + + using (var scope = new EditorGUI.ChangeCheckScope()) + { + m_Profile.objectReferenceValue + = (PostProcessProfile)EditorGUI.ObjectField( + fieldRect, m_Profile.objectReferenceValue, typeof(PostProcessProfile), false); + assetHasChanged = scope.changed; + } + + if (GUI.Button( + buttonNewRect, + EditorUtilities.GetContent("New|Create a new profile."), + showCopy ? EditorStyles.miniButtonLeft : EditorStyles.miniButton)) + { + // By default, try to put assets in a folder next to the currently active + // scene file. If the user isn't a scene, put them in root instead. + var targetName = Target.name; + var scene = Target.gameObject.scene; + var asset = ProfileFactory.CreatePostProcessProfile(scene, targetName); + m_Profile.objectReferenceValue = asset; + assetHasChanged = true; + } + + if (showCopy && GUI.Button( + buttonCopyRect, + EditorUtilities.GetContent("Clone|Create a new profile and copy the content of the currently assigned profile."), + EditorStyles.miniButtonRight)) + { + // Duplicate the currently assigned profile and save it as a new profile + var origin = (PostProcessProfile)m_Profile.objectReferenceValue; + var path = AssetDatabase.GetAssetPath(origin); + path = AssetDatabase.GenerateUniqueAssetPath(path); + + var asset = Instantiate(origin); + asset.settings.Clear(); + AssetDatabase.CreateAsset(asset, path); + + foreach (var item in origin.settings) + { + var itemCopy = Instantiate(item); + itemCopy.hideFlags = HideFlags.HideInInspector | HideFlags.HideInHierarchy; + itemCopy.name = item.name; + asset.settings.Add(itemCopy); + AssetDatabase.AddObjectToAsset(itemCopy, asset); + } + + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + + m_Profile.objectReferenceValue = asset; + assetHasChanged = true; + } + + if (m_Profile.objectReferenceValue == null) + { + if (assetHasChanged) + m_EffectList.Clear(); // Asset wasn't null before, do some cleanup + + EditorGUILayout.HelpBox( + "Assign an existing Post-process Profile by choosing an asset, or create a new one by clicking the \"New\" button.\nNew assets are automatically put in a folder next to your scene file. If your scene hasn't been saved yet they will be created at the root of the Assets folder.", + MessageType.Info); + } + else + { + if (assetHasChanged) + RefreshEffectListEditor((PostProcessProfile)m_Profile.objectReferenceValue); + m_EffectList.OnGUI(); + } + } + } +} +#endif diff --git a/Assets/Cinemachine/PostFX/Editor/CinemachinePostProcessingEditor.cs.meta b/Assets/Cinemachine/PostFX/Editor/CinemachinePostProcessingEditor.cs.meta new file mode 100644 index 0000000..1b8fbd2 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/CinemachinePostProcessingEditor.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: dec69862942cc9744ade63216979cafd +timeCreated: 1504726346 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs b/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs new file mode 100644 index 0000000..1156197 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs @@ -0,0 +1,35 @@ + +namespace Cinemachine.PostFX +{ + /// <summary>Integrates Cinemachine with PostProcessing V1 stack.</summary> + /// Since PostPorcessing V1 does not create a define in Player settings the + /// way V2 does, we do it ourselves if we detect the presence of PostProcessing V1 + class PostFXAutoImport + { + [UnityEditor.InitializeOnLoad] + class EditorInitialize + { + static EditorInitialize() + { +#if UNITY_POST_PROCESSING_STACK_V2 + // We have PPv2 + CinemachinePostProcessing.InitializeModule(); +#else + // Check for PostProcessing V1. Define symbol if we have it. + if (Cinemachine.Utility.ReflectionHelpers.TypeIsDefined("UnityEngine.PostProcessing.PostProcessingBehaviour")) + { + if (Cinemachine.Editor.ScriptableObjectUtility.AddDefineForAllBuildTargets("UNITY_POST_PROCESSING_STACK_V1")) + { + string path = Cinemachine.Editor.ScriptableObjectUtility.CinemachineInstallAssetPath + "/PostFX/CinemachinePostFX.cs"; + UnityEditor.AssetDatabase.ImportAsset(path, UnityEditor.ImportAssetOptions.ForceUpdate); + } + } + #if UNITY_POST_PROCESSING_STACK_V1 + // We have PPv1 + CinemachinePostFX.InitializeModule(); + #endif +#endif + } + } + } +} diff --git a/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs.meta b/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs.meta new file mode 100644 index 0000000..7b0d751 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/PostFXAutoImport.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: f6542fc5402b30a4482cd20a3621602b +timeCreated: 1493832945 +licenseType: Store +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Cinemachine/PostFX/Editor/Resources.meta b/Assets/Cinemachine/PostFX/Editor/Resources.meta new file mode 100644 index 0000000..20303b9 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f15624949ca514549b2f04481b49bdd0 +folderAsset: yes +timeCreated: 1504790995 +licenseType: Store +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Cinemachine/PostFX/Editor/Resources/PostProcessLayer.png b/Assets/Cinemachine/PostFX/Editor/Resources/PostProcessLayer.png new file mode 100644 index 0000000..f78f1c1 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/Resources/PostProcessLayer.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b4b2c2810e178fe08231677abee71a3eba1821baeda831b3d7034b2cd2a078cd +size 37871 diff --git a/Assets/Cinemachine/PostFX/Editor/Resources/PostProcessLayer.png.meta b/Assets/Cinemachine/PostFX/Editor/Resources/PostProcessLayer.png.meta new file mode 100644 index 0000000..b9624e0 --- /dev/null +++ b/Assets/Cinemachine/PostFX/Editor/Resources/PostProcessLayer.png.meta @@ -0,0 +1,74 @@ +fileFormatVersion: 2 +guid: 1fa3cd9f91afee64e96c128a82544bcd +timeCreated: 1504790999 +licenseType: Store +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 4 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -1 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 100 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + platformSettings: + - buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: |
