1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420 |
- using System;
- using System.Collections.Generic;
- using System.Reflection;
- using System.Runtime.CompilerServices;
- using UnityEngine;
- [Serializable]
- public class AMPropertyTrack : AMTrack
- {
- public PropertyInfo propertyInfo
- {
- get
- {
- if (this.cachedPropertyInfo != null)
- {
- return this.cachedPropertyInfo;
- }
- if (!this.obj || !this.component || this.propertyName == null)
- {
- return null;
- }
- this.cachedPropertyInfo = this.component.GetType().GetProperty(this.propertyName);
- return this.cachedPropertyInfo;
- }
- set
- {
- if (value != null)
- {
- this.propertyName = value.Name;
- }
- else
- {
- this.propertyName = null;
- }
- this.cachedPropertyInfo = value;
- }
- }
- public FieldInfo fieldInfo
- {
- get
- {
- if (this.cachedFieldInfo != null)
- {
- return this.cachedFieldInfo;
- }
- if (!this.obj || !this.component || this.fieldName == null)
- {
- return null;
- }
- this.cachedFieldInfo = this.component.GetType().GetField(this.fieldName);
- return this.cachedFieldInfo;
- }
- set
- {
- if (value != null)
- {
- this.fieldName = value.Name;
- }
- else
- {
- this.fieldName = null;
- }
- this.cachedFieldInfo = value;
- }
- }
- public MethodInfo methodInfo
- {
- get
- {
- if (this.cachedMethodInfo != null)
- {
- return this.cachedMethodInfo;
- }
- if (!this.obj || !this.component || this.methodName == null)
- {
- return null;
- }
- Type[] array = new Type[this.methodParameterTypes.Length];
- for (int i = 0; i < this.methodParameterTypes.Length; i++)
- {
- array[i] = Type.GetType(this.methodParameterTypes[i]);
- }
- this.cachedMethodInfo = this.component.GetType().GetMethod(this.methodName, array);
- return this.cachedMethodInfo;
- }
- set
- {
- if (value != null)
- {
- this.methodName = value.Name;
- }
- else
- {
- this.methodName = null;
- }
- this.cachedMethodInfo = value;
- }
- }
- public MethodInfo methodInfoMorphNames
- {
- get
- {
- if (this.cachedMethodInfoMorphNames != null)
- {
- return this.cachedMethodInfoMorphNames;
- }
- if (!this.obj || !this.component || this.valueType != 8)
- {
- return null;
- }
- this.cachedMethodInfoMorphNames = this.component.GetType().GetMethod("GetChannelNames");
- return this.cachedMethodInfo;
- }
- }
- public override string getTrackType()
- {
- if (this.fieldInfo != null)
- {
- return this.fieldInfo.Name;
- }
- if (this.propertyInfo != null)
- {
- return this.propertyInfo.Name;
- }
- if (this.methodInfo != null && this.valueType == 8)
- {
- return "Morph";
- }
- return "Not Set";
- }
- public string getMemberInfoTypeName()
- {
- if (this.fieldInfo != null)
- {
- return "FieldInfo";
- }
- if (this.propertyInfo != null)
- {
- return "PropertyInfo";
- }
- if (this.methodInfo != null)
- {
- return "MethodInfo";
- }
- return "Undefined";
- }
- public bool isPropertySet()
- {
- return this.fieldInfo != null || this.propertyInfo != null || (this.methodInfo != null && this.valueType == 8);
- }
- public void addKey(int _frame)
- {
- if (AMPropertyTrack.isValueTypeNumeric(this.valueType))
- {
- this.addKey(_frame, this.getPropertyValueNumeric());
- }
- else if (this.valueType == 4)
- {
- this.addKey(_frame, this.getPropertyValueVector2());
- }
- else if (this.valueType == 5)
- {
- this.addKey(_frame, this.getPropertyValueVector3());
- }
- else if (this.valueType == 6)
- {
- this.addKey(_frame, this.getPropertyValueColor());
- }
- else if (this.valueType == 7)
- {
- this.addKey(_frame, this.getPropertyValueRect());
- }
- else if (this.valueType == 8)
- {
- this.addKeyMegaMorph(_frame, new List<float>());
- }
- else
- {
- Debug.LogError("Animator: Invalid ValueType " + this.valueType.ToString());
- }
- }
- public void addKeyMegaMorph(int _frame, List<float> channels)
- {
- foreach (AMKey amkey in this.keys)
- {
- AMPropertyKey ampropertyKey = (AMPropertyKey)amkey;
- if (ampropertyKey.frame == _frame)
- {
- ampropertyKey.setValueMegaMorph(channels);
- this.updateCache();
- return;
- }
- }
- AMPropertyKey ampropertyKey2 = ScriptableObject.CreateInstance<AMPropertyKey>();
- ampropertyKey2.frame = _frame;
- ampropertyKey2.setValueMegaMorph(channels);
- ampropertyKey2.easeType = 14;
- this.keys.Add(ampropertyKey2);
- this.updateCache();
- }
- public void addKey(int _frame, double val)
- {
- foreach (AMKey amkey in this.keys)
- {
- AMPropertyKey ampropertyKey = (AMPropertyKey)amkey;
- if (ampropertyKey.frame == _frame)
- {
- ampropertyKey.setValue(val);
- this.updateCache();
- return;
- }
- }
- AMPropertyKey ampropertyKey2 = ScriptableObject.CreateInstance<AMPropertyKey>();
- ampropertyKey2.frame = _frame;
- ampropertyKey2.setValue(val);
- ampropertyKey2.easeType = 21;
- this.keys.Add(ampropertyKey2);
- this.updateCache();
- }
- public void addKey(int _frame, Vector2 val)
- {
- foreach (AMKey amkey in this.keys)
- {
- AMPropertyKey ampropertyKey = (AMPropertyKey)amkey;
- if (ampropertyKey.frame == _frame)
- {
- ampropertyKey.setValue(val);
- this.updateCache();
- return;
- }
- }
- AMPropertyKey ampropertyKey2 = ScriptableObject.CreateInstance<AMPropertyKey>();
- ampropertyKey2.frame = _frame;
- ampropertyKey2.setValue(val);
- ampropertyKey2.easeType = 21;
- this.keys.Add(ampropertyKey2);
- this.updateCache();
- }
- public void addKey(int _frame, Vector3 val)
- {
- foreach (AMKey amkey in this.keys)
- {
- AMPropertyKey ampropertyKey = (AMPropertyKey)amkey;
- if (ampropertyKey.frame == _frame)
- {
- ampropertyKey.setValue(val);
- this.updateCache();
- return;
- }
- }
- AMPropertyKey ampropertyKey2 = ScriptableObject.CreateInstance<AMPropertyKey>();
- ampropertyKey2.frame = _frame;
- ampropertyKey2.setValue(val);
- ampropertyKey2.easeType = 21;
- this.keys.Add(ampropertyKey2);
- this.updateCache();
- }
- public void addKey(int _frame, Color val)
- {
- foreach (AMKey amkey in this.keys)
- {
- AMPropertyKey ampropertyKey = (AMPropertyKey)amkey;
- if (ampropertyKey.frame == _frame)
- {
- ampropertyKey.setValue(val);
- this.updateCache();
- return;
- }
- }
- AMPropertyKey ampropertyKey2 = ScriptableObject.CreateInstance<AMPropertyKey>();
- ampropertyKey2.frame = _frame;
- ampropertyKey2.setValue(val);
- ampropertyKey2.easeType = 21;
- this.keys.Add(ampropertyKey2);
- this.updateCache();
- }
- public void addKey(int _frame, Rect val)
- {
- foreach (AMKey amkey in this.keys)
- {
- AMPropertyKey ampropertyKey = (AMPropertyKey)amkey;
- if (ampropertyKey.frame == _frame)
- {
- ampropertyKey.setValue(val);
- this.updateCache();
- return;
- }
- }
- AMPropertyKey ampropertyKey2 = ScriptableObject.CreateInstance<AMPropertyKey>();
- ampropertyKey2.frame = _frame;
- ampropertyKey2.setValue(val);
- ampropertyKey2.easeType = 21;
- this.keys.Add(ampropertyKey2);
- this.updateCache();
- }
- public bool isObjectUnique(GameObject obj)
- {
- return this.obj != obj;
- }
- public bool changeObject(GameObject obj)
- {
- NDebug.Assert(this.componentName != null, "AMPropertyTrackに対象コンポーネント名が設定されていません。");
- Component component = obj.GetComponent(this.componentName);
- string text = this.propertyName;
- string text2 = this.fieldName;
- string value = this.methodName;
- if (component == null)
- {
- NDebug.Assert(string.Concat(new string[]
- {
- "AMPropertyTrackへ新しいオブジェクトへ置換しようとしましたが、同じ",
- this.componentName,
- "コンポーネントが",
- obj.name,
- "にはありませんでした。"
- }), false);
- }
- this.setObject(obj);
- this.setComponent(component);
- if (!string.IsNullOrEmpty(text))
- {
- PropertyInfo[] properties = component.GetType().GetProperties();
- foreach (PropertyInfo propertyInfo in properties)
- {
- if (propertyInfo.PropertyType != typeof(HideFlags))
- {
- if (propertyInfo.CanWrite && AMPropertyTrack.isValidType(propertyInfo.PropertyType) && propertyInfo.Name == text)
- {
- this.setPropertyInfo(propertyInfo);
- break;
- }
- }
- }
- }
- if (!string.IsNullOrEmpty(text2))
- {
- FieldInfo[] fields = component.GetType().GetFields();
- foreach (FieldInfo fieldInfo in fields)
- {
- if (AMPropertyTrack.isValidType(fieldInfo.FieldType))
- {
- if (fieldInfo.Name == text2)
- {
- this.setFieldInfo(fieldInfo);
- break;
- }
- }
- }
- }
- if (!string.IsNullOrEmpty(value))
- {
- NDebug.Assert("メソッドの置換(MegaMorph)には対応しておりません。", false);
- }
- this.updateCache();
- return false;
- }
- public bool setObject(GameObject obj)
- {
- if (this.obj != obj)
- {
- this.obj = obj;
- this.objName = obj.name;
- this.fieldInfo = null;
- this.fieldName = null;
- this.propertyInfo = null;
- this.propertyName = null;
- this.methodInfo = null;
- this.methodName = null;
- return true;
- }
- return false;
- }
- public bool setComponent(Component component)
- {
- if (this.component != component)
- {
- this.component = component;
- this.componentName = component.GetType().Name;
- return true;
- }
- return false;
- }
- public bool setPropertyInfo(PropertyInfo propertyInfo)
- {
- if (this.propertyInfo != propertyInfo)
- {
- this.setValueType(propertyInfo.PropertyType);
- this.propertyInfo = propertyInfo;
- this.fieldInfo = null;
- this.fieldName = null;
- return true;
- }
- return false;
- }
- public bool setFieldInfo(FieldInfo fieldInfo)
- {
- if (this.fieldInfo != fieldInfo)
- {
- this.setValueType(fieldInfo.FieldType);
- this.fieldInfo = fieldInfo;
- this.propertyInfo = null;
- this.propertyName = null;
- return true;
- }
- return false;
- }
- public bool setMethodInfo(MethodInfo methodInfo, string[] parameterTypes, AMPropertyTrack.ValueType valueType)
- {
- if (this.valueType != (int)valueType || this.methodParameterTypes != parameterTypes || this.methodInfo != methodInfo)
- {
- this.setValueType((int)valueType);
- this.methodParameterTypes = parameterTypes;
- this.methodInfo = methodInfo;
- this.propertyInfo = null;
- this.propertyName = null;
- this.fieldInfo = null;
- this.fieldName = null;
- return true;
- }
- return false;
- }
- public override void updateCache()
- {
- this.objName = this.obj.name;
- this.componentName = this.component.GetType().Name;
- base.sortKeys();
- base.destroyCache();
- this.cache = new List<AMAction>();
- for (int i = 0; i < this.keys.Count; i++)
- {
- AMPropertyAction ampropertyAction = ScriptableObject.CreateInstance<AMPropertyAction>();
- ampropertyAction.component = this.component;
- ampropertyAction.componentName = this.component.GetType().Name;
- ampropertyAction.startFrame = this.keys[i].frame;
- if (this.keys.Count > i + 1)
- {
- ampropertyAction.endFrame = this.keys[i + 1].frame;
- }
- else
- {
- ampropertyAction.endFrame = -1;
- }
- ampropertyAction.valueType = this.valueType;
- Type type = null;
- bool flag = true;
- int num = -1;
- if (this.fieldInfo != null)
- {
- ampropertyAction.fieldInfo = this.fieldInfo;
- type = this.fieldInfo.FieldType;
- flag = false;
- }
- else if (this.propertyInfo != null)
- {
- ampropertyAction.propertyInfo = this.propertyInfo;
- type = this.propertyInfo.PropertyType;
- flag = false;
- }
- else if (this.methodInfo != null)
- {
- ampropertyAction.methodInfo = this.methodInfo;
- ampropertyAction.methodParameterTypes = this.methodParameterTypes;
- if (this.valueType == 8)
- {
- num = 8;
- flag = false;
- }
- }
- if (flag)
- {
- Debug.LogError("Animator: Fatal Error; fieldInfo, propertyInfo and methodInfo are unset for Value Type " + this.valueType);
- ampropertyAction.destroy();
- return;
- }
- if (num == 8)
- {
- ampropertyAction.start_morph = new List<float>((this.keys[i] as AMPropertyKey).morph);
- if (ampropertyAction.endFrame != -1)
- {
- ampropertyAction.end_morph = new List<float>((this.keys[i + 1] as AMPropertyKey).morph);
- }
- }
- else if (AMPropertyTrack.isNumeric(type))
- {
- ampropertyAction.start_val = (this.keys[i] as AMPropertyKey).val;
- if (ampropertyAction.endFrame != -1)
- {
- ampropertyAction.end_val = (this.keys[i + 1] as AMPropertyKey).val;
- }
- }
- else if (type == typeof(Vector2))
- {
- ampropertyAction.start_vect2 = (this.keys[i] as AMPropertyKey).vect2;
- if (ampropertyAction.endFrame != -1)
- {
- ampropertyAction.end_vect2 = (this.keys[i + 1] as AMPropertyKey).vect2;
- }
- }
- else if (type == typeof(Vector3))
- {
- ampropertyAction.start_vect3 = (this.keys[i] as AMPropertyKey).vect3;
- if (ampropertyAction.endFrame != -1)
- {
- ampropertyAction.end_vect3 = (this.keys[i + 1] as AMPropertyKey).vect3;
- }
- }
- else if (type == typeof(Color))
- {
- ampropertyAction.start_color = (this.keys[i] as AMPropertyKey).color;
- if (ampropertyAction.endFrame != -1)
- {
- ampropertyAction.end_color = (this.keys[i + 1] as AMPropertyKey).color;
- }
- }
- else
- {
- if (type != typeof(Rect))
- {
- Debug.LogError("Animator: Fatal Error, property type '" + type.ToString() + "' not found.");
- ampropertyAction.destroy();
- return;
- }
- ampropertyAction.start_rect = (this.keys[i] as AMPropertyKey).rect;
- if (ampropertyAction.endFrame != -1)
- {
- ampropertyAction.end_rect = (this.keys[i + 1] as AMPropertyKey).rect;
- }
- }
- ampropertyAction.easeType = (this.keys[i] as AMPropertyKey).easeType;
- ampropertyAction.customEase = new List<float>(this.keys[i].customEase);
- this.cache.Add(ampropertyAction);
- }
- base.updateCache();
- }
- public double getPropertyValueNumeric()
- {
- if (this.fieldInfo != null)
- {
- return Convert.ToDouble(this.fieldInfo.GetValue(this.component));
- }
- return Convert.ToDouble(this.propertyInfo.GetValue(this.component, null));
- }
- public Vector2 getPropertyValueVector2()
- {
- if (this.fieldInfo != null)
- {
- return (Vector2)this.fieldInfo.GetValue(this.component);
- }
- return (Vector2)this.propertyInfo.GetValue(this.component, null);
- }
- public Vector3 getPropertyValueVector3()
- {
- if (this.fieldInfo != null)
- {
- return (Vector3)this.fieldInfo.GetValue(this.component);
- }
- return (Vector3)this.propertyInfo.GetValue(this.component, null);
- }
- public Color getPropertyValueColor()
- {
- if (this.fieldInfo != null)
- {
- return (Color)this.fieldInfo.GetValue(this.component);
- }
- return (Color)this.propertyInfo.GetValue(this.component, null);
- }
- public Rect getPropertyValueRect()
- {
- if (this.fieldInfo != null)
- {
- return (Rect)this.fieldInfo.GetValue(this.component);
- }
- return (Rect)this.propertyInfo.GetValue(this.component, null);
- }
- public static bool isNumeric(Type t)
- {
- return t == typeof(int) || t == typeof(long) || t == typeof(float) || t == typeof(double);
- }
- public static bool isValidType(Type t)
- {
- return t == typeof(int) || t == typeof(long) || t == typeof(float) || t == typeof(double) || t == typeof(Vector2) || t == typeof(Vector3) || t == typeof(Color) || t == typeof(Rect);
- }
- public void setValueType(int type)
- {
- this.valueType = type;
- }
- public void setValueType(Type t)
- {
- if (t == typeof(int))
- {
- this.valueType = 0;
- }
- else if (t == typeof(long))
- {
- this.valueType = 1;
- }
- else if (t == typeof(float))
- {
- this.valueType = 2;
- }
- else if (t == typeof(double))
- {
- this.valueType = 3;
- }
- else if (t == typeof(Vector2))
- {
- this.valueType = 4;
- }
- else if (t == typeof(Vector3))
- {
- this.valueType = 5;
- }
- else if (t == typeof(Color))
- {
- this.valueType = 6;
- }
- else if (t == typeof(Rect))
- {
- this.valueType = 7;
- }
- else
- {
- this.valueType = -1;
- Debug.LogWarning("Animator: Value type " + t.ToString() + " is unsupported.");
- }
- }
- public void previewFrame(float frame, bool quickPreview = false)
- {
- if (this.cache == null || this.cache.Count <= 0)
- {
- return;
- }
- if (!this.component || !this.obj)
- {
- return;
- }
- this.componentName = this.component.GetType().Name;
- if (string.IsNullOrEmpty(this.objName))
- {
- this.objName = this.obj.name;
- }
- int num = 0;
- if (frame <= (float)this.cache[0].startFrame || (this.cache[0] as AMPropertyAction).endFrame == -1)
- {
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, (this.cache[0] as AMPropertyAction).getStartValue());
- this.refreshTransform();
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, (this.cache[0] as AMPropertyAction).getStartValue(), null);
- this.refreshTransform();
- }
- else if (this.methodInfo != null)
- {
- try
- {
- string[] morphNames = this.getMorphNames();
- num = morphNames.Length;
- }
- catch
- {
- }
- this.previewMorph((this.cache[0] as AMPropertyAction).start_morph, num);
- }
- return;
- }
- if (frame >= (float)(this.cache[this.cache.Count - 2] as AMPropertyAction).endFrame)
- {
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, (this.cache[this.cache.Count - 2] as AMPropertyAction).getEndValue());
- this.refreshTransform();
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, (this.cache[this.cache.Count - 2] as AMPropertyAction).getEndValue(), null);
- this.refreshTransform();
- }
- else if (this.methodInfo != null)
- {
- string[] morphNames2 = this.getMorphNames();
- num = morphNames2.Length;
- this.previewMorph((this.cache[this.cache.Count - 2] as AMPropertyAction).end_morph, num);
- }
- return;
- }
- foreach (AMAction amaction in this.cache)
- {
- AMPropertyAction ampropertyAction = (AMPropertyAction)amaction;
- if (frame >= (float)ampropertyAction.startFrame && frame <= (float)ampropertyAction.endFrame)
- {
- if (quickPreview && !ampropertyAction.targetsAreEqual())
- {
- break;
- }
- if (frame == (float)ampropertyAction.startFrame)
- {
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, ampropertyAction.getStartValue());
- this.refreshTransform();
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, ampropertyAction.getStartValue(), null);
- this.refreshTransform();
- }
- else if (this.methodInfo != null)
- {
- string[] morphNames3 = this.getMorphNames();
- num = morphNames3.Length;
- this.previewMorph(ampropertyAction.start_morph, num);
- }
- break;
- }
- if (frame == (float)ampropertyAction.endFrame)
- {
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, ampropertyAction.getEndValue());
- this.refreshTransform();
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, ampropertyAction.getEndValue(), null);
- this.refreshTransform();
- }
- else if (this.methodInfo != null)
- {
- string[] morphNames4 = this.getMorphNames();
- num = morphNames4.Length;
- this.previewMorph(ampropertyAction.end_morph, num);
- }
- break;
- }
- AnimationCurve curve = null;
- AMTween.EasingFunction easingFunction;
- if (ampropertyAction.hasCustomEase())
- {
- if (AMPropertyTrack.<>f__mg$cache0 == null)
- {
- AMPropertyTrack.<>f__mg$cache0 = new AMTween.EasingFunction(AMTween.customEase);
- }
- easingFunction = AMPropertyTrack.<>f__mg$cache0;
- curve = ampropertyAction.easeCurve;
- }
- else
- {
- easingFunction = AMTween.GetEasingFunction((AMTween.EaseType)ampropertyAction.easeType);
- }
- float num2 = frame - (float)ampropertyAction.startFrame;
- if (num2 < 0f)
- {
- num2 = 0f;
- }
- float value = num2 / (float)ampropertyAction.getNumberOfFrames();
- if (ampropertyAction.valueType == 8)
- {
- string[] morphNames5 = this.getMorphNames();
- num = morphNames5.Length;
- List<float> list = new List<float>();
- for (int i = 0; i < num; i++)
- {
- if (ampropertyAction.start_morph.Count <= i || ampropertyAction.end_morph.Count <= i)
- {
- break;
- }
- list.Add(0f);
- list[i] = easingFunction(ampropertyAction.start_morph[i], ampropertyAction.end_morph[i], value, curve);
- }
- this.previewMorph(list, num);
- }
- else if (ampropertyAction.valueType == 0)
- {
- float start = Convert.ToSingle(ampropertyAction.start_val);
- float end = Convert.ToSingle(ampropertyAction.end_val);
- int num3 = (int)easingFunction(start, end, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, num3);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, num3, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 1)
- {
- float start2 = Convert.ToSingle(ampropertyAction.start_val);
- float end2 = Convert.ToSingle(ampropertyAction.end_val);
- long num4 = (long)easingFunction(start2, end2, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, num4);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, num4, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 2)
- {
- float start3 = Convert.ToSingle(ampropertyAction.start_val);
- float end3 = Convert.ToSingle(ampropertyAction.end_val);
- float num5 = easingFunction(start3, end3, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, num5);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, num5, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 3)
- {
- float start4 = Convert.ToSingle(ampropertyAction.start_val);
- float end4 = Convert.ToSingle(ampropertyAction.end_val);
- double num6 = (double)easingFunction(start4, end4, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, num6);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, num6, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 4)
- {
- Vector2 start_vect = ampropertyAction.start_vect2;
- Vector2 end_vect = ampropertyAction.end_vect2;
- Vector2 vector = default(Vector2);
- vector.x = easingFunction(start_vect.x, end_vect.x, value, curve);
- vector.y = easingFunction(start_vect.y, end_vect.y, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, vector);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, vector, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 5)
- {
- Vector3 start_vect2 = ampropertyAction.start_vect3;
- Vector3 end_vect2 = ampropertyAction.end_vect3;
- Vector3 vector2 = default(Vector3);
- vector2.x = easingFunction(start_vect2.x, end_vect2.x, value, curve);
- vector2.y = easingFunction(start_vect2.y, end_vect2.y, value, curve);
- vector2.z = easingFunction(start_vect2.z, end_vect2.z, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, vector2);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, vector2, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 6)
- {
- Color start_color = ampropertyAction.start_color;
- Color end_color = ampropertyAction.end_color;
- Color color = default(Color);
- color.r = easingFunction(start_color.r, end_color.r, value, curve);
- color.g = easingFunction(start_color.g, end_color.g, value, curve);
- color.b = easingFunction(start_color.b, end_color.b, value, curve);
- color.a = easingFunction(start_color.a, end_color.a, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, color);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, color, null);
- }
- this.refreshTransform();
- }
- else if (ampropertyAction.valueType == 7)
- {
- Rect start_rect = ampropertyAction.start_rect;
- Rect end_rect = ampropertyAction.end_rect;
- Rect rect = default(Rect);
- rect.x = easingFunction(start_rect.x, end_rect.x, value, curve);
- rect.y = easingFunction(start_rect.y, end_rect.y, value, curve);
- rect.width = easingFunction(start_rect.width, end_rect.width, value, curve);
- rect.height = easingFunction(start_rect.height, end_rect.height, value, curve);
- if (this.fieldInfo != null)
- {
- this.fieldInfo.SetValue(this.component, rect);
- }
- else if (this.propertyInfo != null)
- {
- this.propertyInfo.SetValue(this.component, rect, null);
- }
- this.refreshTransform();
- }
- else
- {
- Debug.LogError("Animator: Invalid ValueType " + this.valueType.ToString());
- }
- break;
- }
- }
- }
- public void refreshTransform()
- {
- if (Application.isPlaying || !this.obj)
- {
- return;
- }
- this.obj.transform.position = new Vector3(this.obj.transform.position.x, this.obj.transform.position.y, this.obj.transform.position.z);
- }
- public void previewMorph(List<float> morph, int count)
- {
- if (this.valueType == 8)
- {
- this.parentTake.addMorph(this.obj, this.methodInfo, this.component, morph);
- }
- }
- public string getComponentName()
- {
- if (this.fieldInfo != null)
- {
- return this.fieldInfo.DeclaringType.Name;
- }
- if (this.propertyInfo != null)
- {
- return this.propertyInfo.DeclaringType.Name;
- }
- if (this.methodInfo != null && this.valueType == 8)
- {
- return "Morph";
- }
- return "Unknown";
- }
- public string getValueInitialization(int codeLanguage, string varName)
- {
- string text = string.Empty;
- if (this.valueType == 8)
- {
- string text2 = text;
- return string.Concat(new string[]
- {
- text2,
- "AMTween.SetMorph(",
- varName,
- ", ",
- varName,
- "Property, ",
- (this.cache[0] as AMPropertyAction).getFloatArrayString(codeLanguage, (this.cache[0] as AMPropertyAction).start_morph),
- ");"
- });
- }
- text = text + varName + "Property.";
- if (this.methodInfo != null)
- {
- text = text + "Invoke(" + varName + ", ";
- if (codeLanguage == 0)
- {
- text += "new object[]{";
- }
- else
- {
- text += "[";
- }
- }
- else
- {
- text = text + "SetValue(" + varName + ", ";
- }
- if (this.valueType == 0)
- {
- float num = Convert.ToSingle((this.cache[0] as AMPropertyAction).start_val);
- text += num;
- }
- else if (this.valueType == 1)
- {
- float num2 = Convert.ToSingle((this.cache[0] as AMPropertyAction).start_val);
- text += num2;
- }
- else if (this.valueType == 2)
- {
- float num3 = Convert.ToSingle((this.cache[0] as AMPropertyAction).start_val);
- text += num3;
- if (codeLanguage == 0)
- {
- text += "f";
- }
- }
- else if (this.valueType == 3)
- {
- float num4 = Convert.ToSingle((this.cache[0] as AMPropertyAction).start_val);
- text += num4;
- if (codeLanguage == 0)
- {
- text += "f";
- }
- }
- else if (this.valueType == 4)
- {
- Vector2 start_vect = (this.cache[0] as AMPropertyAction).start_vect2;
- if (codeLanguage == 0)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "new Vector2(",
- start_vect.x,
- "f, ",
- start_vect.y,
- "f)"
- });
- }
- else
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "Vector2(",
- start_vect.x,
- ", ",
- start_vect.y,
- ")"
- });
- }
- }
- else if (this.valueType == 5)
- {
- Vector3 start_vect2 = (this.cache[0] as AMPropertyAction).start_vect3;
- if (codeLanguage == 0)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "new Vector3(",
- start_vect2.x,
- "f, ",
- start_vect2.y,
- "f, ",
- start_vect2.z,
- "f)"
- });
- }
- else
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "Vector3(",
- start_vect2.x,
- ", ",
- start_vect2.y,
- ", ",
- start_vect2.z,
- ")"
- });
- }
- }
- else if (this.valueType == 6)
- {
- Color start_color = (this.cache[0] as AMPropertyAction).start_color;
- if (codeLanguage == 0)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "new Color(",
- start_color.r,
- "f, ",
- start_color.g,
- "f, ",
- start_color.b,
- "f, ",
- start_color.a,
- "f)"
- });
- }
- else
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "Color(",
- start_color.r,
- ", ",
- start_color.g,
- ", ",
- start_color.b,
- ", ",
- start_color.a,
- ")"
- });
- }
- }
- else if (this.valueType == 7)
- {
- Rect start_rect = (this.cache[0] as AMPropertyAction).start_rect;
- if (codeLanguage == 0)
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "new Rect(",
- start_rect.x,
- "f, ",
- start_rect.y,
- "f, ",
- start_rect.width,
- "f, ",
- start_rect.height,
- "f)"
- });
- }
- else
- {
- string text2 = text;
- text = string.Concat(new object[]
- {
- text2,
- "Rect(",
- start_rect.x,
- ", ",
- start_rect.y,
- ", ",
- start_rect.width,
- ", ",
- start_rect.height,
- ")"
- });
- }
- }
- if (this.propertyInfo != null)
- {
- text += ", null";
- }
- else if (this.methodInfo != null)
- {
- if (codeLanguage == 0)
- {
- text += "}";
- }
- else
- {
- text += "]";
- }
- }
- return text + ");";
- }
- public static bool isValueTypeNumeric(int valueType)
- {
- return valueType == 0 || valueType == 1 || valueType == 2 || valueType == 3;
- }
- public bool hasSamePropertyAs(AMPropertyTrack _track)
- {
- return _track.obj == this.obj && _track.component == this.component && _track.getTrackType() == this.getTrackType();
- }
- public string[] getMorphNames()
- {
- if (!this.component || this.methodInfoMorphNames == null)
- {
- return new string[0];
- }
- return (string[])this.methodInfoMorphNames.Invoke(this.component, null);
- }
- public override AnimatorTimeline.JSONInit getJSONInit()
- {
- if (!this.obj || this.keys.Count <= 0 || this.cache.Count <= 0)
- {
- return null;
- }
- AnimatorTimeline.JSONInit jsoninit = new AnimatorTimeline.JSONInit();
- jsoninit.go = this.obj.gameObject.name;
- List<string> list = new List<string>();
- list.Add(this.component.GetType().Name);
- if (this.fieldInfo != null)
- {
- jsoninit.typeExtra = "fieldinfo";
- list.Add(this.fieldInfo.Name);
- }
- else if (this.propertyInfo != null)
- {
- jsoninit.typeExtra = "propertyinfo";
- list.Add(this.propertyInfo.Name);
- }
- else if (this.methodInfo != null)
- {
- jsoninit.typeExtra = "methodinfo";
- list.Add(this.methodInfo.Name);
- foreach (string item in this.methodParameterTypes)
- {
- list.Add(item);
- }
- }
- if (this.valueType == 8)
- {
- jsoninit.type = "propertymorph";
- jsoninit.floats = (this.cache[0] as AMPropertyAction).start_morph.ToArray();
- }
- else if (this.valueType == 0)
- {
- jsoninit.type = "propertyint";
- jsoninit._int = Convert.ToInt32((this.cache[0] as AMPropertyAction).start_val);
- }
- else if (this.valueType == 1)
- {
- jsoninit.type = "propertylong";
- jsoninit._long = Convert.ToInt64((this.cache[0] as AMPropertyAction).start_val);
- }
- else if (this.valueType == 2)
- {
- jsoninit.type = "propertyfloat";
- jsoninit.floats = new float[]
- {
- Convert.ToSingle((this.cache[0] as AMPropertyAction).start_val)
- };
- }
- else if (this.valueType == 3)
- {
- jsoninit.type = "propertydouble";
- jsoninit._double = (this.cache[0] as AMPropertyAction).start_val;
- }
- else if (this.valueType == 4)
- {
- jsoninit.type = "propertyvect2";
- AnimatorTimeline.JSONVector2 jsonvector = new AnimatorTimeline.JSONVector2();
- jsonvector.setValue((this.cache[0] as AMPropertyAction).start_vect2);
- jsoninit._vect2 = jsonvector;
- }
- else if (this.valueType == 5)
- {
- jsoninit.type = "propertyvect3";
- AnimatorTimeline.JSONVector3 jsonvector2 = new AnimatorTimeline.JSONVector3();
- jsonvector2.setValue((this.cache[0] as AMPropertyAction).start_vect3);
- jsoninit.position = jsonvector2;
- }
- else if (this.valueType == 6)
- {
- jsoninit.type = "propertycolor";
- AnimatorTimeline.JSONColor jsoncolor = new AnimatorTimeline.JSONColor();
- jsoncolor.setValue((this.cache[0] as AMPropertyAction).start_color);
- jsoninit._color = jsoncolor;
- }
- else
- {
- if (this.valueType != 7)
- {
- Debug.LogWarning("Animator: Error exporting JSON, unknown Property ValueType " + this.valueType);
- return null;
- }
- jsoninit.type = "propertyrect";
- AnimatorTimeline.JSONRect jsonrect = new AnimatorTimeline.JSONRect();
- jsonrect.setValue((this.cache[0] as AMPropertyAction).start_rect);
- jsoninit._rect = jsonrect;
- }
- jsoninit.strings = list.ToArray();
- return jsoninit;
- }
- public override List<GameObject> getDependencies()
- {
- List<GameObject> list = new List<GameObject>();
- if (this.obj)
- {
- list.Add(this.obj);
- }
- return list;
- }
- public override List<GameObject> updateDependencies(List<GameObject> newReferences, List<GameObject> oldReferences)
- {
- List<GameObject> list = new List<GameObject>();
- if (!this.obj)
- {
- return list;
- }
- int i = 0;
- while (i < oldReferences.Count)
- {
- if (oldReferences[i] == this.obj)
- {
- string name = this.component.GetType().Name;
- Component component = newReferences[i].GetComponent(name);
- if (!component)
- {
- Debug.LogWarning(string.Concat(new string[]
- {
- "Animator: Property Track component '",
- name,
- "' not found on new reference for GameObject '",
- this.obj.name,
- "'. Duplicate not replaced."
- }));
- list.Add(oldReferences[i]);
- return list;
- }
- if (component.GetType().GetProperty(this.propertyName) == null)
- {
- Debug.LogWarning(string.Concat(new string[]
- {
- "Animator: Property Track property '",
- this.propertyName,
- "' not found on new reference for GameObject '",
- this.obj.name,
- "'. Duplicate not replaced."
- }));
- list.Add(oldReferences[i]);
- return list;
- }
- this.obj = newReferences[i];
- this.component = component;
- break;
- }
- else
- {
- i++;
- }
- }
- return list;
- }
- public int valueType;
- public GameObject obj;
- public string objName;
- public Component component;
- public string componentName;
- public string propertyName;
- public string fieldName;
- public string methodName;
- public string[] methodParameterTypes;
- private PropertyInfo cachedPropertyInfo;
- private FieldInfo cachedFieldInfo;
- private MethodInfo cachedMethodInfo;
- private MethodInfo cachedMethodInfoMorphNames;
- [CompilerGenerated]
- private static AMTween.EasingFunction <>f__mg$cache0;
- public enum ValueType
- {
- Integer,
- Long,
- Float,
- Double,
- Vector2,
- Vector3,
- Color,
- Rect,
- MorphChannels,
- String
- }
- }
|