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); }
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 override AnimatorTimeline.JSONInit getJSONInit() { if (!obj || keys.Count <= 0) { return(null); } AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit(); init.type = "rotation"; init.go = obj.gameObject.name; AnimatorTimeline.JSONQuaternion q = new AnimatorTimeline.JSONQuaternion(); q.setValue(getInitialRotation()); init.rotation = q; return(init); }
// JSON void exportJSON() { string takeName = aData.getCurrentTake().name; string saveJSONPath = EditorUtility.SaveFilePanel("Save JSON", "Assets/", takeName, "txt"); if (saveJSONPath == "") { return; } // start serialization AnimatorTimeline.JSONTake j = new AnimatorTimeline.JSONTake(); j.takeName = aData.getCurrentTake().name; List <AnimatorTimeline.JSONInit> lsInits = new List <AnimatorTimeline.JSONInit>(); List <AnimatorTimeline.JSONAction> lsActions = new List <AnimatorTimeline.JSONAction>(); foreach (AMTrack track in aData.getCurrentTake().trackValues) { if (dictTracks.ContainsKey(track.id) && dictTracks[track.id] == true) { // set initial values AnimatorTimeline.JSONInit init = track.getJSONInit(); if (init != null) { lsInits.Add(init); } // set actions foreach (AMAction action in track.cache) { AnimatorTimeline.JSONAction a = action.getJSONAction(aData.getCurrentTake().frameRate); if (a != null) { lsActions.Add(a); } } } } j.inits = lsInits.ToArray(); j.actions = lsActions.ToArray(); // serialize json string json = JsonWriter.Serialize(j); // write json to file File.WriteAllText(saveJSONPath, json); // refresh project directory AssetDatabase.Refresh(); // refresh code refreshCode(); }
public override AnimatorTimeline.JSONInit getJSONInit() { if (keys.Count <= 0) { return(null); } string _type; if ((keys[0] as AMCameraSwitcherKey).type == 0) { if ((keys[0] as AMCameraSwitcherKey).camera == null) { return(null); } _type = "camera"; } else { _type = "color"; } AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit(); init.type = "cameraswitcher"; init.typeExtra = _type; if (_type == "camera") { init.go = (keys[0] as AMCameraSwitcherKey).camera.gameObject.name; } else { AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor(); c.setValue((keys[0] as AMCameraSwitcherKey).color); init._color = c; } // all cameras Camera[] cameras = getAllCameras(); init.strings = new string[cameras.Length]; for (int i = 0; i < cameras.Length; i++) { init.strings[i] = cameras[i].gameObject.name; } // all textures /*Texture[] textures = getAllTextures(); * init.stringsExtra = new string[textures.Length]; * for(int i=0; i<textures.Length;i++) { * init.stringsExtra[i] = textures[i].name; * }*/ return(init); }
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 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 = "rotation"; init.go = _obj.gameObject.name; AnimatorTimeline.JSONQuaternion q = new AnimatorTimeline.JSONQuaternion(); q.setValue(getInitialRotation()); init.rotation = q; return init; }
public override AnimatorTimeline.JSONInit getJSONInit() { if(keys.Count <= 0) return null; string _type; if((keys[0] as AMCameraSwitcherKey).type == 0) { if((keys[0] as AMCameraSwitcherKey).camera == null) return null; _type = "camera"; } else { _type = "color"; } AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit(); init.type = "cameraswitcher"; init.typeExtra = _type; if(_type == "camera") init.go = (keys[0] as AMCameraSwitcherKey).camera.gameObject.name; else { AnimatorTimeline.JSONColor c = new AnimatorTimeline.JSONColor(); c.setValue((keys[0] as AMCameraSwitcherKey).color); init._color = c; } // all cameras Camera[] cameras = getAllCameras(); init.strings = new string[cameras.Length]; for(int i=0; i<cameras.Length;i++) { init.strings[i] = cameras[i].gameObject.name; } // all textures /*Texture[] textures = getAllTextures(); init.stringsExtra = new string[textures.Length]; for(int i=0; i<textures.Length;i++) { init.stringsExtra[i] = textures[i].name; }*/ 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; }
public override AnimatorTimeline.JSONInit getJSONInit(AMITarget target) { if(!_obj || keys.Count <= 0) return null; AnimatorTimeline.JSONInit init = new AnimatorTimeline.JSONInit(); init.type = "rotation"; init.go = _obj.gameObject.name; AnimatorTimeline.JSONQuaternion q = new AnimatorTimeline.JSONQuaternion(); Quaternion quat = getInitialRotation(); q.setValue(new Vector4(quat.x, quat.y, quat.z, quat.w)); init.rotation = q; return init; }
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; }