Esempio n. 1
0
 public void OnDestroy()
 {
     if (script != null)
     {
         script.Destroy();
     }
 }
Esempio n. 2
0
 public void OnDestroy()
 {
     if (reflectionScript != null)
     {
         reflectionScript.Destroy();
     }
 }
Esempio n. 3
0
        public override void OnStart(StartState state)
        {
            var reflections = Reflections.Instance;

            Shader reflectiveShader = shader.Length == 0 ? null : Shader.Find(shader);
            Color  reflectionColour = Color.white;
            int    updateInterval   = 1;

            Util.Parse(colour, ref reflectionColour);
            Util.Parse(interval, ref updateInterval);

            updateInterval = Math.Max(updateInterval, 1);

            List <string> meshNames = Util.SplitConfigValue(meshes).ToList();

            if (reflections.LogReflectiveMeshes)
            {
                log.Print("Part \"{0}\"", part.name);
            }

            if (reflections.ReflectionType == Reflections.Type.None)
            {
                return;
            }

            script = new Reflections.Script(part, updateInterval);

            bool success = false;

            foreach (MeshFilter meshFilter in part.FindModelComponents <MeshFilter>())
            {
                var renderer = meshFilter.GetComponent <Renderer>();
                if (renderer == null)
                {
                    continue;
                }

                Material material = renderer.material;
                if (reflections.LogReflectiveMeshes)
                {
                    log.Print("+ {0} [{1}]", meshFilter.name, material.shader.name);
                }

                if (meshNames.Count == 0 || meshNames.Contains(meshFilter.name))
                {
                    success |= script.Apply(material, reflectiveShader, reflectionColour);
                }
            }

            if (!success)
            {
                script?.Destroy();
                script = null;

                log.Print("Failed to replace any shader on \"{0}\" with its reflective counterpart", part.name);
            }
        }
Esempio n. 4
0
 public void OnDestroy()
 {
     reflectionScript?.Destroy();
 }
 public void OnDestroy()
 {
     script?.Destroy();
 }