Пример #1
0
        void GetPropertyInfos(Material mat, out string[] names, out string[] details, out AMMaterialTrack.ValueType[] types, out int[] inds)
        {
            Shader shader = mat.shader;
            int count = ShaderUtil.GetPropertyCount(shader);

            List<string> _names = new List<string>();
            List<AMMaterialTrack.ValueType> _types = new List<AMMaterialTrack.ValueType>();

            for(int i = 0; i < count; i++) {
                var name = ShaderUtil.GetPropertyName(shader, i);
                var type = ShaderUtil.GetPropertyType(shader, i);

                _names.Add(name);
                _types.Add((AMMaterialTrack.ValueType)type);

                if(type == ShaderUtil.ShaderPropertyType.TexEnv) {
                    _names.Add(name); _types.Add(AMMaterialTrack.ValueType.TexOfs);
                    _names.Add(name); _types.Add(AMMaterialTrack.ValueType.TexScale);
                }
            }

            count = _names.Count;

            names = new string[count];
            details = new string[count];
            types = new AMMaterialTrack.ValueType[count];
            inds = new int[count];

            for(int i = 0; i < count; i++) {
                names[i] = _names[i];
                types[i] = _types[i];

                switch(types[i]) {
                    case AMMaterialTrack.ValueType.TexOfs:
                        details[i] = string.Format("{0} Offset", names[i]);
                        break;
                    case AMMaterialTrack.ValueType.TexScale:
                        details[i] = string.Format("{0} Scale", names[i]);
                        break;
                    default:
                        details[i] = names[i];
                        break;
                }

                inds[i] = i;
            }
        }
Пример #2
0
 public static void ApplyValueLerp(AMMaterialTrack.ValueType valueType, string prop, int propId, Material mat, AMMaterialKey fromKey, AMMaterialKey toKey, float t)
 {
     switch(valueType) {
         case AMMaterialTrack.ValueType.Float:
         case AMMaterialTrack.ValueType.Range:
             mat.SetFloat(propId, Mathf.Lerp(fromKey.val, toKey.val, t));
             break;
         case AMMaterialTrack.ValueType.Vector:
             mat.SetVector(propId, Vector4.Lerp(fromKey.vector, toKey.vector, t));
             break;
         case AMMaterialTrack.ValueType.Color:
             mat.SetColor(propId, Color.Lerp(fromKey.color, toKey.color, t));
             break;
         case AMMaterialTrack.ValueType.TexOfs:
             mat.SetTextureOffset(prop, Vector2.Lerp(fromKey.texOfs, toKey.texOfs, t));
             break;
         case AMMaterialTrack.ValueType.TexScale:
             mat.SetTextureScale(prop, Vector2.Lerp(fromKey.texScale, toKey.texScale, t));
             break;
     }
 }
Пример #3
0
 public void ApplyValue(AMMaterialTrack.ValueType valueType, string prop, int propId, Material mat)
 {
     switch(valueType) {
         case AMMaterialTrack.ValueType.Float:
         case AMMaterialTrack.ValueType.Range:
             mat.SetFloat(propId, val);
             break;
         case AMMaterialTrack.ValueType.Vector:
             mat.SetVector(propId, vector);
             break;
         case AMMaterialTrack.ValueType.Color:
             mat.SetColor(propId, color);
             break;
         case AMMaterialTrack.ValueType.TexEnv:
             mat.SetTexture(propId, texture);
             break;
         case AMMaterialTrack.ValueType.TexOfs:
             mat.SetTextureOffset(prop, texOfs);
             break;
         case AMMaterialTrack.ValueType.TexScale:
             mat.SetTextureScale(prop, texScale);
             break;
     }
 }
Пример #4
0
 public bool hasSamePropertyAs(AMITarget target, AMMaterialTrack _track)
 {
     if(_track.GetTarget(target) == GetTarget(target) && _track.GetMaterial(target) == GetMaterial(target) && _track.getTrackType() == getTrackType())
         return true;
     return false;
 }
Пример #5
0
 public bool targetsAreEqual(AMMaterialTrack.ValueType valueType, AMMaterialKey nextKey)
 {
     if(nextKey) {
         if(valueType == AMMaterialTrack.ValueType.Float || valueType == AMMaterialTrack.ValueType.Range) return val == nextKey.val;
         if(valueType == AMMaterialTrack.ValueType.Vector) return vector == nextKey.vector;
         if(valueType == AMMaterialTrack.ValueType.Color) return color == nextKey.color;
         if(valueType == AMMaterialTrack.ValueType.TexOfs) return texOfs == nextKey.texOfs;
         if(valueType == AMMaterialTrack.ValueType.TexScale) return texScale == nextKey.texScale;
     }
     return false;
 }
Пример #6
0
        public string getValueString(AMMaterialTrack.ValueType valueType, AMMaterialKey nextKey, bool brief)
        {
            System.Text.StringBuilder s = new System.Text.StringBuilder();

            switch(valueType) {
                case AMMaterialTrack.ValueType.Float:
                case AMMaterialTrack.ValueType.Range:
                    s.Append(formatNumeric(val));
                    if(!brief && nextKey) { s.Append(" -> "); s.Append(formatNumeric(nextKey.val)); }
                    break;
                case AMMaterialTrack.ValueType.Vector:
                    s.Append(_val4.ToString());
                    if(!brief && nextKey) { s.Append(" -> "); s.Append(nextKey._val4.ToString()); }
                    break;
                case AMMaterialTrack.ValueType.Color:
                    s.Append(color.ToString());
                    if(!brief && nextKey) { s.Append(" -> "); s.Append(nextKey.color.ToString()); }
                    break;
                case AMMaterialTrack.ValueType.TexEnv:
                    s.Append(texture ? texture.name : "None");
                    break;
                case AMMaterialTrack.ValueType.TexOfs:
                    s.Append(texOfs.ToString());
                    if(!brief && nextKey) { s.Append(" -> "); s.Append(nextKey.texOfs.ToString()); }
                    break;
                case AMMaterialTrack.ValueType.TexScale:
                    s.Append(texScale.ToString());
                    if(!brief && nextKey) { s.Append(" -> "); s.Append(nextKey.texScale.ToString()); }
                    break;
            }

            return s.ToString();
        }
Пример #7
0
 public object getValue(AMMaterialTrack.ValueType valueType)
 {
     if(valueType == AMMaterialTrack.ValueType.TexEnv) return texture ? texture : null;
     if(valueType == AMMaterialTrack.ValueType.Vector) return vector;
     if(valueType == AMMaterialTrack.ValueType.Color) return color;
     if(valueType == AMMaterialTrack.ValueType.TexOfs) return texOfs;
     if(valueType == AMMaterialTrack.ValueType.TexScale) return texScale;
     return val;
 }
Пример #8
0
        public static void Open(AMMaterialTrack track)
        {
            window = EditorWindow.GetWindow(typeof(AMMaterialEditor)) as AMMaterialEditor;

            window.mTrack = track;
        }