/// <summary> /// Follows target and returns depth texture with post processing /// </summary> /// <param name="texture"></param> public void GetDepthTexture(out Texture texture) { if ((Time.time - lastUpdateTime) < Time.fixedDeltaTime) { texture = postProcessTexture; return; } lastUpdateTime = Time.time; if (followPlayer && target != null) { FollowTarget(); } onSetDepthTextureEvent.Invoke(); postProcessTexture = depthTexture; for (int i = 0; i < postProcessProfile.postProcesses.Count; ++i) { GrassPostProcess postProcess = postProcessProfile.postProcesses[i]; GrassPostProcessState state = postProcessStates[i]; postProcess.DoPostProcess(this, ref state, ref postProcessTexture); postProcessStates[i] = state; } ResetLastMovementVector(); texture = postProcessTexture; }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { EditorGUI.BeginProperty(position, label, property); GrassPostProcess element = GetElement(property); property.isExpanded = EditorGUI.Foldout(new Rect(position.x, position.y, EditorGUIUtility.labelWidth, EditorGUIUtility.singleLineHeight), property.isExpanded, new GUIContent(NameAttribute.GetNameFromClassType(element.GetType()), NameAttribute.GetDescriptionFromClassType(element.GetType())), true); if (GUI.changed) { property.serializedObject.ApplyModifiedProperties(); } if (property.objectReferenceValue == null) { EditorGUIUtility.ExitGUI(); } if (property.isExpanded) { const float witdthOffset = 25f; var newRect = new Rect(position.x, position.y, position.width - position.x - witdthOffset, position.height); DrawAllChildrensGUI(newRect, property); } property.serializedObject.ApplyModifiedProperties(); EditorGUI.EndProperty(); }
private void AddPostProcessHandler(object target) { GrassPostProcess obj = ScriptableObject.CreateInstance(target as string) as GrassPostProcess; m_Profile.postProcesses.Add(obj as GrassPostProcess); AssetDatabase.AddObjectToAsset(obj, m_Profile); AssetDatabase.SaveAssets(); }
private GrassPostProcess GetElement(SerializedProperty property) { GrassPostProcess element = property.objectReferenceValue as GrassPostProcess; if (element == null) { (property.serializedObject.targetObject as GrassPostProcessProfile).postProcesses.RemoveAll(item => item == null); } return(element); }
/// <summary> /// Initialization of the needed elements /// </summary> protected void Awake() { postProcessStates = new List <GrassPostProcessState>(postProcessProfile.postProcesses.Count); for (int i = 0; i < postProcessProfile.postProcesses.Count; ++i) { GrassPostProcess postProcess = postProcessProfile.postProcesses[i]; GrassPostProcessState state; postProcess.Initialize(this, out state); postProcessStates.Add(state); } transform.rotation = Quaternion.LookRotation(new Vector3(0, 1, 0)); if (null != depthTexture) { textureSize = new Vector2Int(depthTexture.width, depthTexture.height); } }