Ejemplo n.º 1
0
    public override AnimatorTimeline.JSONInit getJSONInit()
    {
        if (!obj || keys.Count <= 0)
        {
            return(null);
        }
        AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit();
        init.type = "orientation";
        init.go   = obj.gameObject.name;
        Transform _target            = getInitialTarget();
        int       start_frame        = keys[0].frame;
        AMTrack   _translation_track = null;

        if (start_frame > 0)
        {
            _translation_track = parentTake.getTranslationTrackForTransform(_target);
        }
        Vector3 _lookv3 = _target.transform.position;

        if (_translation_track)
        {
            _lookv3 = (_translation_track as AMTranslationTrack).getPositionAtFrame(start_frame);
        }
        AnimatorTimeline.JSONVector3 v = new AnimatorTimeline.JSONVector3();
        v.setValue(_lookv3);
        init.position = v;
        return(init);
    }
Ejemplo n.º 2
0
 public override AnimatorTimeline.JSONInit getJSONInit()
 {
     if (!obj || keys.Count <= 0)
     {
         return(null);
     }
     AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit();
     init.type = "position";
     init.go   = obj.gameObject.name;
     AnimatorTimeline.JSONVector3 v = new AnimatorTimeline.JSONVector3();
     v.setValue(getInitialPosition());
     init.position = v;
     return(init);
 }
    public AnimatorTimeline.JSONEventParameter toJSON()
    {
        AnimatorTimeline.JSONEventParameter e = new AnimatorTimeline.JSONEventParameter();
        e.valueType = valueType;
        if(valueType == (int) ValueType.Boolean) e.val_bool = val_bool;
        if(valueType == (int) ValueType.String) e.val_string = (val_string/* as object*/);
        if(valueType == (int) ValueType.Char) {
            if(val_string == null || val_string.Length<=0) e.val_string = "\0";
            e.val_string =  ""+val_string[0];
        }
        if(valueType == (int) ValueType.Integer || valueType == (int) ValueType.Long) e.val_int = (val_int/* as object*/);
        if(valueType == (int) ValueType.Float || valueType == (int) ValueType.Double) e.val_float = (val_float/* as object*/);
        if(valueType == (int) ValueType.Vector2) {
            AnimatorTimeline.JSONVector2 v2 = new AnimatorTimeline.JSONVector2();
            v2.setValue(val_vect2);
            e.val_vect2 = v2;
        }
        if(valueType == (int) ValueType.Vector3) {
            AnimatorTimeline.JSONVector3 v3 = new AnimatorTimeline.JSONVector3();
            v3.setValue(val_vect3);
            e.val_vect3 = v3;
        }
        if(valueType == (int) ValueType.Vector4) {
            AnimatorTimeline.JSONVector4 v4 = new AnimatorTimeline.JSONVector4();
            v4.setValue(val_vect4);
            e.val_vect4 = v4;
        }
        if(valueType == (int) ValueType.Color) {
            AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor();
            c.setValue(val_color);
            e.val_color = c;
        }
        if(valueType == (int) ValueType.Rect) {
            AnimatorTimeline.JSONRect r = new AnimatorTimeline.JSONRect();
            r.setValue(val_rect);
            e.val_rect = r;
        }
        if(valueType == (int) ValueType.Object) {
            if(val_obj.GetType() != typeof(GameObject)) {
                // component
                e.val_obj_extra = val_obj.name;
                e.val_obj = val_obj.GetType().Name;
            } else {
                // gameobject
                e.val_obj_extra = null;
                e.val_obj = val_obj.name;
            }

        }
        if(valueType == (int) ValueType.Array && lsArray.Count > 0) {
            AnimatorTimeline.JSONEventParameter[] arr = new AnimatorTimeline.JSONEventParameter[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    //arrObj[i] = lsArray[i].val_bool;
                    arr[i] = lsArray[i].toJSON();
                }
            e.array = arr;
            /*
            if(lsArray[0].valueType == (int) ValueType.Boolean) {
                //bool[] arrObj = new bool[lsArray.Count];
        //				AnimatorTimeline.JSONEventParameter[] arr = new AnimatorTimeline.JSONEventParameter[lsArray.Count];
        //				for(int i=0;i<lsArray.Count;i++){
        //					//arrObj[i] = lsArray[i].val_bool;
        //					arr[i] = lsArray[i].toJSON();
        //				}
                //return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.String) {
                string[] arrObj = new string[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_string;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Char) {
                char[] arrObj = new char[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_string[0];
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Integer || lsArray[0].valueType == (int) ValueType.Long) {
                int[] arrObj = new int[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_int;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Float || lsArray[0].valueType == (int) ValueType.Double) {
                float[] arrObj = new float[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_float;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Vector2) {
                Vector2[] arrObj = new Vector2[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_vect2;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Vector3) {
                Vector3[] arrObj = new Vector3[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_vect3;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Vector4) {
                Vector4[] arrObj = new Vector4[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_vect4;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Color) {
                Color[] arrObj = new Color[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_color;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Rect) {
                Rect[] arrObj = new Rect[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_rect;
                }
                return arrObj;
            }
            if(lsArray[0].valueType == (int) ValueType.Object) {
                UnityEngine.Object[] arrObj = new UnityEngine.Object[lsArray.Count];
                for(int i=0;i<lsArray.Count;i++){
                    arrObj[i] = lsArray[i].val_obj;
                }
                return arrObj;
            }*/

        }
        //Debug.LogError("Animator: Type not found for Event Parameter.");
        return e;
    }
Ejemplo n.º 4
0
 public override AnimatorTimeline.JSONInit getJSONInit()
 {
     if(!_obj || keys.Count <= 0) return null;
     AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit();
     init.type = "position";
     init.go = _obj.gameObject.name;
     AnimatorTimeline.JSONVector3 v = new AnimatorTimeline.JSONVector3();
     v.setValue(getInitialPosition());
     init.position = v;
     return init;
 }
    public AnimatorTimeline.JSONEventParameter toJSON()
    {
        AnimatorTimeline.JSONEventParameter e = new AnimatorTimeline.JSONEventParameter();
        e.valueType = valueType;
        if (valueType == (int)ValueType.Boolean)
        {
            e.val_bool = val_bool;
        }
        if (valueType == (int)ValueType.String)
        {
            e.val_string = (val_string /* as object*/);
        }
        if (valueType == (int)ValueType.Char)
        {
            if (val_string == null || val_string.Length <= 0)
            {
                e.val_string = "\0";
            }
            e.val_string = "" + val_string[0];
        }
        if (valueType == (int)ValueType.Integer || valueType == (int)ValueType.Long)
        {
            e.val_int = (val_int /* as object*/);
        }
        if (valueType == (int)ValueType.Float || valueType == (int)ValueType.Double)
        {
            e.val_float = (val_float /* as object*/);
        }
        if (valueType == (int)ValueType.Vector2)
        {
            AnimatorTimeline.JSONVector2 v2 = new AnimatorTimeline.JSONVector2();
            v2.setValue(val_vect2);
            e.val_vect2 = v2;
        }
        if (valueType == (int)ValueType.Vector3)
        {
            AnimatorTimeline.JSONVector3 v3 = new AnimatorTimeline.JSONVector3();
            v3.setValue(val_vect3);
            e.val_vect3 = v3;
        }
        if (valueType == (int)ValueType.Vector4)
        {
            AnimatorTimeline.JSONVector4 v4 = new AnimatorTimeline.JSONVector4();
            v4.setValue(val_vect4);
            e.val_vect4 = v4;
        }
        if (valueType == (int)ValueType.Color)
        {
            AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor();
            c.setValue(val_color);
            e.val_color = c;
        }
        if (valueType == (int)ValueType.Rect)
        {
            AnimatorTimeline.JSONRect r = new AnimatorTimeline.JSONRect();
            r.setValue(val_rect);
            e.val_rect = r;
        }
        if (valueType == (int)ValueType.Object)
        {
            if (val_obj.GetType() != typeof(GameObject))
            {
                // component
                e.val_obj_extra = val_obj.name;
                e.val_obj       = val_obj.GetType().Name;
            }
            else
            {
                // gameobject
                e.val_obj_extra = null;
                e.val_obj       = val_obj.name;
            }
        }
        if (valueType == (int)ValueType.Array && lsArray.Count > 0)
        {
            AnimatorTimeline.JSONEventParameter[] arr = new AnimatorTimeline.JSONEventParameter[lsArray.Count];
            for (int i = 0; i < lsArray.Count; i++)
            {
                //arrObj[i] = lsArray[i].val_bool;
                arr[i] = lsArray[i].toJSON();
            }
            e.array = arr;

            /*
             * if(lsArray[0].valueType == (int) ValueType.Boolean) {
             *      //bool[] arrObj = new bool[lsArray.Count];
             * //				AnimatorTimeline.JSONEventParameter[] arr = new AnimatorTimeline.JSONEventParameter[lsArray.Count];
             * //				for(int i=0;i<lsArray.Count;i++){
             * //					//arrObj[i] = lsArray[i].val_bool;
             * //					arr[i] = lsArray[i].toJSON();
             * //				}
             *      //return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.String) {
             *      string[] arrObj = new string[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_string;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Char) {
             *      char[] arrObj = new char[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_string[0];
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Integer || lsArray[0].valueType == (int) ValueType.Long) {
             *      int[] arrObj = new int[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_int;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Float || lsArray[0].valueType == (int) ValueType.Double) {
             *      float[] arrObj = new float[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_float;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Vector2) {
             *      Vector2[] arrObj = new Vector2[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_vect2;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Vector3) {
             *      Vector3[] arrObj = new Vector3[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_vect3;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Vector4) {
             *      Vector4[] arrObj = new Vector4[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_vect4;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Color) {
             *      Color[] arrObj = new Color[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_color;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Rect) {
             *      Rect[] arrObj = new Rect[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_rect;
             *      }
             *      return arrObj;
             * }
             * if(lsArray[0].valueType == (int) ValueType.Object) {
             *      UnityEngine.Object[] arrObj = new UnityEngine.Object[lsArray.Count];
             *      for(int i=0;i<lsArray.Count;i++){
             *              arrObj[i] = lsArray[i].val_obj;
             *      }
             *      return arrObj;
             * }*/
        }
        //Debug.LogError("Animator: Type not found for Event Parameter.");
        return(e);
    }
Ejemplo n.º 6
0
    public override AnimatorTimeline.JSONInit getJSONInit()
    {
        if (!obj || keys.Count <= 0 || cache.Count <= 0)
        {
            return(null);
        }
        AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit();
        init.go = obj.gameObject.name;
        List <string> strings = new List <string>();

        strings.Add(component.GetType().Name);
        if (fieldInfo != null)
        {
            init.typeExtra = "fieldinfo";
            strings.Add(fieldInfo.Name);
        }
        else if (propertyInfo != null)
        {
            init.typeExtra = "propertyinfo";
            strings.Add(propertyInfo.Name);
        }
        else if (methodInfo != null)
        {
            init.typeExtra = "methodinfo";
            strings.Add(methodInfo.Name);
            // parameter types
            foreach (string s in methodParameterTypes)
            {
                strings.Add(s);
            }
        }
        if (valueType == (int)ValueType.MorphChannels)
        {
            init.type   = "propertymorph";
            init.floats = (cache[0] as AMPropertyAction).start_morph.ToArray();
        }
        else if (valueType == (int)ValueType.Integer)
        {
            init.type = "propertyint";
            init._int = Convert.ToInt32((cache[0] as AMPropertyAction).start_val);
        }
        else if (valueType == (int)ValueType.Long)
        {
            init.type  = "propertylong";
            init._long = Convert.ToInt64((cache[0] as AMPropertyAction).start_val);
        }
        else if (valueType == (int)ValueType.Float)
        {
            init.type   = "propertyfloat";
            init.floats = new float[] { Convert.ToSingle((cache[0] as AMPropertyAction).start_val) };
        }
        else if (valueType == (int)ValueType.Double)
        {
            init.type    = "propertydouble";
            init._double = (cache[0] as AMPropertyAction).start_val;
        }
        else if (valueType == (int)ValueType.Vector2)
        {
            init.type = "propertyvect2";
            AnimatorTimeline.JSONVector2 v2 = new AnimatorTimeline.JSONVector2();
            v2.setValue((cache[0] as AMPropertyAction).start_vect2);
            init._vect2 = v2;
        }
        else if (valueType == (int)ValueType.Vector3)
        {
            init.type = "propertyvect3";
            AnimatorTimeline.JSONVector3 v3 = new AnimatorTimeline.JSONVector3();
            v3.setValue((cache[0] as AMPropertyAction).start_vect3);
            init.position = v3;
        }
        else if (valueType == (int)ValueType.Color)
        {
            init.type = "propertycolor";
            AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor();
            c.setValue((cache[0] as AMPropertyAction).start_color);
            init._color = c;
        }
        else if (valueType == (int)ValueType.Rect)
        {
            init.type = "propertyrect";
            AnimatorTimeline.JSONRect r = new AnimatorTimeline.JSONRect();
            r.setValue((cache[0] as AMPropertyAction).start_rect);
            init._rect = r;
        }
        else
        {
            Debug.LogWarning("Animator: Error exporting JSON, unknown Property ValueType " + valueType);
            return(null);
        }
        init.strings = strings.ToArray();
        return(init);
    }
 public override AnimatorTimeline.JSONInit getJSONInit()
 {
     if(!obj || keys.Count <= 0) return null;
     AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit();
     init.type = "orientation";
     init.go = obj.gameObject.name;
     Transform _target = getInitialTarget();
     int start_frame = keys[0].frame;
     AMTrack _translation_track = null;
     if(start_frame > 0) _translation_track = parentTake.getTranslationTrackForTransform(_target);
     Vector3 _lookv3 = _target.transform.position;
     if(_translation_track) _lookv3 = (_translation_track as AMTranslationTrack).getPositionAtFrame(start_frame);
     AnimatorTimeline.JSONVector3 v = new AnimatorTimeline.JSONVector3();
     v.setValue(_lookv3);
     init.position = v;
     return init;
 }
Ejemplo n.º 8
0
    public virtual AnimatorTimeline.JSONEventParameter toJSON()
    {
        AnimatorTimeline.JSONEventParameter e = new AnimatorTimeline.JSONEventParameter();
        e.valueType = valueType;
        if(valueType == (int)ValueType.Boolean) e.val_bool = val_bool;
        if(valueType == (int)ValueType.String) e.val_string = (val_string/* as object*/);
        if(valueType == (int)ValueType.Char) {
            if(val_string == null || val_string.Length <= 0) e.val_string = "\0";
            e.val_string = "" + val_string[0];
        }
        if(valueType == (int)ValueType.Integer || valueType == (int)ValueType.Long) e.val_int = (val_int/* as object*/);
        if(valueType == (int)ValueType.Float || valueType == (int)ValueType.Double) e.val_float = (val_float/* as object*/);
        if(valueType == (int)ValueType.Vector2) {
            AnimatorTimeline.JSONVector2 v2 = new AnimatorTimeline.JSONVector2();
            v2.setValue(val_vect2);
            e.val_vect2 = v2;
        }
        if(valueType == (int)ValueType.Vector3) {
            AnimatorTimeline.JSONVector3 v3 = new AnimatorTimeline.JSONVector3();
            v3.setValue(val_vect3);
            e.val_vect3 = v3;
        }
        if(valueType == (int)ValueType.Vector4) {
            AnimatorTimeline.JSONVector4 v4 = new AnimatorTimeline.JSONVector4();
            v4.setValue(val_vect4);
            e.val_vect4 = v4;
        }
        if(valueType == (int)ValueType.Color) {
            AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor();
            c.setValue(val_color);
            e.val_color = c;
        }
        if(valueType == (int)ValueType.Rect) {
            AnimatorTimeline.JSONRect r = new AnimatorTimeline.JSONRect();
            r.setValue(val_rect);
            e.val_rect = r;
        }
        if(valueType == (int)ValueType.Object) {
            if(val_obj.GetType() != typeof(GameObject)) {
                // component
                e.val_obj_extra = val_obj.name;
                e.val_obj = val_obj.GetType().Name;
            }
            else {
                // gameobject
                e.val_obj_extra = null;
                e.val_obj = val_obj.name;
            }

        }
        //Debug.LogError("Animator: Type not found for Event Parameter.");
        return e;
    }
Ejemplo n.º 9
0
 public override AnimatorTimeline.JSONInit getJSONInit()
 {
     if(!obj || keys.Count <= 0 || cache.Count <= 0) return null;
     AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit();
     init.go = obj.gameObject.name;
     List<string> strings = new List<string>();
     strings.Add(component.GetType().Name);
     if(fieldInfo != null) {
         init.typeExtra = "fieldinfo";
         strings.Add(fieldInfo.Name);
     } else if(propertyInfo != null) {
         init.typeExtra = "propertyinfo";
         strings.Add(propertyInfo.Name);
     } else if(methodInfo != null) {
         init.typeExtra = "methodinfo";
         strings.Add(methodInfo.Name);
         // parameter types
         foreach(string s in methodParameterTypes) {
             strings.Add(s);
         }
     }
     if(valueType == (int)ValueType.MorphChannels) {
         init.type = "propertymorph";
         init.floats = (cache[0] as AMPropertyAction).start_morph.ToArray();
     } else if(valueType == (int)ValueType.Integer) {
         init.type = "propertyint";
         init._int = Convert.ToInt32((cache[0] as AMPropertyAction).start_val);
     } else if(valueType == (int)ValueType.Long) {
         init.type = "propertylong";
         init._long = Convert.ToInt64((cache[0] as AMPropertyAction).start_val);
     } else if(valueType == (int)ValueType.Float) {
         init.type = "propertyfloat";
         init.floats = new float[]{Convert.ToSingle((cache[0] as AMPropertyAction).start_val)};
     } else if(valueType == (int)ValueType.Double) {
         init.type = "propertydouble";
         init._double = (cache[0] as AMPropertyAction).start_val;
     } else if(valueType == (int)ValueType.Vector2) {
         init.type = "propertyvect2";
         AnimatorTimeline.JSONVector2 v2 = new AnimatorTimeline.JSONVector2();
         v2.setValue((cache[0] as AMPropertyAction).start_vect2);
         init._vect2 = v2;
     } else if(valueType == (int)ValueType.Vector3) {
         init.type = "propertyvect3";
         AnimatorTimeline.JSONVector3 v3 = new AnimatorTimeline.JSONVector3();
         v3.setValue((cache[0] as AMPropertyAction).start_vect3);
         init.position = v3;
     } else if(valueType == (int)ValueType.Color) {
         init.type = "propertycolor";
         AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor();
         c.setValue((cache[0] as AMPropertyAction).start_color);
         init._color = c;
     } else if(valueType == (int)ValueType.Rect) {
         init.type = "propertyrect";
         AnimatorTimeline.JSONRect r = new AnimatorTimeline.JSONRect();
         r.setValue((cache[0] as AMPropertyAction).start_rect);
         init._rect = r;
     } else {
         Debug.LogWarning("Animator: Error exporting JSON, unknown Property ValueType "+valueType);
         return null;
     }
     init.strings = strings.ToArray();
     return init;
 }