Example #1
0
        public override AnimatorTimeline.JSONEventParameter toJSON()
        {
            if(valueType == (int)ValueType.Array && lsArray.Count > 0) {
                AnimatorTimeline.JSONEventParameter e = new AnimatorTimeline.JSONEventParameter();
                e.valueType = valueType;
                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;
                }*/
                return e;
            }

            return base.toJSON();
        }
Example #2
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;
        }