예제 #1
0
        protected virtual void OnDisable()
        {
            DestroyImmediate(_reflectionTextureLeft);
            DestroyImmediate(_reflectionTextureRight);

            QuickMirrorReflectionManager.RemoveMirror(this);
        }
예제 #2
0
        protected virtual void OnEnable()
        {
            //Create the mesh filter
            _mFilter = gameObject.GetOrCreateComponent <MeshFilter>();
            if (!_mFilter.sharedMesh)
            {
                _mFilter.sharedMesh = QuickUtils.CreateFullScreenQuad();
            }

            //Create the mesh renderer
            _renderer = gameObject.GetOrCreateComponent <MeshRenderer>();
            _renderer.receiveShadows = false;

            //Ensure that the renderer has the reflection material.
            string shaderName = GetShaderName();

            if (!_renderer.sharedMaterial || _renderer.sharedMaterial.shader.name != shaderName)
            {
                _renderer.sharedMaterial = new Material(Shader.Find(shaderName));
            }

            QuickMirrorReflectionManager.AddMirror(this);
        }