示例#1
0
 private void DestoryPanel()
 {
     for (int i = Panels.Count - 1; i >= 0; i--)
     {
         CPanel panel = Panels[i];
         Panels.RemoveAt(i);
         UnityEngine.Object.Destroy(panel.gameObject);
     }
 }
示例#2
0
    public void FreezPanel(string panel_name, bool value = true)
    {
        CPanel panel = panels.Find(x => x.name == panel_name);

        if (panel != null)
        {
            panel.freez = value;
        }
    }
示例#3
0
        private void Compile(string path, InterfacePanel res)
        {
            Writer.Write((int)Type.Panel);
            var cpanel = new CPanel();

            cpanel.Base  = new CElement(res);
            cpanel.Image = Compile(path, res.Image);
            cpanel.Write(Writer);
        }
示例#4
0
 protected void OnCloseContainer(ClientViewport Viewport, ClientContainer Container)
 {
     foreach (ContainerPanel CPanel in Sidebar.ContentView.SubviewsOfType <ContainerPanel>())
     {
         if (CPanel.ContainerID == Container.ContainerID)
         {
             CPanel.RemoveFromSuperview();
         }
     }
 }
示例#5
0
    public void SetPanelVisible(string panel_name, bool visible, bool immediate = false)
    {
        CPanel panel = panels.Find(x => x.name == panel_name);

        if (panel)
        {
            if (immediate)
            {
                panel.SetVisible(visible, true);
            }
            else
            {
                panel.SetVisible(visible);
            }
        }
    }
示例#6
0
        static public CPanel BuildCPanel(Control parent)
        {
            while (model.allControls.Exists(l => l.cd.Name == "CPanel" + CPanel.count))
            {
                CPanel.count++;
            }
            CPanel c = new CPanel();

            parent.Controls.Add(c);

            SetCommonHandlers(c);
            SetDragDropHandlers(c);

            Model.getInstance().allControls.Add(c);
            c.SetControlDescription();

            c.cd.RealText = c.cd.Text;
            c.AllowDrop   = true;

            model.logCreator.Append("+ Added: " + c.cd.Name);

            return(c);
        }
示例#7
0
        public IEnumerator LoadPanel(Panel prefab, Request req = null)
        {
            Debug.LogError("newPanel=" + prefab.ToString());
            OldPanel = CurrentPanel;
            CPanel panel = GetPanel(prefab);

            if (panel != null)
            {
                CurrentPanel = panel;
                CurrentPanel.gameObject.SetActive(true);
                CurrentScene.StartCoroutine(CurrentPanel.OnLoad(req == null ? new Request() : req));
            }
            else
            {
                System.Action <GameObject> callback = (GameObject instance) =>
                {
                    //GameObject instance = CurrentScene.GetObject(o);
                    CurrentPanel = instance.GetComponent <CPanel>();
                    CurrentPanel.gameObject.SetActive(true);
                    Panels.Add(CurrentPanel);
                    RectTransform trans = instance.GetComponent <RectTransform>();
                    trans.anchorMax = new Vector2(0.5f, 0.5f);
                    trans.anchorMin = new Vector2(0.5f, 0.5f);
                    Transform parent = CurrentScene.panelsParent;
                    instance.transform.SetParent(parent);
                    instance.transform.localScale    = Vector3.one;
                    instance.transform.localPosition = Vector3.zero;
                    CurrentScene.StartCoroutine(CurrentPanel.OnLoad(req == null ? new Request() : req));
                };
                yield return(LoadPrefab("Panels", prefab.ToString(), callback));
            }
            if (OldPanel != null)
            {
                yield return(OldPanel.Unload());
            }
        }
示例#8
0
    private void CreatePanel()
    {
        var panel = new CPanel();

        panel.CreatePanelWithDefaultSettings();
    }
示例#9
0
    private void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();

        // Create event system
        if (GUILayout.Button("Event System"))
        {
            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
            else
            {
                EditorUtility.DisplayDialog("Event System Already Exist", "UI Tool Cant Generate Multiple EventSystem", "OK");
            }
        }


        // Create Screen Space Overlay Canvas
        if (GUILayout.Button("Canvas"))
        {
            // Create canvas
            CreateCanvas();

            // Add EventSystem, if doesnot exist
            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create Panel
        if (GUILayout.Button("Panel"))
        {
            CreatePanel();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }

        // Create Text
        if (GUILayout.Button("Text"))
        {
            CreateText();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }

        EditorGUILayout.EndHorizontal();


        EditorGUILayout.BeginHorizontal();

        // Create button
        if (GUILayout.Button("Button With Text"))
        {
            CreateButton();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create button without text
        if (GUILayout.Button("Button Without Text"))
        {
            CreateButtonWithoutText();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create Image
        if (GUILayout.Button("Image"))
        {
            CreateImage();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }


        // Create raw Image
        if (GUILayout.Button("Raw Image"))
        {
            CreateRawImage();

            if (!IsEventSystemExist())
            {
                CreateEventSystem();
            }
        }

        EditorGUILayout.EndHorizontal();


        // Space area
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        //========================================================================================
        //========================================================================================
        EditorGUILayout.BeginVertical();

        // Begin Horizontal To add Image realted buttons
        EditorGUILayout.LabelField("Add Photoshop Text files.");
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("-"))
        {
            if (_textFiles.Count > 0)
            {
                _textFiles.RemoveAt(_textFiles.Count - 1);
            }
        }
        if (GUILayout.Button("Clear"))
        {
            _textFiles = new List <TextAsset>();
        }
        if (GUILayout.Button("+"))
        {
            _textFiles.Add(new TextAsset());
        }

        EditorGUILayout.EndHorizontal();

        for (var i = 0; i < _textFiles.Count; i++)
        {
            EditorGUILayout.BeginHorizontal();
            _textFiles[i] = (TextAsset)EditorGUILayout.ObjectField("Photoshop text file : ", _textFiles[i], typeof(TextAsset), false);

            if (GUILayout.Button("-", GUILayout.MaxWidth(50)))
            {
                _textFiles.Remove(_textFiles[i]);
            }

            EditorGUILayout.EndHorizontal();
        }

        //========================================================================================
        //========================================================================================

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();


        EditorGUILayout.LabelField("Add Image Folder");
        EditorGUILayout.BeginHorizontal();

        if (GUILayout.Button("+", GUILayout.MaxWidth(50)))
        {
            _textureFolderPath = EditorUtility.OpenFolderPanel("Load Textures", "Images", "");
            if (!_textureFolderPath.Contains(Application.dataPath))
            {
                EditorUtility.DisplayDialog("Folder Warning", "Folder Must Exist in Assets", "OK");
                return;
            }

            _spriteList = new List <Sprite>();
            if (!string.IsNullOrEmpty(_textureFolderPath))
            {
                // get directories and load images
                CreateSpriteListFromDirectorySearch(_textureFolderPath);
                Debug.Log(_spriteList.Count);
            }
        }
        EditorGUILayout.LabelField(_textureFolderPath);
        EditorGUILayout.EndHorizontal();

        //========================================================================================
        //========================================================================================

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (_textFiles.Count > 0 && _spriteList.Count > 0)
        {
            if (GUILayout.Button("Create Menu", GUILayout.ExpandWidth(false)))
            {
                var sprite = new Sprite();

                // create canvas
                var canvasObj = new CCanvas();
                canvasObj.GetCanvas();

                // create event system
                if (!IsEventSystemExist())
                {
                    CreateEventSystem();
                }

                foreach (var textFile in _textFiles)
                {
                    if (textFile == null)
                    {
                        continue;
                    }

                    var informationList = new List <UiInformation>();
                    informationList = TextReader.ReadTextFile(textFile);

                    // Create Panel
                    var panel    = new CPanel();
                    var panelObj = panel.CreatePanelWithDefaultSettings();

                    // Create UI
                    foreach (var uiInfo in informationList)
                    {
                        switch (uiInfo.UIType)
                        {
                        case eUIType.Button:
                            foreach (var spriteImage in _spriteList)
                            {
                                if (spriteImage.name.Equals(uiInfo.Name))
                                {
                                    sprite = spriteImage;
                                    break;
                                }
                            }

                            // create button
                            var button = new CButton();
                            button.CreateButtonWithoutText(panelObj, uiInfo, sprite);
                            break;

                        case eUIType.Text:
                            // create text
                            var text = new CText();
                            text.CreateText(panelObj, uiInfo);
                            break;

                        case eUIType.ButtonWithText:
                            Debug.Log("Create button with text");
                            foreach (var spriteImage in _spriteList)
                            {
                                if (spriteImage.name.Equals(uiInfo.Name))
                                {
                                    sprite = spriteImage;
                                    break;
                                }
                            }

                            // create button
                            var btnWithText = new CButton();
                            var btnObj      = btnWithText.CreateButtonWithoutText(panelObj, uiInfo, sprite);

                            // create text
                            var txt = new CText();
                            txt.CreateText(btnObj, uiInfo);
                            break;

                        default:
                            throw new ArgumentOutOfRangeException();
                        }
                    }
                }
            }
        }

        // End vertical layout in the end
        EditorGUILayout.EndVertical();
    }
示例#10
0
 public static void LoadScene(string name, Request req = null)
 {
     OldPanel = null;
     Global.AppManager.DestoryPanel();
     CurrentScene.StartCoroutine(LoadSceneCoroutine(name, req));
 }
示例#11
0
        private void CreatePreviewControls(Section s, XElement i)
        {
            if (s == null)
            {
                return;
            }
            if (i == null)
            {
                return;
            }

            switch (i.Attribute("type").Value)
            {
            case "CLabel":
                CLabel lbl = ControlFactory.BuildCLabel(s.Tab);
                lbl.cd.Name = i.Element("Name").Value;
                break;

            case "CComboBox":
                CComboBox cb = ControlFactory.BuildCComboBox(s.Tab);
                cb.cd.Name = i.Element("Name").Value;
                break;

            case "CButton":
                CButton b = ControlFactory.BuildCButton(s.Tab);
                b.cd.Name = i.Element("Name").Value;
                break;

            case "CGroupBox":
                CGroupBox gb = ControlFactory.BuildCGroupBox(s.Tab);
                gb.cd.Name = i.Element("Name").Value;
                break;

            case "CPanel":
                CPanel pl = ControlFactory.BuildCPanel(s.Tab);
                pl.cd.Name = i.Element("Name").Value;
                break;

            case "CBitmap":
                CBitmap bm = ControlFactory.BuildCBitmap(s.Tab);
                bm.cd.Name = i.Element("Name").Value;
                break;

            case "CTextBox":
                CTextBox tb = ControlFactory.BuildCTextBox(s.Tab);
                tb.cd.Name = i.Element("Name").Value;
                break;

            case "CCheckBox":
                CCheckBox ccb = ControlFactory.BuildCCheckBox(s.Tab);
                ccb.cd.Name = i.Element("Name").Value;
                break;

            case "CTabControl":
                CTabControl ctc = ControlFactory.BuildCTabControl(s.Tab);
                ctc.cd.Name = i.Element("Name").Value;
                break;

            case "CTabPage":
                //Tab pages require its parent TabControl to be created first.
                break;
            }
        }
示例#12
0
 void Awake()
 {
     main   = this;
     cpanel = GetComponent <CPanel>();
 }