/// <summary> /// Instanciates the necessary datastructures for the rendering of the velocity buffer and the post-processing effect. /// Basically it finds every gameobject that contains a MeshRenderer component and adds the ObjectEffectHandler script to that object. /// </summary> override protected void Start() { //sets up the ObjectEffectHandler script for each object that is rendered by the mesh renderer Object[] sceneObjects = GameObject.FindObjectsOfType(typeof(MeshRenderer)); foreach (Object obj in sceneObjects) { if (obj is MeshRenderer) { GameObject gmObj = ((MeshRenderer)obj).gameObject; ObjectEffectHandler component = gmObj.GetComponent <ObjectEffectHandler>(); if (component == null) { gmObj.AddComponent <ObjectEffectHandler>(); } else if (!component.enabled) { component.enabled = true; } } } base.Start(); }
/// <summary> /// Static function so that each ObjectEffectHandler can remove itself from the list of objects to be rendered /// to the velocity buffer. (OnDisable) /// </summary> /// <param name="obj">The instance of the ObjectEffectHandler</param> public static void RemoveEffectObject(ObjectEffectHandler obj) { if (EffectObjects.Contains(obj)) { EffectObjects.Remove(obj); } }
/// <summary> /// Static function so that each ObjectEffectHandler can remove itself from the list of objects to be rendered /// to the velocity buffer. (OnDisable) /// </summary> /// <param name="obj">The instance of the ObjectEffectHandler</param> public static void RemoveEffectObject(ObjectEffectHandler obj) { if (EffectObjects.Contains(obj)) EffectObjects.Remove(obj); }
/// <summary> /// Static function so that each ObjectEffectHandler can add itself into the list of objects to be rendered /// to the velocity buffer. (OnEnable) /// </summary> /// <param name="obj">The instance of the ObjectEffectHandler</param> public static void AddEffectObject(ObjectEffectHandler obj) { EffectObjects.Add(obj); }