/////////////////////////////////////////////////////////////////////////////// // functions /////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void Awake() { exUIControl ctrl = GetComponent <exUIControl>(); if (ctrl) { if (scaleInfos != null) { for (int j = 0; j < scaleInfos.Count; ++j) { EffectInfo_Scale info = scaleInfos[j]; EffectState_Scale state = new EffectState_Scale(); state.info = info; state.func = info.GetCurveFunction(); AddState_Scale(ctrl, state); } } if (offsetInfos != null) { for (int j = 0; j < offsetInfos.Count; ++j) { EffectInfo_Offset info = offsetInfos[j]; EffectState_Offset state = new EffectState_Offset(); state.info = info; state.func = info.GetCurveFunction(); AddState_Offset(ctrl, state); } } if (colorInfos != null) { for (int j = 0; j < colorInfos.Count; ++j) { EffectInfo_Color info = colorInfos[j]; EffectState_Color state = new EffectState_Color(); state.info = info; state.func = info.GetCurveFunction(); AddState_Color(ctrl, state); } } } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void AddEffect_Scale(Transform _target, EffectEventType _type, exEase.Type _curveType, Vector3 _to, float _duration) { exUIControl ctrl = GetComponent <exUIControl>(); if (ctrl) { EffectInfo_Scale info = new EffectInfo_Scale(); info.duration = _duration; info.target = _target; info.normal = _target.localScale; info.curveType = _curveType; EffectInfo_Scale.PropInfo propInfo = new EffectInfo_Scale.PropInfo(); propInfo.type = _type; propInfo.val = _to; info.propInfos.Add(propInfo); EffectState_Scale state = new EffectState_Scale(); state.info = info; state.func = info.GetCurveFunction(); AddState_Scale(ctrl, state); } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void AddState_Scale(exUIControl _ctrl, EffectState_Scale _state) { for (int i = 0; i < _state.info.propInfos.Count; ++i) { EffectInfo_Scale.PropInfo propInfo = _state.info.propInfos[i]; switch (propInfo.type) { case EffectEventType.Deactive: _ctrl.AddEventListener("onDeactive", delegate(exUIEvent _event) { enabled = true; _state.Begin(propInfo.val); }); _ctrl.AddEventListener("onActive", delegate(exUIEvent _event) { enabled = true; _state.Begin(_state.info.normal); }); break; case EffectEventType.Press: _ctrl.AddEventListener("onPressDown", delegate(exUIEvent _event) { enabled = true; _state.Begin(propInfo.val); }); _ctrl.AddEventListener("onPressUp", delegate(exUIEvent _event) { enabled = true; _state.Begin(_state.info.GetValue(EffectEventType.Hover)); }); _ctrl.AddEventListener("onHoverOut", delegate(exUIEvent _event) { if (_ctrl.grabMouseOrTouch == false) { enabled = true; _state.Begin(_state.info.normal); } }); break; case EffectEventType.Hover: _ctrl.AddEventListener("onHoverIn", delegate(exUIEvent _event) { enabled = true; _state.Begin(propInfo.val); }); _ctrl.AddEventListener("onHoverOut", delegate(exUIEvent _event) { enabled = true; _state.Begin(_state.info.normal); }); break; case EffectEventType.Unchecked: exUIToggle toggle = _ctrl as exUIToggle; if (toggle != null) { _ctrl.AddEventListener("onUnchecked", delegate(exUIEvent _event) { enabled = true; _state.Begin(propInfo.val); }); _ctrl.AddEventListener("onChecked", delegate(exUIEvent _event) { enabled = true; _state.Begin(_state.info.GetValue(EffectEventType.Hover)); }); } break; } } states.Add(_state); }
/////////////////////////////////////////////////////////////////////////////// // functions /////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void Awake() { exUIControl ctrl = GetComponent<exUIControl>(); if ( ctrl ) { if ( scaleInfos != null ) { for ( int j = 0; j < scaleInfos.Count; ++j ) { EffectInfo_Scale info = scaleInfos[j]; EffectState_Scale state = new EffectState_Scale(); state.info = info; state.func = info.GetCurveFunction(); AddState_Scale (ctrl, state); } } if ( offsetInfos != null ) { for ( int j = 0; j < offsetInfos.Count; ++j ) { EffectInfo_Offset info = offsetInfos[j]; EffectState_Offset state = new EffectState_Offset(); state.info = info; state.func = info.GetCurveFunction(); AddState_Offset (ctrl, state); } } if ( colorInfos != null ) { for ( int j = 0; j < colorInfos.Count; ++j ) { EffectInfo_Color info = colorInfos[j]; EffectState_Color state = new EffectState_Color(); state.info = info; state.func = info.GetCurveFunction(); AddState_Color (ctrl, state); } } } }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ void AddState_Scale( exUIControl _ctrl, EffectState_Scale _state ) { for ( int i = 0; i < _state.info.propInfos.Count; ++i ) { EffectInfo_Scale.PropInfo propInfo = _state.info.propInfos[i]; switch ( propInfo.type ) { case EffectEventType.Deactive: _ctrl.AddEventListener( "onDeactive", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( propInfo.val ); } ); _ctrl.AddEventListener( "onActive", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( _state.info.normal ); } ); break; case EffectEventType.Press: _ctrl.AddEventListener ( "onPressDown", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( propInfo.val ); } ); _ctrl.AddEventListener ( "onPressUp", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( _state.info.GetValue( EffectEventType.Hover ) ); } ); _ctrl.AddEventListener ( "onHoverOut", delegate ( exUIEvent _event ) { if ( _ctrl.grabMouseOrTouch == false ) { enabled = true; _state.Begin( _state.info.normal ); } } ); break; case EffectEventType.Hover: _ctrl.AddEventListener ( "onHoverIn", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( propInfo.val ); } ); _ctrl.AddEventListener ( "onHoverOut", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( _state.info.normal ); } ); break; case EffectEventType.Unchecked: exUIToggle toggle = _ctrl as exUIToggle; if ( toggle != null ) { _ctrl.AddEventListener ( "onUnchecked", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( propInfo.val ); } ); _ctrl.AddEventListener ( "onChecked", delegate ( exUIEvent _event ) { enabled = true; _state.Begin( _state.info.GetValue( EffectEventType.Hover ) ); } ); } break; } } states.Add(_state); }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void AddEffect_Scale( Transform _target, EffectEventType _type, exEase.Type _curveType, Vector3 _to, float _duration ) { exUIControl ctrl = GetComponent<exUIControl>(); if ( ctrl ) { EffectInfo_Scale info = new EffectInfo_Scale(); info.duration = _duration; info.target = _target; info.normal = _target.localScale; info.curveType = _curveType; EffectInfo_Scale.PropInfo propInfo = new EffectInfo_Scale.PropInfo(); propInfo.type = _type; propInfo.val = _to; info.propInfos.Add(propInfo); EffectState_Scale state = new EffectState_Scale(); state.info = info; state.func = info.GetCurveFunction(); AddState_Scale( ctrl, state ); } }