Exemplo n.º 1
0
        private void RenderButton3()
        {
            string text = " Create new event handler in the existing script";

            if (Application.isPlaying)
            {
                text += " (requires Play mode STOP)";
            }

            //GUI.enabled = false;
            if (GUILayout.Button(new GUIContent(text, TextureCache.Instance.EventHandlerCreateButton), StyleCache.Instance.BigButton, GUILayout.ExpandHeight(true)))
            {
                var scanCommand = new AttachExistingScriptFileScan
                {
                    Adapter            = AddEventHandlerDialog.Instance.Adapter,
                    Data               = AddEventHandlerDialog.Instance.Data,
                    CreatingNewHandler = true
                };
                _isChosen = scanCommand.Run();
                if (_isChosen)
                {
                    var eventHandlerScriptRetriever = new EventHandlerScriptRetriever
                    {
                        Data = AddEventHandlerDialog.Instance.Data,
                        //GameObject = AddEventHandlerDialog.Instance.Adapter.gameObject
                    };

                    var scripts = eventHandlerScriptRetriever.Process();

                    //Debug.Log("AddEventHandlerDialog.Instance.Data: " + AddEventHandlerDialog.Instance.Data);
                    // important:
                    //AddEventHandlerDialog.Instance.Data.Action = AddHandlerAction.CreateNewHandlerInExistingScript;
                    AddEventHandlerDialog.Instance.Data.Scripts = scripts;
                    EventHandlerListStep.Instance.Scripts       = scripts;

                    GotoSignal.Emit(2);
                }
            }
            //GUI.enabled = true;
        }
Exemplo n.º 2
0
        private void RenderButton2()
        {
            string text = " Add the existing script + map event handler";

            if (Application.isPlaying)
            {
                text += " (requires Play mode STOP)";
            }

            if (GUILayout.Button(new GUIContent(text, TextureCache.Instance.EventHandlerScriptAddButton), StyleCache.Instance.BigButton, GUILayout.ExpandHeight(true)))
            {
                var scanCommand = new AttachExistingScriptFileScan
                {
                    Adapter = AddEventHandlerDialog.Instance.Adapter,
                    Data    = AddEventHandlerDialog.Instance.Data
                };
                _isChosen = scanCommand.Run();
                if (_isChosen)
                {
                    var eventHandlerScriptRetriever = new EventHandlerScriptRetriever
                    {
                        Data = AddEventHandlerDialog.Instance.Data,
                        //GameObject = AddEventHandlerDialog.Instance.Adapter.gameObject
                    };
                    var scripts = eventHandlerScriptRetriever.Process();

                    var data = AddEventHandlerDialog.Instance.Data;
                    data.Scripts = scripts;
                    data.ScriptAlreadyAttached = null != data.Adapter.gameObject.GetComponent(data.ClassName); // perhaps we don't need to stop the play mode

                    EventHandlerListStep.Instance.Scripts = scripts;

                    GotoSignal.Emit(1);
                }
            }
        }