public UIState( exUIPanel _panel, State _parent = null ) : base(_panel.name,_parent) { panel = _panel; onEnter += delegate ( State _from, State _to ) { panel.Enter(); }; onExit += delegate ( State _from, State _to ) { panel.Exit(); }; }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void Init() { if ( inited ) return; panel = GetComponent<exUIPanel>(); colorCtrl = GetComponent<exSpriteColorController>(); if ( panel ) { panel.AddEventListener( "onStartFadeIn", delegate ( exUIEvent _event ) { panel.gameObject.SetActive(true); if ( colorCtrl ) { colorCtrl.color = new Color( 1.0f, 1.0f, 1.0f, 0.0f ); } } ); panel.AddEventListener( "onFinishFadeOut", delegate ( exUIEvent _event ) { panel.gameObject.SetActive(false); } ); panel.AddEventListener( "onFadeIn", delegate ( exUIEvent _event ) { exUIRatioEvent ratioEvent = _event as exUIRatioEvent; if ( colorCtrl ) { colorCtrl.color = new Color( 1.0f, 1.0f, 1.0f, ratioEvent.ratio ); } } ); panel.AddEventListener( "onFadeOut", delegate ( exUIEvent _event ) { exUIRatioEvent ratioEvent = _event as exUIRatioEvent; if ( colorCtrl ) { colorCtrl.color = new Color( 1.0f, 1.0f, 1.0f, 1.0f-ratioEvent.ratio ); } } ); } inited = true; }