Exemplo n.º 1
0
        public MonitorMaterialProperty(Material material, NGShaderProperty propertyInfo) : base(propertyInfo.name, null)
        {
            this.material     = material;
            this.propertyInfo = propertyInfo;

            switch (this.propertyInfo.type)
            {
            case NGShader.ShaderPropertyType.Color:
                this.typeHandler = TypeHandlersManager.GetTypeHandler(typeof(Color));
                this.value       = this.material.GetColor(this.propertyInfo.name);
                break;

            case NGShader.ShaderPropertyType.Float:
            case NGShader.ShaderPropertyType.Range:
                this.typeHandler = TypeHandlersManager.GetTypeHandler(typeof(float));
                this.value       = this.material.GetFloat(this.propertyInfo.name);
                break;

            case NGShader.ShaderPropertyType.TexEnv:
                this.typeHandler = TypeHandlersManager.GetTypeHandler(typeof(Texture));
                this.value       = this.material.GetTexture(this.propertyInfo.name);
                break;

            case NGShader.ShaderPropertyType.Vector:
                this.typeHandler = TypeHandlersManager.GetTypeHandler(typeof(Vector4));
                this.value       = this.material.GetVector(this.propertyInfo.name);
                break;
            }
        }
Exemplo n.º 2
0
        public static void      Serialize(ByteBuffer buffer, Material mat, NGShaderProperty prop)
        {
            buffer.AppendUnicodeString(prop.description);
            buffer.AppendUnicodeString(prop.name);
            buffer.Append((int)prop.type);
            buffer.Append(prop.hidden);
            buffer.Append(prop.rangeMin);
            buffer.Append(prop.rangeMax);

            Type        type = null;
            TypeHandler typeHandler;

            if (prop.type == NGShader.ShaderPropertyType.Color)
            {
                type = typeof(Color);
            }
            else if (prop.type == NGShader.ShaderPropertyType.Float ||
                     prop.type == NGShader.ShaderPropertyType.Range)
            {
                type = typeof(float);
            }
            else if (prop.type == NGShader.ShaderPropertyType.TexEnv)
            {
                type = typeof(Texture);
            }
            else if (prop.type == NGShader.ShaderPropertyType.Vector)
            {
                type = typeof(Vector4);
            }

            typeHandler = TypeHandlersManager.GetTypeHandler(type);
            InternalNGDebug.Assert(typeHandler != null, "TypeHandler for " + prop.name + " is not supported.");

            if (prop.type == NGShader.ShaderPropertyType.Color)
            {
                typeHandler.Serialize(buffer, type, mat.GetColor(prop.name));
            }
            else if (prop.type == NGShader.ShaderPropertyType.Float ||
                     prop.type == NGShader.ShaderPropertyType.Range)
            {
                typeHandler.Serialize(buffer, type, mat.GetFloat(prop.name));
            }
            else if (prop.type == NGShader.ShaderPropertyType.TexEnv)
            {
                typeHandler.Serialize(buffer, type, mat.GetTexture(prop.name));

                TypeHandler vector2Handler = TypeHandlersManager.GetTypeHandler <Vector2>();

                vector2Handler.Serialize(buffer, typeof(Vector2), mat.GetTextureOffset(prop.name));
                vector2Handler.Serialize(buffer, typeof(Vector2), mat.GetTextureScale(prop.name));
            }
            else if (prop.type == NGShader.ShaderPropertyType.Vector)
            {
                typeHandler.Serialize(buffer, type, mat.GetVector(prop.name));
            }

            //Debug.Log("NetMP.Ser " + prop.description + " " + prop.name + " " + prop.type + "	" + prop.hidden);
        }
Exemplo n.º 3
0
        public MonitorMaterialVector2(Material material, NGShaderProperty propertyInfo, MaterialVector2Type type) : base(propertyInfo.name + '.' + type, null)
        {
            this.material     = material;
            this.propertyInfo = propertyInfo;
            this.type         = type;

            if (this.type == MaterialVector2Type.Offset)
            {
                this.value = this.material.GetTextureOffset(this.propertyInfo.name);
            }
            else if (this.type == MaterialVector2Type.Scale)
            {
                this.value = this.material.GetTextureScale(this.propertyInfo.name);
            }
        }