Example #1
0
        public override Packet[]        CreateUpdatePackets()
        {
            NGServerScene scene  = Object.FindObjectOfType <NGServerScene>();
            NGShader      shader = scene.GetNGShader(this.material.shader);

            return(new Packet[] { new NotifyMaterialDataChangedPacket(this.material, shader) });
        }
Example #2
0
        public MonitorMaterial(Material gameObject, NGShader shader) : base(gameObject.GetInstanceID().ToString(), () => gameObject)
        {
            this.material      = gameObject;
            this.workingShader = this.material.shader;

            this.children = new List <MonitorData>(shader.properties.Length);

            this.MonitorChildren(shader);
        }
Example #3
0
        private void    MonitorChildren(NGShader shader)
        {
            for (int i = 0; i < shader.properties.Length; i++)
            {
                if (shader.properties[i].type == NGShader.ShaderPropertyType.TexEnv)
                {
                    this.children.Add(new MonitorMaterialVector2(this.material, shader.properties[i], MaterialVector2Type.Offset));
                    this.children.Add(new MonitorMaterialVector2(this.material, shader.properties[i], MaterialVector2Type.Scale));
                }

                this.children.Add(new MonitorMaterialProperty(this.material, shader.properties[i]));
            }
        }
Example #4
0
        public override void    CollectUpdates(List <MonitorData> updates)
        {
            if (this.material == null)
            {
                updates.Add(this);
                return;
            }

            if (this.workingShader != this.material.shader)
            {
                this.workingShader = this.material.shader;
                this.children.Clear();

                updates.Add(this);

                if (this.material.shader != null)
                {
                    NGServerScene scene  = Object.FindObjectOfType <NGServerScene>();
                    NGShader      shader = scene.GetNGShader(this.material.shader);

                    if (shader != null)
                    {
                        this.MonitorChildren(shader);
                    }
                }

                return;
            }

            // Remove properties if the shader has changed.
            for (int i = 0; i < this.children.Count; i++)
            {
                if (this.children[i].ToDelete == true)
                {
                    this.children.RemoveAt(i--);
                }
            }

            for (int i = 0; i < this.children.Count; i++)
            {
                this.children[i].CollectUpdates(updates);
            }
        }
Example #5
0
        public static void      Serialize(ByteBuffer buffer, Material mat, NGShader shader)
        {
            buffer.Append(mat.GetInstanceID());
            buffer.AppendUnicodeString(mat.name);
            buffer.AppendUnicodeString(mat.shader.name);

            if (shader == null)
            {
                buffer.Append(-1);
            }
            else
            {
                buffer.Append(shader.properties.Length);

                for (int i = 0; i < shader.properties.Length; i++)
                {
                    NetMaterialProperty.Serialize(buffer, mat, shader.properties[i]);
                }
            }
        }
 public NotifyMaterialDataChangedPacket(Material serverMaterial, NGShader ngShader)
 {
     this.serverMaterial = serverMaterial;
     this.ngShader       = ngShader;
 }