/// <summary> /// Creates a new object that is a copy of the current instance. /// </summary> /// <returns> /// A new object that is a copy of this instance. /// </returns> /// <filterpriority>2</filterpriority> public override object Clone() { Tween t = (Tween)MemberwiseClone(); t.Parent = Parent; if (null != StartValueReader) { t.StartValueReader = (PropertyReader)StartValueReader.Clone(); } if (null != EndValueReader) { t.EndValueReader = (PropertyReader)EndValueReader.Clone(); } if (Proxy is ICloneable) // added 20131107 { t.Proxy = (ISetterProxy)(Proxy as ICloneable).Clone(); } return(t); }
private void Initialize() { if (null == _proxy) { InitProxy(); } // check if interpolator not defined, and add one from defaults if (null != _proxy && null == _interpolator) { InitInterpolator(); } //Debug.Log("Proxy is null: " + (null == _proxy)); //Debug.Log("StartValue: " + StartValue); //Debug.Log("EndValue: " + EndValue); /** * Note: The priority is as follows: * 1) StartValue is checked. If set, skipping other checks * 2) StartValueReader is checked. If set, it reads the specified property * 3) StartValueReaderFunction is checked. If set, it is being run to get a property value. * - if niether of above steps resulted in having StartValue, we throw an exception * */ if (null != StartValue) { // do nothing } else if (null != StartValueReader) { if (null == StartValueReader.Target && null != Target) { StartValueReader.Target = Target; } if (null == StartValueReader.Property && null != Property) { StartValueReader.Property = Property; } StartValue = StartValueReader.Read(); } else if (null != StartValueReaderFunction) { StartValue = StartValueReaderFunction(Target); } if (CheckStartValue && null == StartValue) { throw new Exception("StartValue, StartValueGetter or StartValueReaderFunction not set: " + this); } if (null != EndValue) { // do nothing } if (null != EndValueReader) { if (null == EndValueReader.Target && null != Target) { EndValueReader.Target = Target; } if (null == EndValueReader.Property && null != Property) { EndValueReader.Property = Property; } EndValue = EndValueReader.Read(); } else if (null != EndValueReaderFunction) { EndValue = EndValueReaderFunction(Target); } if (CheckEndValue && null == EndValue) { throw new Exception("EndValue, EndValueReader or EndValueReaderFunction not set: " + this); } // check if tween is needed if (null != StartValue && null != EndValue && EndValue.Equals(StartValue)) { #if DEBUG if (DebugMode) { Debug.Log("EndValue equals StartValue. Returning..."); } #endif //if (IsChild) //{ // Parent.FinishedCount++; //} return; } #if DEBUG if (DebugMode) { Debug.Log("Playing: " + this); } #endif // go for a tween _startTime = DateTime.Now; //if (reset) _fraction = Starting; /** * Check if this is a root tween * If so, and not connected, connect * */ /*if (null == Parent && !SystemManager.Instance.UpdateSignal.HasSlot(this)) * SystemManager.Instance.UpdateSignal.Connect(this);*/ //Debug.Log("* INIT *"); TweenRegistry.Instance.Add(this); _initialized = true; }