// =================================================================================== // INTERNAL METHODS ------------------------------------------------------------------ /// <summary> /// Initializes the plugin after its instantiation. /// Called by Tweener after a property and plugin have been validated, and the plugin has to be set and added. /// Virtual because some classes (like PlugVector3Path) override it to avoid isRelative being TRUE. /// </summary> /// <param name="p_tweenObj"> /// The <see cref="Tweener"/> to refer to. /// </param> /// <param name="p_propertyName"> /// The name of the property to control. /// </param> /// <param name="p_easeType"> /// The <see cref="EaseType"/> to use. /// </param> /// <param name="p_targetType"> /// Directly passed from TweenParms to speed up MemberAccessor creation. /// </param> /// <param name="p_propertyInfo"> /// Directly passed from TweenParms to speed up MemberAccessor creation. /// </param> /// <param name="p_fieldInfo"> /// Directly passed from TweenParms to speed up MemberAccessor creation. /// </param> internal virtual void Init(Tweener p_tweenObj, string p_propertyName, EaseType p_easeType, Type p_targetType, PropertyInfo p_propertyInfo, FieldInfo p_fieldInfo) { _initialized = true; tweenObj = p_tweenObj; _propName = p_propertyName; targetType = p_targetType; if (easeType != EaseType.AnimationCurve && easeInfo == null || tweenObj.speedBased || easeType == EaseType.AnimationCurve && easeCurve == null) { SetEase(p_easeType); } _duration = tweenObj.duration; if (targetType == typeof(Transform)) { // Use specific transform accessors for faster performance _transformTarget = p_tweenObj.target as Transform; _useSpeedTransformAccessors = true; switch (_propName) { case "position": _setTransformVector3 = value => _transformTarget.position = value; _getTransformVector3 = () => _transformTarget.position; break; case "localPosition": _setTransformVector3 = value => _transformTarget.localPosition = value; _getTransformVector3 = () => _transformTarget.localPosition; break; case "localScale": _setTransformVector3 = value => _transformTarget.localScale = value; _getTransformVector3 = () => _transformTarget.localScale; break; case "rotation": _setTransformQuaternion = value => _transformTarget.rotation = value; _getTransformQuaternion = () => _transformTarget.rotation; break; case "localRotation": _setTransformQuaternion = value => _transformTarget.localRotation = value; _getTransformQuaternion = () => _transformTarget.localRotation; break; default: _transformTarget = null; // No valid speed property found _useSpeedTransformAccessors = false; break; } } if (!_useSpeedTransformAccessors) { #if MICRO propInfo = p_propertyInfo; fieldInfo = p_fieldInfo; #else if (HOTween.isIOS) { propInfo = p_propertyInfo; fieldInfo = p_fieldInfo; } else { if (!ignoreAccessor) { valAccessor = MemberAccessorCacher.Make(p_targetType, p_propertyName, p_propertyInfo, p_fieldInfo); } } #endif } }