示例#1
0
        /// <summary>
        /// Initiate the Material of this renderer
        /// </summary>
        private void InitialteFPVMaterials()
        {
            if (fpvMaterial == null)
            {
                fpvMaterial = new FPV_SM_Material();
            }

            fpvMaterial.OriginalMaterial = _render.sharedMaterial;      //Store the original material

            if (fpvMaterial.FirstPersonViewMaterial == null)            //Instance a new material of the original used if none is assigned to the firstpersonmaterial
            {
                fpvMaterial.FirstPersonViewMaterial = _render.material; //Create instance.

                //Reset the original material
                _render.sharedMaterial = fpvMaterial.OriginalMaterial;
            }

            //Enable the Keyword FIRSTPERSONVIEW for this material
            fpvMaterial.FirstPersonViewMaterial.EnableKeyword("FIRSTPERSONVIEW");
        }