/////////////////////////////////////////////////////////////////////////////// // Panel /////////////////////////////////////////////////////////////////////////////// // ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ static void CreatePanelObject(bool _useSprite) { // create panel object GameObject panelGO = new GameObject("Panel"); exUIPanel panel = panelGO.AddComponent <exUIPanel>(); // create Background if (_useSprite) { GameObject backgroundGO = new GameObject("Background"); exSprite background = backgroundGO.AddComponent <exSprite>(); panel.background = background; backgroundGO.transform.parent = panelGO.transform; } else { GameObject backgroundGO = new GameObject("Background"); exSpriteBorder background = backgroundGO.AddComponent <exSpriteBorder>(); panel.background = background; backgroundGO.transform.parent = panelGO.transform; } panel.width = 100.0f; panel.height = 100.0f; // Selection.activeObject = panelGO; }
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(); }; }
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: // ------------------------------------------------------------------ protected override void OnSceneGUI() { base.OnSceneGUI(); serializedObject.Update(); exUIPanel curEdit = target as exUIPanel; if (curEdit.background) { if (curEdit.background.anchor != curEdit.anchor) { curEdit.background.anchor = curEdit.anchor; EditorUtility.SetDirty(curEdit.background); HandleUtility.Repaint(); } } serializedObject.ApplyModifiedProperties(); }
// ------------------------------------------------------------------ // 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; }
// ------------------------------------------------------------------ // 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; }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public void Awake() { exUIPanel panel = GetComponent <exUIPanel>(); if (panel) { panel.AddEventListener("onStartFadeIn", delegate(exUIEvent _event) { transform.position = Vector3.zero; panel.gameObject.SetActive(true); }); panel.AddEventListener("onFinishFadeOut", delegate(exUIEvent _event) { transform.position = new Vector3(2000, 2000, 0); panel.gameObject.SetActive(false); }); if (useLeftToRight) { panel.AddEventListener("onFadeIn", delegate(exUIEvent _event) { exUIRatioEvent ratioEvent = _event as exUIRatioEvent; transform.position = Vector3.Lerp(new Vector3(-1000, 0, 0), new Vector3(0, 0, 0), ratioEvent.ratio); }); panel.AddEventListener("onFadeOut", delegate(exUIEvent _event) { exUIRatioEvent ratioEvent = _event as exUIRatioEvent; transform.position = Vector3.Lerp(new Vector3(0, 0, 0), new Vector3(1000, 0, 0), ratioEvent.ratio); }); } } }