private void OnGUI()
        {
            CheckBatchJson();
            if (currentBatches == null)
            {
                EditorGUILayout.HelpBox("读取文件错误", MessageType.Error);
                return;
            }

            EditorGUILayout.Space();

            //如果按下了ESC,可以推出
            if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape)
            {
                Close();
            }

            asset = EditorGUILayout.ObjectField("选择加载场景", asset, typeof(SceneAsset), false) as SceneAsset;


            EditorGUI.BeginDisabledGroup(asset == null);

            int selection = -1;

            selection = GUILayout.SelectionGrid(selection, buttonContents, 2);

            switch (selection)
            {
            case 0:
            {
                var path = AssetDatabase.GetAssetPath(asset);
                EditorSceneManager.OpenScene(path, OpenSceneMode.Single);
                Close();
            }
            break;

            case 1:
            {
                var path = AssetDatabase.GetAssetPath(asset);
                EditorSceneManager.OpenScene(path, OpenSceneMode.Additive);
                Close();
            }
            break;

            default:
                break;
            }

            EditorGUI.EndDisabledGroup();

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

            EditorGUILayout.LabelField("按下Esc退出该面板", EditorStyleExtention.Title);

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

            EditorGUILayout.LabelField("常用快速访问");
            EditorGUILayout.Space();

            scrollView = EditorGUILayout.BeginScrollView(scrollView);


            foreach (var list in taggedBatches)
            {
                if (EditorGUILayout.Foldout(true, list.Key))
                {
                    foreach (var batch in list.Value)
                    {
                        if (batch.scenes.Length >= 1 && GUILayout.Button(batch.describe))
                        {
                            //如果是场景
                            if (batch.scenes[0].Contains(".unity"))
                            {
                                if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                                {
                                    EditorSceneManager.OpenScene(Application.dataPath + batch.scenes[0], OpenSceneMode.Single);

                                    for (int i = 1; i < batch.scenes.Length - 1; ++i)
                                    {
                                        EditorSceneManager.OpenScene(Application.dataPath + batch.scenes[i], OpenSceneMode.Additive);
                                    }

                                    var scene = EditorSceneManager.OpenScene(Application.dataPath + batch.scenes[batch.scenes.Length - 1], OpenSceneMode.Additive);
                                    EditorSceneManager.SetActiveScene(scene);
                                }
                            }
                            else //文件
                            {
                                EditorUtility.OpenWithDefaultApp(Application.dataPath + batch.scenes[0]);
                            }

                            this.Close();
                            break;
                        }
                    }
                }
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 2
0
    private void OnGUIEventFilter()
    {
        EditorGUILayout.BeginVertical("box", GUILayout.Width(300));
        {
            //filterType = (FilterType)GUILayout.Toolbar((int)filterType, FilterTypeStrings);
            if (filterType == FilterType.Name)
            {
                eventFilterScroll = EditorGUILayout.BeginScrollView(eventFilterScroll);
                bool changed = false;
                foreach (Filter filter in nameFilterList.list)
                {
                    bool oldSelected = filter.on;
                    bool selected    = GUILayout.Toggle(oldSelected, string.Format("{0}({1})", filter.name, filter.count));
                    if (selected != oldSelected)
                    {
                        filter.on = selected;
                        changed   = true;
                    }
                }

                if (changed)
                {
                    foreach (ListCtrl.Row row in eventLogList.RowList)
                    {
                        ApplyFilter(row);
                    }
                }
                EditorGUILayout.EndScrollView();
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("All"))
                {
                    foreach (Filter filter in nameFilterList.list)
                    {
                        filter.on = true;
                    }
                    foreach (ListCtrl.Row row in eventLogList.RowList)
                    {
                        ApplyFilter(row);
                    }
                }
                if (GUILayout.Button("None"))
                {
                    foreach (Filter filter in nameFilterList.list)
                    {
                        filter.on = false;
                    }
                    foreach (ListCtrl.Row row in eventLogList.RowList)
                    {
                        ApplyFilter(row);
                    }
                }
                if (GUILayout.Button("X"))
                {
                    nameFilterList.Reset();

                    foreach (ListCtrl.Row row in eventLogList.RowList)
                    {
                        ApplyFilter(row);
                    }
                }

                EditorGUILayout.EndHorizontal();
            }
        }
        EditorGUILayout.EndVertical();
    }
Exemplo n.º 3
0
        private void CreateMenusGUI()
        {
            EditorGUILayout.BeginVertical(CustomStyles.thinBox);
            showMenuList = CustomGUILayout.ToggleHeader(showMenuList, "Menus");
            if (showMenuList)
            {
                if (menus != null && menus.Count > 1)
                {
                    nameFilter = EditorGUILayout.TextField("Filter by name:", nameFilter);
                    EditorGUILayout.Space();
                }

                int numInFilter = 0;
                foreach (AC.Menu _menu in menus)
                {
                    if (_menu == null)
                    {
                        menus.Remove(_menu);
                        CleanUpAsset();
                        EditorGUILayout.EndVertical();
                        return;
                    }

                    _menu.showInFilter = false;
                    if (string.IsNullOrEmpty(nameFilter) || _menu.title.ToLower().Contains(nameFilter.ToLower()))
                    {
                        _menu.showInFilter = true;
                        numInFilter++;
                    }
                }

                if (numInFilter > 0)
                {
                    scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(numInFilter * 22, ACEditorPrefs.MenuItemsBeforeScroll * 22) + 9));

                    foreach (AC.Menu _menu in menus)
                    {
                        if (_menu.showInFilter)
                        {
                            EditorGUILayout.BeginHorizontal();

                            string buttonLabel = _menu.title;
                            if (buttonLabel == "")
                            {
                                buttonLabel = "(Untitled)";
                            }
                            if (GUILayout.Toggle(selectedMenu == _menu, buttonLabel, "Button"))
                            {
                                if (selectedMenu != _menu)
                                {
                                    DeactivateAllMenus();
                                    ActivateMenu(_menu);
                                }
                            }

                            if (GUILayout.Button(string.Empty, CustomStyles.IconCog))
                            {
                                SideMenu(_menu);
                            }

                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    EditorGUILayout.EndScrollView();

                    if (numInFilter != menus.Count)
                    {
                        EditorGUILayout.HelpBox("Filtering " + numInFilter + " out of " + menus.Count + " menus.", MessageType.Info);
                    }
                }
                else if (menus.Count > 0)
                {
                    EditorGUILayout.HelpBox("No Menus that match the above filters have been created.", MessageType.Info);
                }

                EditorGUILayout.Space();

                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Create new menu"))
                {
                    Undo.RecordObject(this, "Add menu");

                    Menu newMenu = (Menu)CreateInstance <Menu>();
                    newMenu.Declare(GetIDArray());
                    menus.Add(newMenu);

                    DeactivateAllMenus();
                    ActivateMenu(newMenu);

                    newMenu.hideFlags = HideFlags.HideInHierarchy;
                    AssetDatabase.AddObjectToAsset(newMenu, this);
                    AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newMenu));
                    AssetDatabase.SaveAssets();
                    CleanUpAsset();
                }
                if (MenuManager.copiedMenu == null)
                {
                    GUI.enabled = false;
                }
                if (GUILayout.Button("Paste menu"))
                {
                    PasteMenu();
                }
                GUI.enabled = true;
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
        }
Exemplo n.º 4
0
        void OnGUI()
        {
            if (!isInitialised)
            {
                Initialise();
            }

            if (!_selectedAC)
            {
                _SetCurrentAudioController(_FindAudioController());
            }

            if (_selectedAC == null && Selection.activeGameObject != null)
            {
                _SetCurrentAudioController(Selection.activeGameObject.GetComponent <AudioController>());
            }

            if (_audioControllerNameList == null)
            {
                _FindAudioController();

                if (_audioControllerNameList == null && _selectedAC != null)   // can happen if AC was selected by Show( AC )
                {
                    _audioControllerNameList = new string[1] {
                        _GetPrefabName(_selectedAC)
                    };
                }
            }

            if (!_selectedAC)
            {
                EditorGUILayout.LabelField("No AudioController found!");
                return;
            }

            EditorGUILayout.BeginHorizontal();

            int newACIndex = EditorGUILayout.Popup(_selectedACIndex, _audioControllerNameList, _headerStyleButton);

            if (newACIndex != _selectedACIndex)
            {
                _selectedACIndex = newACIndex;
                _SetCurrentAudioController(_audioControllerList[_selectedACIndex]);
                _SelectCurrentAudioController();
            }

            if (_foldoutsSetFromController != _selectedAC)
            {
                _SetCategoryFoldouts();
            }

            if (_searchString == null)
            {
                _searchString = "";
            }

            _searchString = EditorGUILayout.TextField("                  search item: ", _searchString);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Button("      ", _styleEmptyButton);
            EditorGUILayout.LabelField("Item", _headerStyle);
            EditorGUILayout.LabelField("Sub Item", _headerStyle);

            EditorGUILayout.EndHorizontal();

            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);

            if (_selectedAC != null && _selectedAC.AudioCategories != null)
            {
                for (int categoryIndex = 0; categoryIndex < _selectedAC.AudioCategories.Length; categoryIndex++)
                {
                    var category = _selectedAC.AudioCategories[categoryIndex];

                    if (string.IsNullOrEmpty(category.Name))
                    {
                        Debug.LogWarning("empty category.Name");
                        continue;
                    }


                    if (!_foldedOutCategories.ContainsKey(category.Name))
                    {
                        Debug.LogWarning("can not find category.Name: " + category.Name);   // TODO: find out why this can happen sometimes
                        continue;
                    }

                    EditorGUILayout.BeginHorizontal();

                    if (GUILayout.Button((_foldedOutCategories[category.Name] ? "-\t" : "+\t") + category.Name, _styleCategoryButtonHeader))
                    {
                        _foldedOutCategories[category.Name] = !_foldedOutCategories[category.Name];
                    }

                    EditorGUILayout.EndHorizontal();

                    var filteredAudioItems = new List <AudioItem>(category.AudioItems);
                    if (!string.IsNullOrEmpty(_searchString))
                    {
                        bool catFoldedOut = false;
                        for (int i = 0; i < filteredAudioItems.Count; ++i)
                        {
                            AudioItem item = filteredAudioItems[i];
                            if (!item.Name.ToLowerInvariant().Contains(_searchString.ToLowerInvariant()))
                            {
                                filteredAudioItems.RemoveAt(i--);
                            }
                            else
                            {
                                catFoldedOut = true;
                            }
                        }
                        _foldedOutCategories[category.Name] = catFoldedOut && filteredAudioItems.Count > 0;
                    }

                    if (_foldedOutCategories[category.Name])
                    {
                        if (category.AudioItems == null)
                        {
                            continue;
                        }

                        var sortedAudioItems = filteredAudioItems.OrderBy(x => x.Name).ToArray();

                        for (int itemIndex = 0; itemIndex < sortedAudioItems.Length; itemIndex++)
                        {
                            var    item       = sortedAudioItems[itemIndex];
                            string emptySpace = "      ";

                            EditorGUILayout.BeginHorizontal();
                            GUILayout.Button(emptySpace, _styleEmptyButton);
                            GUILayout.Label(item.Name);
                            EditorGUILayout.EndHorizontal();

                            if (item.subItems == null)
                            {
                                continue;
                            }
                            for (int subitemIndex = 0; subitemIndex < item.subItems.Length; subitemIndex++)
                            {
                                var subItem = item.subItems[subitemIndex];

                                GUILayout.BeginHorizontal();
                                GUILayout.Button(emptySpace, _styleEmptyButton);
                                EditorGUILayout.BeginHorizontal();

                                string listItemDisplay     = "";
                                string listItemTypeDisplay = "     ";

                                if (subItem.SubItemType == AudioSubItemType.Clip)
                                {
                                    if (subItem.Clip != null)
                                    {
                                        listItemDisplay      = subItem.Clip.name;
                                        listItemTypeDisplay += "CLIP:";
                                    }
                                    else
                                    {
                                        listItemDisplay      = "*unset*";
                                        listItemTypeDisplay += "CLIP:";
                                    }
                                }
                                else
                                {
                                    listItemTypeDisplay += "ITEM:";
                                    listItemDisplay      = subItem.ItemModeAudioID;
                                }

                                EditorGUILayout.LabelField(listItemTypeDisplay, GUILayout.MaxWidth(_buttonSize));

                                if (GUILayout.Button(listItemDisplay, subitemIndex % 2 == 0 ? _styleListItemButton0 : _styleListItemButton1, GUILayout.ExpandWidth(true)))
                                {
                                    _selectedAC._currentInspectorSelection.currentCategoryIndex = categoryIndex;
                                    _selectedAC._currentInspectorSelection.currentItemIndex     = Array.FindIndex(category.AudioItems, x => x.Name == item.Name);
                                    _selectedAC._currentInspectorSelection.currentSubitemIndex  = subitemIndex;
                                    _SelectCurrentAudioController();
                                }

                                if (subItem.SubItemType == AudioSubItemType.Clip)
                                {
                                    if (subItem.Clip != null)
                                    {
                                        if (GUILayout.Button("Clip", subitemIndex % 2 == 0 ? _styleListItemButton0 : _styleListItemButton1, GUILayout.MaxWidth(50)))
                                        {
                                            Selection.activeObject = subItem.Clip;
                                            EditorGUIUtility.PingObject(subItem.Clip);
                                        }
                                    }
                                }


                                EditorGUILayout.EndHorizontal();
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                    }
                }
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 5
0
    private void renderAtlasPreview()
    {
        string[] atlasesNames = TPAssetPostprocessor.atlasesNames;


        EditorGUIUtility.LookLikeInspector();
        GUILayout.BeginHorizontal(TexturePackerStyles.toolBarBoxStyle);
        GUILayout.FlexibleSpace();

        EditorGUI.BeginChangeCheck();

        if (atlasIndex == -1)
        {
            int    i = 0;
            string n = TPEditorData.selectedAtlasName;
            foreach (string atName in atlasesNames)
            {
                if (atName.Equals(n))
                {
                    atlasIndex = i;
                    break;
                }
                i++;
            }
            if (atlasIndex == -1)
            {
                atlasIndex = 0;
            }
        }

        atlasIndex = EditorGUI.Popup(
            new Rect(-10, 0, TexturePackerStyles.ATLAS_POPUP_WIDTH, 20),
            "",
            atlasIndex,
            atlasesNames, TexturePackerStyles.toolBarDropDwonStyle);
        if (EditorGUI.EndChangeCheck())
        {
            images.Clear();
            selection.Clear();
            TPEditorData.selectedAtlasName = atlasesNames [atlasIndex];
        }


        GUIStyle btnStyle = EditorStyles.toolbarButton;

        if (GUILayout.Button("Add To Animation", btnStyle))
        {
            addSelectedFrameToAnimation();
        }


        if (TPEditorData.isExtensionsEnabled)
        {
            btnStyle = TexturePackerStyles.toobarEnabledButton;
        }



        if (GUILayout.Button("Extensions", btnStyle))
        {
            TPEditorData.isExtensionsEnabled = !TPEditorData.isExtensionsEnabled;
        }



        search = GUILayout.TextField(search, GUI.skin.FindStyle("ToolbarSeachTextField"), TexturePackerStyles.FixedWidth(200f));


        if (GUILayout.Button("", GUI.skin.FindStyle("ToolbarSeachCancelButton")))
        {
            // Remove focus if cleared
            search = "";
            GUI.FocusControl(null);
        }


        GUILayout.EndHorizontal();



        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(editor.position.width), GUILayout.Height(editor.position.height - 17f));

        GUILayout.Box("", GUIStyle.none, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(_maxY) });
        _maxY = 0f;


        TextureNodeRenderer.calculateVars(editor.position.width - 10f);
        currentAtlas = getAtlas(atlasesNames[atlasIndex]);
        Rect r;
        int  index = 0;

        images.Clear();
        foreach (string name in currentAtlas.frameNames)
        {
            if (search != string.Empty)
            {
                if (!name.ToLower().Contains(search.ToLower()))
                {
                    continue;
                }
            }

            r = TextureNodeRenderer.RenderNode(index, currentAtlas, name);
            rememberImageRect(name, r);
            setNodeY(r.y + r.height * 1.5f);
            index++;
        }


        EditorGUILayout.EndScrollView();
    }
Exemplo n.º 6
0
        void OnGUI()
        {
            DTInspectorNode.IsInsideInspector = false;
            if (Curves.Count == 0)
            {
                return;
            }
            scroll = EditorGUILayout.BeginScrollView(scroll);

            Mode = GUILayout.SelectionGrid(Mode, new GUIContent[]
            {
                new GUIContent("Closed Shape", "Export a closed shape with triangles"),
                new GUIContent("Vertex Line", "Export a vertex line")
            }, 2);

            if (!string.IsNullOrEmpty(TriangulationMessage) && !TriangulationMessage.Contains("Angle must be >0"))
            {
                EditorGUILayout.HelpBox(TriangulationMessage, MessageType.Error);
            }

            // OUTLINE
            GUIRenderer.RenderSectionHeader(nOutline);
            if (nOutline.ContentVisible)
            {
                CurveGUI(Curves[0], false);
            }
            mNeedRepaint = mNeedRepaint || nOutline.NeedRepaint;
            GUIRenderer.RenderSectionFooter(nOutline);
            if (Mode == CLOSEDSHAPE)
            {
                // HOLES
                GUIRenderer.RenderSectionHeader(nHoles);
                if (nHoles.ContentVisible)
                {
                    for (int i = 1; i < Curves.Count; i++)
                    {
                        CurveGUI(Curves[i], true);
                    }
                    if (GUILayout.Button("Add Hole"))
                    {
                        Curves.Add(new SplinePolyLine(null));
                    }
                }
                GUIRenderer.RenderSectionFooter(nHoles);
                mNeedRepaint = mNeedRepaint || nHoles.NeedRepaint;
            }

            // TEXTURING
            GUIRenderer.RenderSectionHeader(nTexture);
            if (nTexture.ContentVisible)
            {
                Mat      = (Material)EditorGUILayout.ObjectField("Material", Mat, typeof(Material), true);
                UVTiling = EditorGUILayout.Vector2Field("Tiling", UVTiling);
                UVOffset = EditorGUILayout.Vector2Field("Offset", UVOffset);
            }
            GUIRenderer.RenderSectionFooter(nTexture);
            mNeedRepaint = mNeedRepaint || nTexture.NeedRepaint;
            // EXPORT
            GUIRenderer.RenderSectionHeader(nExport);
            if (nExport.ContentVisible)
            {
                EditorGUILayout.HelpBox("Export is 2D (x/y) only!", MessageType.Info);
                MeshName = EditorGUILayout.TextField("Mesh Name", MeshName);
                UV2      = EditorGUILayout.Toggle("Add UV2", UV2);

                GUILayout.BeginHorizontal();

                if (GUILayout.Button("Save as Asset"))
                {
                    string path = EditorUtility.SaveFilePanelInProject("Save Mesh", MeshName + ".asset", "asset", "Choose a file location");
                    if (!string.IsNullOrEmpty(path))
                    {
                        Mesh msh = clonePreviewMesh();
                        if (msh)
                        {
                            msh.name = MeshName;
                            AssetDatabase.DeleteAsset(path);
                            AssetDatabase.CreateAsset(msh, path);
                            AssetDatabase.SaveAssets();
                            AssetDatabase.Refresh();
                            Debug.Log("Curvy Export: Mesh Asset saved!");
                        }
                    }
                }

                if (GUILayout.Button("Create GameObject"))
                {
                    Mesh msh = clonePreviewMesh();
                    if (msh)
                    {
                        msh.name = MeshName;
                        var go = new GameObject(MeshName, typeof(MeshRenderer), typeof(MeshFilter));
                        go.GetComponent <MeshFilter>().sharedMesh       = msh;
                        go.GetComponent <MeshRenderer>().sharedMaterial = Mat;
                        Selection.activeGameObject = go;
                        Debug.Log("Curvy Export: GameObject created!");
                    }
                    else
                    {
                        Debug.LogWarning("Curvy Export: Unable to triangulate spline!");
                    }
                }
                GUILayout.EndHorizontal();
            }
            GUIRenderer.RenderSectionFooter(nExport);
            mNeedRepaint = mNeedRepaint || nExport.NeedRepaint;
            EditorGUILayout.EndScrollView();
            refreshNow = refreshNow || GUI.changed;
            if (mNeedRepaint)
            {
                Repaint();
                mNeedRepaint = false;
            }
        }
Exemplo n.º 7
0
        private void OnGUI()
        {
            EditorGUILayout.Separator();

            OnPatternsGUI();

            EditorGUILayout.Separator();

            if (GUILayout.Button("Run Analysis", GUILayout.Width(300f)))
            {
                ListAllUnusedAssetsInProject();
            }

            EditorGUILayout.Separator();

            if (_launchedAtLeastOnce)
            {
                EditorGUILayout.LabelField($"Unreferenced Assets: {_unusedAssets.Count}");

                if (_unusedAssets.Count > 0)
                {
                    _pagesScroll = EditorGUILayout.BeginScrollView(_pagesScroll);

                    EditorGUILayout.BeginHorizontal();

                    var prevColor = GUI.color;
                    GUI.color = !_pageToShow.HasValue ? Color.yellow : Color.white;

                    if (GUILayout.Button("All", GUILayout.Width(30f)))
                    {
                        _pageToShow = null;
                    }

                    GUI.color = prevColor;

                    var totalCount = _unusedAssets.Count;
                    var pagesCount = totalCount / PageSize + (totalCount % PageSize > 0 ? 1 : 0);

                    for (var i = 0; i < pagesCount; i++)
                    {
                        prevColor = GUI.color;
                        GUI.color = _pageToShow == i ? Color.yellow : Color.white;

                        if (GUILayout.Button((i + 1).ToString(), GUILayout.Width(30f)))
                        {
                            _pageToShow = i;
                        }

                        GUI.color = prevColor;
                    }

                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.EndScrollView();
                }
            }

            EditorGUILayout.Separator();

            _assetsScroll = GUILayout.BeginScrollView(_assetsScroll);

            EditorGUILayout.BeginVertical();

            for (var i = 0; i < _unusedAssets.Count; i++)
            {
                if (_pageToShow.HasValue)
                {
                    var page = _pageToShow.Value;
                    if (i < page * PageSize || i >= (page + 1) * PageSize)
                    {
                        continue;
                    }
                }

                var unusedAssetPath = _unusedAssets[i];
                EditorGUILayout.BeginHorizontal();

                var type     = AssetDatabase.GetMainAssetTypeAtPath(unusedAssetPath);
                var typeName = type.ToString();
                typeName = typeName.Replace("UnityEngine.", string.Empty);
                typeName = typeName.Replace("UnityEditor.", string.Empty);

                EditorGUILayout.LabelField(i.ToString(), GUILayout.Width(40f));
                EditorGUILayout.LabelField(typeName, GUILayout.Width(150f));

                var guiContent = EditorGUIUtility.ObjectContent(null, type);
                guiContent.text = Path.GetFileName(unusedAssetPath);

                var alignment = GUI.skin.button.alignment;
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;

                if (GUILayout.Button(guiContent,
                                     GUILayout.Width(300f),
                                     GUILayout.Height(18f)))
                {
                    Selection.objects = new[] { AssetDatabase.LoadMainAssetAtPath(unusedAssetPath) };
                }

                GUI.skin.button.alignment = alignment;

                EditorGUILayout.LabelField(unusedAssetPath);

                EditorGUILayout.EndHorizontal();
            }

            GUILayout.FlexibleSpace();

            EditorGUILayout.EndVertical();
            GUILayout.EndScrollView();
        }
Exemplo n.º 8
0
        public override void OnInspectorGUI()
        {
            //I18N key
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("I18N Key", GUILayout.Width(65));
            EditorGUILayout.PropertyField(this.serializedObject.FindProperty("I18NKey"), GUIContent.none);
            if (GUILayout.Button("Refresh", GUILayout.MaxWidth(55)))
            {
                var _target = (TextLocalized)target;
                var text    = ((TextLocalized)target).GetComponent <Text>();
                if (text != null)
                {
                    text.text = I18NEditorManager.GetText(_target.I18NKey, _target.I18NGroup, _target.I18NKey);
                }
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("I18N Group", GUILayout.Width(65));
            EditorGUILayout.PropertyField(this.serializedObject.FindProperty("I18NGroup"), GUIContent.none);
            EditorGUILayout.EndHorizontal();

            // 搜索
            GUILayout.Space(10);
            if (!mShowSearchGUI)
            {
                if (GUILayout.Button("Search", GUILayout.MaxWidth(150)))
                {
                    mShowSearchGUI = true;
                }
            }

            if (mShowSearchGUI)
            {
                if (mSearchIcon == null)
                {
                    mSearchIcon = AssetDatabase.LoadAssetAtPath <Texture>("Packages/io.nekonya.tinax.i18n/Editor/Res/Icon/Search.png");
                }
                if (mSelectIcon == null)
                {
                    mSelectIcon = AssetDatabase.LoadAssetAtPath <Texture>("Packages/io.nekonya.tinax.i18n/Editor/Res/Icon/select.png");
                }

                EditorGUILayout.BeginHorizontal();
                mSearchText = EditorGUILayout.TextField(mSearchText, EditorStyles.toolbarSearchField);
                if (GUILayout.Button(new GUIContent(mSearchIcon, "Search"), GUILayout.MaxWidth(25), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight)))
                {
                    mSearchResult = I18NEditorManager.SearchKeyOrValue(mSearchText);
                }
                EditorGUILayout.EndHorizontal();

                if (mSearchResult != null)
                {
                    EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                    if (mSearchResult.Count == 0)
                    {
                        GUILayout.Label("No Result, Please try to refresh data.");
                    }
                    else
                    {
                        var rect = EditorGUILayout.GetControlRect();
                        if (rect.width > 20)
                        {
                            max_width = rect.width;
                        }
                        mV2_Result = EditorGUILayout.BeginScrollView(mV2_Result, GUILayout.MaxHeight(200), GUILayout.MinHeight(40));
                        foreach (var item in mSearchResult)
                        {
                            GUILayout.Label(item.Key, EditorStyles.boldLabel);
                            foreach (var kv in item.Value)
                            {
                                EditorGUILayout.BeginHorizontal();
                                EditorGUILayout.LabelField(kv.Key, GUILayout.MaxWidth((max_width - 45) / 2));
                                EditorGUILayout.LabelField("|" + kv.Value, GUILayout.MaxWidth((max_width - 45) / 2));
                                if (GUILayout.Button(new GUIContent(mSelectIcon, "select it"), GUILayout.MaxHeight(EditorGUIUtility.singleLineHeight), GUILayout.MaxWidth(25)))
                                {
                                    this.serializedObject.FindProperty("I18NKey").stringValue   = kv.Key;
                                    this.serializedObject.FindProperty("I18NGroup").stringValue = item.Key;
                                    var text = ((TextLocalized)target).GetComponent <Text>();
                                    if (text != null)
                                    {
                                        text.text = kv.Value;
                                    }
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndScrollView();
                    }

                    EditorGUILayout.EndVertical();
                }
            }

            this.serializedObject.ApplyModifiedProperties();
            //base.OnInspectorGUI();
        }
Exemplo n.º 9
0
        void OnGUI()
        {
            if (itemStyle == null)
            {
                itemStyle = new GUIStyle(GUI.skin.GetStyle("IN Toggle"));
                itemStyle.normal.background    = null;
                itemStyle.onNormal.background  = GUI.skin.GetStyle("ObjectPickerResultsEven").active.background;
                itemStyle.focused.background   = null;
                itemStyle.onFocused.background = null;
                itemStyle.hover.background     = null;
                itemStyle.onHover.background   = null;
                itemStyle.active.background    = null;
                itemStyle.onActive.background  = null;
                itemStyle.margin.top           = 0;
                itemStyle.margin.bottom        = 0;
            }

            EditorGUILayout.BeginHorizontal();

            //package list start------
            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Packages", (GUIStyle)"OL Title", GUILayout.Width(300));

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);

            scrollPos1 = EditorGUILayout.BeginScrollView(scrollPos1, (GUIStyle)"CN Box", GUILayout.Height(300), GUILayout.Width(300));
            EditorToolSet.LoadPackages();
            List <UIPackage> pkgs = UIPackage.GetPackages();
            int cnt = pkgs.Count;

            if (cnt == 0)
            {
                selectedPackage     = -1;
                selectedPackageName = null;
            }
            else
            {
                for (int i = 0; i < cnt; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Space(4);
                    if (GUILayout.Toggle(selectedPackageName == pkgs[i].name, pkgs[i].name, itemStyle, GUILayout.ExpandWidth(true)))
                    {
                        selectedPackage     = i;
                        selectedPackageName = pkgs[i].name;
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

            //package list end------

            //component list start------

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(5);

            EditorGUILayout.BeginVertical();
            GUILayout.Space(10);
            EditorGUILayout.LabelField("Components", (GUIStyle)"OL Title", GUILayout.Width(220));

            EditorGUILayout.BeginHorizontal();
            GUILayout.Space(4);

            scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2, (GUIStyle)"CN Box", GUILayout.Height(300), GUILayout.Width(220));
            if (selectedPackage >= 0)
            {
                List <PackageItem> items = pkgs[selectedPackage].GetItems();
                int i = 0;
                foreach (PackageItem pi in items)
                {
                    if (pi.type == PackageItemType.Component && pi.exported)
                    {
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Space(4);
                        if (GUILayout.Toggle(selectedComponentName == pi.name, pi.name, itemStyle, GUILayout.ExpandWidth(true)))
                        {
                            selectedComponentName = pi.name;
                        }
                        i++;
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            EditorGUILayout.EndScrollView();

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.EndVertical();

            EditorGUILayout.EndHorizontal();

            //component list end------

            GUILayout.Space(10);

            EditorGUILayout.EndHorizontal();

            GUILayout.Space(20);

            //buttons start---
            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(180);

            if (GUILayout.Button("Refresh", GUILayout.Width(100)))
            {
                EditorToolSet.ReloadPackages();
            }

            GUILayout.Space(20);
            if (GUILayout.Button("OK", GUILayout.Width(100)) && selectedPackage >= 0)
            {
                UIPackage selectedPkg = pkgs[selectedPackage];
                string    tmp         = selectedPkg.assetPath.ToLower();
                string    packagePath;
                int       pos = tmp.LastIndexOf("resources/");
                if (pos != -1)
                {
                    packagePath = selectedPkg.assetPath.Substring(pos + 10);
                }
                else
                {
                    packagePath = selectedPkg.assetPath;
                }
                bool isPrefab = PrefabUtility.GetPrefabType(Selection.activeGameObject) == PrefabType.Prefab;

                Selection.activeGameObject.SendMessage("OnUpdateSource",
                                                       new object[] { selectedPkg.name, packagePath, selectedComponentName, !isPrefab },
                                                       SendMessageOptions.DontRequireReceiver);
#if UNITY_5_3_OR_NEWER
                EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
#elif UNITY_5
                EditorApplication.MarkSceneDirty();
#else
                EditorUtility.SetDirty(Selection.activeGameObject);
#endif
                this.Close();
            }

            EditorGUILayout.EndHorizontal();
        }
Exemplo n.º 10
0
        private void OnGUI()
        {
            // In case resolutionsEnabled didn't exist when the latest SessionData was created
            if (resolutionsEnabled == null || resolutionsEnabled.Count != resolutions.Count)
            {
                resolutionsEnabled = new List <bool>(resolutions.Count);
                for (int i = 0; i < resolutions.Count; i++)
                {
                    resolutionsEnabled.Add(true);
                }
            }

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            GUILayout.BeginHorizontal();

            GUILayout.Label("Resolutions:", GL_EXPAND_WIDTH);

            if (GUILayout.Button("Save"))
            {
                SaveSettings();
            }

            if (GUILayout.Button("Load"))
            {
                LoadSettings();
            }

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUI.enabled = currentResolutionEnabled;
            GUILayout.Label("Current Resolution", GL_EXPAND_WIDTH);
            GUI.enabled = true;

            currentResolutionEnabled = EditorGUILayout.Toggle(GUIContent.none, currentResolutionEnabled, GL_WIDTH_25);

            if (GUILayout.Button("+", GL_WIDTH_25))
            {
                resolutions.Insert(0, new Vector2());
                resolutionsEnabled.Insert(0, true);
            }

            GUI.enabled = false;
            GUILayout.Button("-", GL_WIDTH_25);
            GUI.enabled = true;

            GUILayout.EndHorizontal();

            for (int i = 0; i < resolutions.Count; i++)
            {
                GUILayout.BeginHorizontal();

                GUI.enabled           = resolutionsEnabled[i];
                resolutions[i]        = EditorGUILayout.Vector2Field(GUIContent.none, resolutions[i]);
                GUI.enabled           = true;
                resolutionsEnabled[i] = EditorGUILayout.Toggle(GUIContent.none, resolutionsEnabled[i], GL_WIDTH_25);

                if (GUILayout.Button("+", GL_WIDTH_25))
                {
                    resolutions.Insert(i + 1, new Vector2());
                    resolutionsEnabled.Insert(i + 1, true);
                }

                if (GUILayout.Button("-", GL_WIDTH_25))
                {
                    resolutions.RemoveAt(i);
                    resolutionsEnabled.RemoveAt(i);
                    i--;
                }

                GUILayout.EndHorizontal();
            }

            EditorGUILayout.Space();

            resolutionMultiplier = EditorGUILayout.FloatField("Resolution Multiplier", resolutionMultiplier);
            targetCamera         = (TargetCamera)EditorGUILayout.EnumPopup("Target Camera", targetCamera);

            EditorGUILayout.Space();

            if (targetCamera == TargetCamera.GameView)
            {
                captureOverlayUI = EditorGUILayout.ToggleLeft("Capture Overlay UI", captureOverlayUI);
                if (captureOverlayUI && EditorApplication.isPlaying)
                {
                    EditorGUI.indentLevel++;
                    setTimeScaleToZero = EditorGUILayout.ToggleLeft("Set timeScale to 0 during capture", setTimeScaleToZero);
                    EditorGUI.indentLevel--;
                }
            }

            saveAsPNG = EditorGUILayout.ToggleLeft("Save as PNG", saveAsPNG);
            if (saveAsPNG && !captureOverlayUI && targetCamera == TargetCamera.GameView)
            {
                EditorGUI.indentLevel++;
                allowTransparentBackground = EditorGUILayout.ToggleLeft("Allow transparent background", allowTransparentBackground);
                if (allowTransparentBackground)
                {
                    EditorGUILayout.HelpBox("For transparent background to work, you may need to disable post-processing on the Main Camera.", MessageType.Info);
                }
                EditorGUI.indentLevel--;
            }

            EditorGUILayout.Space();

            saveDirectory = PathField("Save to:", saveDirectory);

            EditorGUILayout.Space();

            GUI.enabled = queuedScreenshots.Count == 0 && resolutionMultiplier > 0f;
            if (GUILayout.Button("Capture Screenshots"))
            {
                if (string.IsNullOrEmpty(saveDirectory))
                {
                    saveDirectory = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory);
                }

                if (currentResolutionEnabled)
                {
                    CaptureScreenshot((targetCamera == TargetCamera.GameView ? Camera.main : SceneView.lastActiveSceneView.camera).pixelRect.size);
                }

                for (int i = 0; i < resolutions.Count; i++)
                {
                    if (resolutionsEnabled[i])
                    {
                        CaptureScreenshot(resolutions[i]);
                    }
                }

                if (!captureOverlayUI || targetCamera == TargetCamera.SceneView)
                {
                    Debug.Log("<b>Saved screenshots:</b> " + saveDirectory);
                }
                else
                {
                    if (EditorApplication.isPlaying && setTimeScaleToZero)
                    {
                        prevTimeScale  = Time.timeScale;
                        Time.timeScale = 0f;
                    }

                    EditorApplication.update -= CaptureQueuedScreenshots;
                    EditorApplication.update += CaptureQueuedScreenshots;
                }
            }
            GUI.enabled = true;

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 11
0
        public override void OnGUI(Rect rect)
        {
            GUILayout.BeginArea(rect);
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos);
                {
                    EGUI.BeginLabelWidth(60);
                    {
                        EditorGUILayout.LabelField(Contents.NewDataContent, EGUIStyles.MiddleCenterLabel);

                        EditorGUILayout.Space();

                        string dataKey = newData.Key;
                        dataKey = EditorGUILayout.TextField(Contents.DataNameContent, dataKey);
                        if (newData.Key != dataKey)
                        {
                            newData.Key = dataKey;
                            if (string.IsNullOrEmpty(dataKey))
                            {
                                errorMessage = Contents.DataNameEmptyStr;
                            }
                            else
                            {
                                if ((group.AsDynamic()).dataDic.ContainsKey(newData.Key))
                                {
                                    errorMessage = Contents.DataNameRepeatStr;
                                }
                                else
                                {
                                    errorMessage = null;
                                }
                            }
                        }

                        if (newData.OptionValues != null && newData.OptionValues.Length > 0)
                        {
                            newData.Value = EGUILayout.StringPopup(Contents.DataValueContent, newData.Value, newData.OptionValues);
                        }
                        else
                        {
                            newData.Value = EditorGUILayout.TextField(Contents.DataValueContent, newData.Value);
                        }

                        newData.Comment = EditorGUILayout.TextField(Contents.DataCommentContent, newData.Comment);
                        optionValuesRList.DoLayoutList();

                        if (!string.IsNullOrEmpty(errorMessage))
                        {
                            EditorGUILayout.HelpBox(errorMessage, MessageType.Error);
                        }
                        else
                        {
                            GUILayout.FlexibleSpace();

                            if (GUILayout.Button(Contents.SaveStr))
                            {
                                newData.OptionValues = optionValues.ToArray();

                                group.AddData(newData.Key, newData.Value, newData.Comment, newData.OptionValues);

                                onCreatedCallback?.Invoke(group.Name, newData.Key);
                                editorWindow.Close();
                            }
                        }
                    }
                    EGUI.EndLableWidth();
                }
                EditorGUILayout.EndScrollView();
            }
            GUILayout.EndArea();
        }
Exemplo n.º 12
0
 private void DrawSpriteInfo()
 {
     if (spriteInfoList == null)
     {
         return;
     }
     mListScrollPos = EditorGUILayout.BeginScrollView(mListScrollPos);
     //mIsListExpand = EditorGUILayout.Foldout(mIsListExpand, "图片列表");
     //if (mIsListExpand)
     //{
     //    foreach (var info in spriteInfoList)
     //    {
     //        EditorGUILayout.BeginHorizontal(GUILayout.Width(380));
     //        GUILayout.Space(30);
     //        GUILayout.Label(info.Atlas.name + " - " + info.Data.name);
     //        //info.Selected = EditorGUILayout.ToggleLeft(info.SpriteName, info.Selected, GUILayout.Width(240));
     //        EditorGUILayout.EndHorizontal();
     //    }
     //}
     mIsDicExpand = EditorGUILayout.Foldout(mIsDicExpand, "比对结果");
     if (mIsDicExpand)
     {
         int i       = 0;
         int size    = 80;
         int padded  = 90;
         int columns = Mathf.FloorToInt(Screen.width / padded);
         if (columns < 1)
         {
             columns = 1;
         }
         GUILayout.Space(100);
         foreach (var info in spriteInfoDic)
         {
             #region 图标绘制
             int       y    = i / columns;
             int       x    = i - columns * y;
             Texture2D tex  = info.Value.Atlas.texture as Texture2D;
             Rect      rect = new Rect(10f + x * (padded), 20 + y * (padded + 20), size, size);
             Rect      uv   = new Rect(info.Value.Data.x, info.Value.Data.y, info.Value.Data.width, info.Value.Data.height);
             uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);
             float scaleX = rect.width / uv.width;
             float scaleY = rect.height / uv.height;
             //把图标拉伸到正常大小
             float aspect   = (scaleY / scaleX) / ((float)tex.height / tex.width);
             Rect  clipRect = rect;
             if (aspect != 1f)
             {
                 if (aspect < 1f)
                 {
                     // The sprite is taller than it is wider
                     float padding = 80 * (1f - aspect) * 0.5f;
                     clipRect.xMin += padding;
                     clipRect.xMax -= padding;
                 }
                 else
                 {
                     // The sprite is wider than it is taller
                     float padding = 80 * (1f - 1f / aspect) * 0.5f;
                     clipRect.yMin += padding;
                     clipRect.yMax -= padding;
                 }
             }
             //画出外框
             if (info.Value.Selected)
             {
                 NGUIEditorTools.DrawOutline(new Rect(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2), Color.green);
             }
             else
             {
                 NGUIEditorTools.DrawOutline(new Rect(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2), Color.grey);
             }
             //画出按钮
             if (GUI.Button(rect, ""))
             {
                 info.Value.Selected = !info.Value.Selected;
             }
             GUI.DrawTextureWithTexCoords(clipRect, tex, uv);
             #endregion
             #region 文字绘制和空白留出
             GUI.Label(new Rect(rect.x, rect.y + size, rect.width, rect.height), info.Value.Data.name);
             GUI.Label(new Rect(rect.x, rect.y + size + 10, rect.width, rect.height), info.Value.Atlas.name);
             if (x == 0)
             {
                 GUILayout.Space(100);
             }
             #endregion
             i++;
         }
     }
     EditorGUILayout.EndScrollView();
 }
Exemplo n.º 13
0
        void showItems()
        {
            GUILayout.Label("Items to Export");
            GUILayout.Space(3f);
            GUIStyle styleScrollView = new GUIStyle(GUI.skin.scrollView);

            styleScrollView.normal.background = GUI.skin.GetStyle("GroupElementBG").onNormal.background;
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, styleScrollView);
            if (didLoad)
            {
                if (gameObjs.Where(p => p != null && p.GetComponent <AnimatorData>() != null).ToList().Count >= 1)
                {
                    GUILayout.BeginHorizontal(GUILayout.Height(height_gameobject));
                    GUI.enabled = false;
                    GUILayout.Toggle(true, "", GUILayout.Width(width_toggle));
                    GUILayout.Space(15f);
                    GUILayout.BeginVertical();
                    GUILayout.Space(height_label_offset);
                    GUILayout.Label(new GUIContent("AnimatorData (" + (take == null ? "All Takes" : take.name) + ")", EditorGUIUtility.ObjectContent(null, typeof(MonoBehaviour)).image));
                    GUILayout.EndVertical();
                    GUI.enabled = true;
                    GUILayout.EndHorizontal();
                }
                bool?      isOpen            = null;
                int        lastDepth         = 0;
                List <int> gameObjectsToShow = new List <int>();
                for (int i = 0; i < gameObjs.Count; i++)
                {
                    if (gameObjs[i] == null)
                    {
                        continue;
                    }
                    if (gameObjs[i].GetComponent <AnimatorData>() != null)
                    {
                        continue;
                    }
                    if (isOpen == false && lastDepth < gameObjsDepth[i])
                    {
                        continue;
                    }
                    isOpen    = gameObjsFoldout[i];
                    lastDepth = gameObjsDepth[i];
                    gameObjectsToShow.Add(i);
                }
                int maxGameObjects = Mathf.CeilToInt((position.height - 62f) / height_gameobject);
                maxGameObjects = Mathf.Clamp(maxGameObjects, 0, gameObjectsToShow.Count);
                int FirstIndex = Mathf.FloorToInt(scrollPos.y / height_gameobject) - 1;
                FirstIndex = Mathf.Clamp(FirstIndex, 0, gameObjectsToShow.Count);
                int LastIndex = FirstIndex + maxGameObjects;
                LastIndex = Mathf.Clamp(LastIndex, 0, gameObjectsToShow.Count);
                if (LastIndex - FirstIndex < maxGameObjects)
                {
                    FirstIndex = Mathf.Clamp(LastIndex - maxGameObjects, 0, gameObjectsToShow.Count);
                }
                for (int i = 0; i < gameObjectsToShow.Count; i++)
                {
                    if (gameObjectsToShow.Count > maxGameObjects && (i < FirstIndex || i > LastIndex))
                    {
                        GUILayout.Space(height_gameobject);
                    }
                    else
                    {
                        showGameObject(gameObjectsToShow[i], gameObjsDepth[gameObjectsToShow[i]]);
                    }
                }
            }
            else
            {
                GUILayout.Label("Loading...");
                GUI.enabled = false;
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 14
0
        private void EmbedPackageGUI()
        {
            if (PackageGuiUtility.SourcePathGui())
            {
                Refresh();
            }

            EditorGUI.BeginChangeCheck();
            displayName = EditorGUILayout.Toggle("ShowDisplayName", displayName);
            if (EditorGUI.EndChangeCheck())
            {
                SortPackageList();
            }

            bool refreshAssets = false;

            scrollPt = EditorGUILayout.BeginScrollView(scrollPt, GUILayout.ExpandHeight(false));
            foreach (var sourcePkg in sourcePackages)
            {
                EditorGUILayout.BeginHorizontal("box");

                if (displayName)
                {
                    EditorGUILayout.LabelField(sourcePkg.packageInfo?.displayName);
                }
                else
                {
                    EditorGUILayout.LabelField(sourcePkg.packageInfo?.name);
                }

                if (sourcePkg.status == SourcePackageInfo.Status.Error)
                {
                    EditorGUILayout.LabelField("Error", GUILayout.Width(60));
                }
                else if (sourcePkg.status == SourcePackageInfo.Status.Embeded)
                {
                    EditorGUILayout.LabelField("Embeded", GUILayout.Width(60));
                }
                else if (GUILayout.Button("Embed", GUILayout.Width(60)))
                {
                    try
                    {
                        //Create a softlink to the source package in our local package directory
                        var source = sourcePkg.directoryInfo.FullName;
                        var dest   = $"{Application.dataPath}/../Packages/{sourcePkg.directoryInfo.Name}";
                        if (!ShellUtility.CreateSymbolicLink(source, dest))
                        {
                            EditorApplication.Beep();
                            EditorUtility.DisplayDialog("Package Embed", "Failed to create symbolic link. Package was not embedded.",
                                                        "OK");
                        }
                        else
                        {
                            refreshAssets = true;
                            EditorUtility.DisplayDialog("Package Embed", "Done",
                                                        "OK");
                        }
                    }
                    catch (Exception e)
                    {
                        Debug.LogException(e);
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();

            //Doing this outside of the foreach loop to avoid layout and enum errors
            if (refreshAssets)
            {
                AssetDatabase.Refresh();
                GUIUtility.ExitGUI();
            }

            RefreshGUI();
        }
Exemplo n.º 15
0
        private void PaintStats()
        {
            EditorGUILayout.BeginHorizontal(this.suggestionHeaderStyle);
            EditorGUILayout.LabelField("Stats", EditorStyles.boldLabel);
            EditorGUILayout.EndHorizontal();

            this.scroll = EditorGUILayout.BeginScrollView(this.scroll);
            int statsCount = this.statsCollection.Length;

            if (statsCount > 0)
            {
                for (int i = 0; i < statsCount; ++i)
                {
                    if (this.statsCollection == null)
                    {
                        continue;
                    }

                    string statName = this.statsCollection[i].stat.uniqueName;
                    if (string.IsNullOrEmpty(statName))
                    {
                        statName = "No Name";
                    }
                    GUIContent statContent = new GUIContent(statName);

                    Rect statRect     = GUILayoutUtility.GetRect(statContent, this.statStyle);
                    bool statHasFocus = (i == this.statIndex);
                    bool mouseEnter   = statHasFocus && UnityEngine.Event.current.type == EventType.MouseDown;

                    if (UnityEngine.Event.current.type == EventType.Repaint)
                    {
                        this.statStyle.Draw(
                            statRect,
                            statContent,
                            statHasFocus,
                            statHasFocus,
                            false,
                            false
                            );
                    }

                    if (this.statIndex == i)
                    {
                        this.statSelectedRect = statRect;
                    }

                    if (statHasFocus)
                    {
                        if (mouseEnter || this.keyPressedEnter)
                        {
                            if (this.keyPressedEnter)
                            {
                                UnityEngine.Event.current.Use();
                            }
                            this.property.objectReferenceValue = this.statsCollection[i];
                            this.property.serializedObject.ApplyModifiedProperties();
                            this.property.serializedObject.Update();

                            this.editorWindow.Close();
                        }
                    }

                    if (UnityEngine.Event.current.type == EventType.MouseMove &&
                        GUILayoutUtility.GetLastRect().Contains(UnityEngine.Event.current.mousePosition))
                    {
                        this.statIndex = i;
                    }
                }

                if (this.keyPressedDown && this.statIndex < statsCount - 1)
                {
                    this.statIndex++;
                    UnityEngine.Event.current.Use();
                }
                else if (this.keyPressedUp && this.statIndex > 0)
                {
                    this.statIndex--;
                    UnityEngine.Event.current.Use();
                }
            }

            EditorGUILayout.EndScrollView();
            float scrollHeight = GUILayoutUtility.GetLastRect().height;

            if (UnityEngine.Event.current.type == EventType.Repaint && this.keyFlagVerticalMoved)
            {
                this.keyFlagVerticalMoved = false;
                if (this.statSelectedRect != Rect.zero)
                {
                    bool isUpperLimit = this.scroll.y > this.statSelectedRect.y;
                    bool isLowerLimit = (this.scroll.y + scrollHeight <
                                         this.statSelectedRect.position.y + this.statSelectedRect.size.y
                                         );

                    if (isUpperLimit)
                    {
                        this.scroll = Vector2.up * (this.statSelectedRect.position.y);
                        this.editorWindow.Repaint();
                    }
                    else if (isLowerLimit)
                    {
                        float positionY = this.statSelectedRect.y + this.statSelectedRect.height - scrollHeight;
                        this.scroll = Vector2.up * positionY;
                        this.editorWindow.Repaint();
                    }
                }
            }
        }
Exemplo n.º 16
0
        void OnGUI()
        {
            GUILayout.Label("Environments", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("Following environment were automatically detected:", UnityEditor.MessageType.None);

            EnvironmentScroll = EditorGUILayout.BeginScrollView(EnvironmentScroll);

            if (Environments.Keys.Count != 0)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
                if (GUILayout.Button("Select All", GUILayout.ExpandWidth(false)))
                {
                    foreach (var key in Environments.Keys.ToArray())
                    {
                        Environments[key] = true;
                    }
                }
                if (GUILayout.Button("Select None", GUILayout.ExpandWidth(false)))
                {
                    foreach (var key in Environments.Keys.ToArray())
                    {
                        Environments[key] = false;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            foreach (var name in Environments.Keys.OrderBy(name => name))
            {
                var check = Environments[name];
                if (check.HasValue)
                {
                    Environments[name] = GUILayout.Toggle(check.Value, name);
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(true);
                    GUILayout.Toggle(false, $"{name} (missing Environments/{name}/{name}.{SceneExtension} file)");
                    EditorGUI.EndDisabledGroup();
                }
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Label("Vehicles", EditorStyles.boldLabel);
            EditorGUILayout.HelpBox("Following vehicles were automatically detected:", UnityEditor.MessageType.None);

            VehicleScroll = EditorGUILayout.BeginScrollView(VehicleScroll);

            if (Vehicles.Keys.Count != 0)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
                if (GUILayout.Button("Select All", GUILayout.ExpandWidth(false)))
                {
                    foreach (var key in Vehicles.Keys.ToArray())
                    {
                        Vehicles[key] = true;
                    }
                }
                if (GUILayout.Button("Select None", GUILayout.ExpandWidth(false)))
                {
                    foreach (var key in Vehicles.Keys.ToArray())
                    {
                        Vehicles[key] = false;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            foreach (var name in Vehicles.Keys.OrderBy(name => name))
            {
                var check = Vehicles[name];
                if (check.HasValue)
                {
                    Vehicles[name] = GUILayout.Toggle(check.Value, name);
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(true);
                    GUILayout.Toggle(false, $"{name} (missing Vehicles/{name}/{name}.{PrefabExtension} file)");
                    EditorGUI.EndDisabledGroup();
                }
            }

            EditorGUILayout.EndScrollView();

            GUILayout.Label("Options", EditorStyles.boldLabel);

            Target = (BuildTarget)EditorGUILayout.EnumPopup("Executable Platform:", Target);

            EditorGUILayout.HelpBox("Select Folder to Save...", MessageType.Info);

            EditorGUILayout.BeginHorizontal(GUILayout.ExpandHeight(false));
            BuildPlayer = GUILayout.Toggle(BuildPlayer, "Build Simulator:", GUILayout.ExpandWidth(false));

            EditorGUI.BeginDisabledGroup(!BuildPlayer);
            PlayerFolder = GUILayout.TextField(PlayerFolder);
            if (GUILayout.Button("...", GUILayout.ExpandWidth(false)))
            {
                var folder = EditorUtility.SaveFolderPanel("Select Folder", PlayerFolder, string.Empty);
                if (!string.IsNullOrEmpty(folder))
                {
                    PlayerFolder = Path.GetFullPath(folder);
                }
            }
            EditorGUILayout.EndHorizontal();

            DevelopmentPlayer = GUILayout.Toggle(DevelopmentPlayer, "Development Build");
            EditorGUI.EndDisabledGroup();

            if (GUILayout.Button("Build"))
            {
                Running = true;
                try
                {
                    var assetBundlesLocation = Path.Combine(Application.dataPath, "..", "AssetBundles");
                    if (BuildPlayer)
                    {
                        if (string.IsNullOrEmpty(PlayerFolder))
                        {
                            Debug.LogError("Please specify simulator build folder!");
                            return;
                        }
                        RunPlayerBuild(Target, PlayerFolder, DevelopmentPlayer);

                        assetBundlesLocation = Path.Combine(PlayerFolder, "AssetBundles");
                    }

                    var environments = Environments.Where(kv => kv.Value.HasValue && kv.Value.Value).Select(kv => kv.Key);
                    var vehicles     = Vehicles.Where(kv => kv.Value.HasValue && kv.Value.Value).Select(kv => kv.Key);

                    RunAssetBundleBuild(assetBundlesLocation, environments.ToList(), vehicles.ToList());
                }
                finally
                {
                    Running = false;
                }
            }
        }
Exemplo n.º 17
0
    /// <summary>
    /// Called on GUI events.
    /// </summary>
    internal void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        this.scrollPos = EditorGUILayout.BeginScrollView(this.scrollPos, false, false);



        //GUILayout.Label("Scenes In Folder", EditorStyles.boldLabel);

        //string folderPath = Path.Combine(Application.dataPath, EDITOR_LEVELS_FILE_DIRECTORY);
        //string[] files = Directory.GetFiles(folderPath, "*.unity");
        //for (var i = 0; i < files.Length; i++)
        //{
        //    var pressed = GUILayout.Button(i + ": " + Path.GetFileNameWithoutExtension(files[i]), new GUIStyle(GUI.skin.GetStyle("Button")) { alignment = TextAnchor.MiddleLeft });
        //    if (pressed)
        //    {
        //        if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
        //        {
        //            EditorSceneManager.OpenScene(files[i]);
        //        }
        //    }
        //}



        foreach (var g in scenesData.SceneGroups)
        {
            g.Visisble = EditorGUILayout.Foldout(g.Visisble, g.GroupName);
            if (g.Visisble)
            {
                foreach (var s in g.Scenes)
                {
                    if (GUILayout.Button(s.SceneName))
                    {
                        if (EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
                        {
                            EditorSceneManager.OpenScene(s.ScenePath);
                        }
                    }
                }
            }
        }

        EditorGUILayout.LabelField("", GUI.skin.horizontalSlider);
        GUILayout.Space(10);

        if (GUILayout.Button("Find Scenes"))
        {
            var rootFolder = EditorUtility.OpenFolderPanel("Select Folder", Application.dataPath, "Scenes");
            if (string.IsNullOrEmpty(rootFolder) == false)
            {
                try
                {
                    var dirs = Directory.GetDirectories(rootFolder);
                    scenesData.SceneGroups = new List <SceneGroup>();
                    foreach (var d in dirs)
                    {
                        var info = new DirectoryInfo(d);

                        var scenes = AssetDatabase.FindAssets("t:Scene", new string[] { d.Substring(d.IndexOf("Assets")) });
                        if (scenes.Length > 0)
                        {
                            scenesData.SceneGroups.Add(new SceneGroup
                            {
                                GroupName = info.Name,
                                Scenes    = scenes.Select(scene_guid =>
                                {
                                    var scenePath = AssetDatabase.GUIDToAssetPath(scene_guid);
                                    var sceneInfo = new FileInfo(scenePath);
                                    return(new SceneData()
                                    {
                                        SceneName = sceneInfo.Name,
                                        ScenePath = scenePath
                                    });
                                }).ToList()
                            });
                        }
                    }
                }
                catch (Exception ex)
                {
                    Debug.LogError(ex);
                }
            }
        }
        if (GUILayout.Button("Save Settings"))
        {
            var path = EditorUtility.SaveFilePanel(
                "Save JSON settings",
                Application.dataPath,
                "scenes.json",
                "json");

            try
            {
                var json = JsonUtility.ToJson(scenesData);
                File.WriteAllText(path, json);
                EditorPrefs.SetString(SETTINGS_FILE_PATH_KEY, path);
            }
            catch (Exception ex)
            {
                EditorUtility.DisplayDialog("Error", ex.Message, "Close");
            }
        }

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
Exemplo n.º 18
0
    public override void OnInspectorGUI()
    {
//this is so that it always updates correct target
        childScript = (AIControllerChild)target;


        EditorGUILayout.LabelField("AI Property Controller");
        EditorGUILayout.Space();


        if (PrefabUtility.GetPrefabType(childScript.gameObject) == PrefabType.Prefab)
        {
            EditorGUILayout.LabelField("Parameters can't be edited using the Overview Panel if the AI is a prefab.");
            return;
        }



        showFoldout1 = EditorGUILayout.Foldout(showFoldout1, "Main Referencing Objects");

//main referencing objects
        if (showFoldout1)
        {
            EditorGUILayout.Space();
            patrolManager = EditorGUILayout.ObjectField("Patrol Manager", patrolManager, typeof(Object), true) as GameObject;
            sensorParent  = EditorGUILayout.ObjectField("Sensor Parent", sensorParent, typeof(Object), true) as GameObject;
            ears          = EditorGUILayout.ObjectField("Ears Object", ears, typeof(Object), true) as GameObject;
            sight         = EditorGUILayout.ObjectField("Sight Object", sight, typeof(Object), true) as GameObject;
            model         = EditorGUILayout.ObjectField("Model Object", model, typeof(Object), true) as GameObject;
            EditorGUILayout.Space();
        }

        showFoldout2 = EditorGUILayout.Foldout(showFoldout2, "Data About AI Character");

//Data About AI Character
        if (showFoldout2)
        {
            EditorGUILayout.Space();
            eyeHeight = EditorGUILayout.Vector3Field("Relative Eye Height", eyeHeight);
            EditorGUILayout.Space();
            health = EditorGUILayout.FloatField("Health", health);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Disengaging Hits To Knockout");
            disengagingHitsToKnockout = EditorGUILayout.FloatField(disengagingHitsToKnockout);
            EditorGUILayout.EndHorizontal();
            radius = EditorGUILayout.FloatField("Radius", radius);
            height = EditorGUILayout.FloatField("Height", height);
            EditorGUILayout.Space();
        }

        showFoldout3 = EditorGUILayout.Foldout(showFoldout3, "Data About Enemies");

//Data About Enemies
        if (showFoldout3)
        {
            EditorGUILayout.Space();
            tagOfEnemy          = EditorGUILayout.TagField("Tag Of Enemy", tagOfEnemy);
            tagOfBullet         = EditorGUILayout.TagField("Tag Of Bullet", tagOfBullet);
            enemyCriticalHeight = EditorGUILayout.Vector3Field("Enemy Critical Height", enemyCriticalHeight);
            EditorGUILayout.Space();
        }

        showFoldout4 = EditorGUILayout.Foldout(showFoldout4, "Reaction Times");

//Reaction Times
        if (showFoldout4)
        {
            EditorGUILayout.Space();
            shockTime                       = EditorGUILayout.FloatField("Reaction To Enemy", shockTime);
            freezeTime                      = EditorGUILayout.FloatField("Freeze Time To Bullet", freezeTime);
            minCoverTime                    = EditorGUILayout.FloatField("Minimum Time In Cover", minCoverTime);
            maxCoverTime                    = EditorGUILayout.FloatField("Maximum Time In Cover", maxCoverTime);
            timeBetweenEnemyChecks          = EditorGUILayout.FloatField("Enemy Checks", timeBetweenEnemyChecks);
            timeForGivingUpDuringEngagement = EditorGUILayout.FloatField("Giving Up Engage Time", timeForGivingUpDuringEngagement);
            timeForGivingUpSeeking          = EditorGUILayout.FloatField("(Frames)Give up Seeking", timeForGivingUpSeeking);
            EditorGUILayout.Space();
        }

        showFoldout5 = EditorGUILayout.Foldout(showFoldout5, "Emotion Control");

//Emotion Control
        if (showFoldout5)
        {
            EditorGUILayout.Space();
            initAndrenaline = EditorGUILayout.FloatField("Andrenaline", initAndrenaline);
            initFear        = EditorGUILayout.FloatField("Fear", initFear);
            chanceForFight  = EditorGUILayout.FloatField("ChanceForFight", chanceForFight);
            EditorGUILayout.Space();
        }

        showFoldout6 = EditorGUILayout.Foldout(showFoldout6, "Weapons And Engagment");

//Weapons And Engagment
        if (showFoldout6)
        {
            EditorGUILayout.Space();

            if (GUILayout.Button("Hold No Weapon"))
            {
                weapon = null;
            }
            weaponHoldingLocation = EditorGUILayout.ObjectField("Weapon Holding Location", weaponHoldingLocation, typeof(Transform), true) as Transform;

            weapon = EditorGUILayout.ObjectField("Main Weapon", weapon, typeof(Object), true) as GameObject;


            if (GUILayout.Button("Add more secondary weapons"))
            {
                otherWeapons.Add(null);
                otherWeaponsMelee.Add(0);
            }

            multipleWeaponsScroll = EditorGUILayout.BeginScrollView(multipleWeaponsScroll, GUILayout.Height(100f), GUILayout.Width(300f));

            for (int x = 0; x < otherWeapons.Count; x++)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Weapon number: " + (x + 1).ToString());

                otherWeapons[x]      = EditorGUILayout.ObjectField(otherWeapons[x], typeof(Object), true) as GameObject;
                otherWeaponsMelee[x] = EditorGUILayout.Popup(otherWeaponsMelee[x], meleeOptions);

                if (GUILayout.Button("X"))
                {
                    otherWeapons.RemoveAt(x);
                    otherWeaponsMelee.RemoveAt(x);
                }

                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndScrollView();


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

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Engagement Script");
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.BeginVertical();
            if (GUILayout.Button("Add Script"))
            {
                targetCheck.Add("Empty");
                targetVisualCheckChance.Add(0f);
            }
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Name Of Script");
            EditorGUILayout.LabelField("% Chance");
            EditorGUILayout.EndHorizontal();
            for (int x = 0; x < targetCheck.Count; x++)
            {
                EditorGUILayout.BeginHorizontal();
                targetCheck[x]             = EditorGUILayout.TextField(targetCheck[x]);
                targetVisualCheckChance[x] = EditorGUILayout.FloatField(targetVisualCheckChance[x]);
                if (GUILayout.Button("X"))
                {
                    targetCheck.RemoveAt(x);
                    targetVisualCheckChance.RemoveAt(x);
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Distance For Close Combat Logic");
            distanceToEngageCloseCombatLogic = EditorGUILayout.FloatField(distanceToEngageCloseCombatLogic);
            EditorGUILayout.EndHorizontal();
            initAmmo = EditorGUILayout.FloatField("Amount Of Ammo", initAmmo);
            EditorGUILayout.Space();
            offsetFactor = EditorGUILayout.FloatField("Factor for accuracy", offsetFactor);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.Space();
        }

        showFoldout7 = EditorGUILayout.Foldout(showFoldout7, "Speed References");

//Speed References
        if (showFoldout7)
        {
            EditorGUILayout.Space();
            refSpeedPatrol = EditorGUILayout.FloatField("Patrol Reference Speed", refSpeedPatrol);
            refSpeedEngage = EditorGUILayout.FloatField("Engage Reference Speed", refSpeedEngage);
            refSpeedCover  = EditorGUILayout.FloatField("Cover Reference Speed", refSpeedCover);
            refSpeedChase  = EditorGUILayout.FloatField("Chase Reference Speed", refSpeedChase);
            EditorGUILayout.Space();
        }

        showFoldout8 = EditorGUILayout.Foldout(showFoldout8, "Model Management");

//Model Management
        if (showFoldout8)
        {
            EditorGUILayout.Space();
//modelParentOfAllBones = EditorGUILayout.ObjectField("Parent Of Bones" , modelParentOfAllBones, typeof(Object), true) as GameObject;
            handToUseInCharacter = (HandToUse)EditorGUILayout.EnumPopup("Hand To Hold Gun", handToUseInCharacter);
            EditorGUILayout.Space();
        }

        showFoldout9 = EditorGUILayout.Foldout(showFoldout9, "Patrol Management");

//Patrol Management
        if (showFoldout9)
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("WAYPOINT MANAGEMENT IN PATROL MANAGER", EditorStyles.boldLabel);
            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Distance To Register Waypoint");
            distanceToWaypointForRegistering = EditorGUILayout.FloatField(distanceToWaypointForRegistering);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Min Distance To Destination");
            patrolMinDistanceToDestination = EditorGUILayout.FloatField(patrolMinDistanceToDestination);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Frames To Check Distance");
            patrolFramesCriticalCheck = EditorGUILayout.FloatField(patrolFramesCriticalCheck);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Checks Until Registering Destination");
            patrolChecksCritical = EditorGUILayout.FloatField(patrolChecksCritical);
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
        }

        showFoldout10 = EditorGUILayout.Foldout(showFoldout10, "Optimisation");

//Optimisation
        if (showFoldout10)
        {
            EditorGUILayout.Space();
            coverAmountOfRays    = EditorGUILayout.FloatField("Cover: Amount Of Rays", coverAmountOfRays);
            coverFieldOfView     = EditorGUILayout.FloatField("Cover: Fielf Of View", coverFieldOfView);
            coverDistanceToCheck = EditorGUILayout.FloatField("Cover: Distance To Check", coverDistanceToCheck);
            patrolTickBarrier    = EditorGUILayout.FloatField("Patrol: Frames To Check", patrolTickBarrier);
            coverTrueCoverTest   = EditorGUILayout.FloatField("Patrol: Extra Checks", coverTrueCoverTest);

/*
 * EditorGUILayout.BeginHorizontal();
 * EditorGUILayout.LabelField("Cover Layermask: ");
 * coverLayerMask = EditorGUILayout.MaskField( coverLayerMask, );
 * EditorGUILayout.EndHorizontal();*/

            EditorGUILayout.Space();
        }

        showFoldout11 = EditorGUILayout.Foldout(showFoldout11, "Melee Settings");
//melee stuff
        if (showFoldout11)
        {
            EditorGUILayout.Space();
            meleeSetting = EditorGUILayout.Popup(meleeSetting, meleeOptions);
            if (meleeSetting != 0)
            {
                distanceForMeleeAttack = EditorGUILayout.FloatField("Distance for melee attack", distanceForMeleeAttack);
            }
            EditorGUILayout.Space();
        }


        if (GUI.changed)
        {
            SetVariablesToChild();
        }
        else
        {
            GetVariablesFromChild();
        }
    }
        public override void OnInspectorGUI()
        {
            var target = (fsAotConfiguration)this.target;

            if (GUILayout.Button("Compile"))
            {
                if (Directory.Exists(target.outputDirectory) == false)
                {
                    Directory.CreateDirectory(target.outputDirectory);
                }

                foreach (fsAotConfiguration.Entry entry in target.aotTypes)
                {
                    if (entry.State == fsAotConfiguration.AotState.Enabled)
                    {
                        Type resolvedType = fsTypeCache.GetType(entry.FullTypeName);
                        if (resolvedType == null)
                        {
                            Debug.LogError("Cannot find type " + entry.FullTypeName);
                            continue;
                        }

                        try {
                            string compilation = fsAotCompilationManager.RunAotCompilationForType(new fsConfig(), resolvedType);
                            string path        = Path.Combine(target.outputDirectory, "AotConverter_" + resolvedType.CSharpName(true, true) + ".cs");
                            File.WriteAllText(path, compilation);
                        } catch (Exception e) {
                            Debug.LogWarning("AOT compiling " + resolvedType.CSharpName(true) + " failed: " + e.Message);
                        }
                    }
                }
                AssetDatabase.Refresh();
            }

            target.outputDirectory = EditorGUILayout.TextField("Output Directory", target.outputDirectory);

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Set All");
            int newIndex = GUILayout.Toolbar(-1, options, GUILayout.ExpandWidth(false));

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
            if (newIndex != -1)
            {
                var newState = fsAotConfiguration.AotState.Default;
                if (newIndex == 0)
                {
                    newState = fsAotConfiguration.AotState.Enabled;
                }
                else if (newIndex == 1)
                {
                    newState = fsAotConfiguration.AotState.Disabled;
                }

                for (int i = 0; i < target.aotTypes.Count; ++i)
                {
                    var entry = target.aotTypes[i];
                    entry.State        = newState;
                    target.aotTypes[i] = entry;
                }
            }


            _scrollPos = EditorGUILayout.BeginScrollView(_scrollPos);
            foreach (fsAotConfiguration.Entry entry in target.aotTypes)
            {
                Type resolvedType = fsTypeCache.GetType(entry.FullTypeName);
                EditorGUI.BeginDisabledGroup(resolvedType == null || string.IsNullOrEmpty(GetAotCompilationMessage(resolvedType)) == false);
                DrawType(entry, resolvedType);
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 20
0
    /// <summary>
    /// Display the form to edit a language
    /// </summary>
    void displayLanguageFields()
    {
        EditorGUILayout.BeginVertical();
        rightScrollPos = EditorGUILayout.BeginScrollView(rightScrollPos);

        if (!localizationText.hasLanguageDataLoaded())
        {
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();
            return;
        }

        if (localizationText.fileAndLang.Find(x => x.language == localizationText.currentLangLoaded).file == null)
        {
            EditorGUILayout.LabelField("No JSON file in the Localized Text  ", new GUIStyle(GUI.skin.label)
            {
                fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter
            });
        }

        EditorGUILayout.LabelField("List of the " + localizationText.currentLangLoaded + " language text : ", new GUIStyle(GUI.skin.label)
        {
            fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter
        });
        EditorGUILayout.Space();

        // display text order by key type


        for (int j = 0; j < localizationTextOrdererByKey.Count; j++)
        {
            List <LocalizationElement> itemsForKeyType = localizationTextOrdererByKey[j];
            string[] keySplitted = itemsForKeyType[0].key.Split('_');

            EditorGUILayout.BeginHorizontal("Box");
            EditorGUILayout.LabelField(keySplitted[keySplitted.Length - 1] + " : ", new GUIStyle(GUI.skin.label)
            {
                fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleCenter
            });

            // hide or display the category
            if (GUILayout.Button(displayKeyTypeCategory[j] ? "Hide" : "Display"))
            {
                displayKeyTypeCategory[j] = !displayKeyTypeCategory[j];
            }
            EditorGUILayout.EndHorizontal();

            if (displayKeyTypeCategory[j])
            {
                for (int i = 0; i < itemsForKeyType.Count; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(itemsForKeyType[i].key, GUILayout.Height(keyAndTextHeight), GUILayout.Width(200));
                    itemsForKeyType[i].text = EditorGUILayout.TextArea(itemsForKeyType[i].text, GUILayout.Height(keyAndTextHeight));
                    EditorGUILayout.EndHorizontal();
                }
            }
        }

        EditorGUILayout.EndScrollView();

        if (GUILayout.Button("Save language"))
        {
            localizationText.saveLocalizedText();
            EditorGUI.FocusTextInControl("");
            localizationText.unloadLocalizationData();
        }

        EditorGUILayout.Space();

        EditorGUILayout.EndVertical();
    }
Exemplo n.º 21
0
        /// <summary>
        /// Draw the player prefs entries
        /// </summary>
        private void DrawPrefs()
        {
            var drawnLines = 0;

            _scrollPosition = EditorGUILayout.BeginScrollView(_scrollPosition);

            var boldGUIStyle = new GUIStyle(EditorStyles.numberField);

            boldGUIStyle.fontStyle = FontStyle.Bold;

            for (var i = 0; i < _playerPrefsEntries.Count; i++)
            {
                var playerPrefsEntry = _playerPrefsEntries[i];
                drawnLines++;

                GUIStyle s = new GUIStyle();
                if (playerPrefsEntry.HasError)
                {
                    s.normal.background = _redTexture;
                }

                EditorGUILayout.BeginHorizontal(s);

                // type
                var type        = "";
                var typeTooltip = "";
                switch (playerPrefsEntry.Type)
                {
                case SecurePlayerPrefs.ItemType.Int:
                    type        = "I";
                    typeTooltip = "Int Type";
                    break;

                case SecurePlayerPrefs.ItemType.Float:
                    type        = "F";
                    typeTooltip = "Float Type";
                    break;

                case SecurePlayerPrefs.ItemType.String:
                    type        = "S";
                    typeTooltip = "String Type";
                    break;
                }
                GUILayout.Label(new GUIContent(type, typeTooltip), GUILayout.Width(20));

                if (playerPrefsEntry.IsEncrypted)
                {
                    GUILayout.Label(new GUIContent(null, _lockIcon, "Encrypted Values\n\nKey: " + playerPrefsEntry.OriginalEncryptedKey + "\nValue: " + playerPrefsEntry.OriginalEncryptedValue), GUILayout.Width(20));
                }
                else
                {
                    GUILayout.Label(new GUIContent("-", "Not encrypted"), GUILayout.Width(20));
                }

                // key
                playerPrefsEntry.Key = EditorGUILayout.TextField(playerPrefsEntry.Key, playerPrefsEntry.IsModified ? boldGUIStyle : EditorStyles.textField, GUILayout.MinWidth(80), GUILayout.MaxWidth(100), GUILayout.ExpandWidth(true));

                // value
                switch (playerPrefsEntry.Type)
                {
                case SecurePlayerPrefs.ItemType.Int:
                    playerPrefsEntry.ValueInt = EditorGUILayout.IntField(playerPrefsEntry.ValueInt, playerPrefsEntry.IsModified ? boldGUIStyle : EditorStyles.textField, GUILayout.MinWidth(80));
                    break;

                case SecurePlayerPrefs.ItemType.Float:
                    playerPrefsEntry.ValueFloat = EditorGUILayout.FloatField(playerPrefsEntry.ValueFloat, playerPrefsEntry.IsModified ? boldGUIStyle : EditorStyles.textField, GUILayout.MinWidth(80));
                    break;

                case SecurePlayerPrefs.ItemType.String:
                    playerPrefsEntry.ValueString = EditorGUILayout.TextField(playerPrefsEntry.ValueString, playerPrefsEntry.IsModified ? boldGUIStyle : EditorStyles.textField, GUILayout.MinWidth(80));
                    break;
                }

                // save button
                if (ButtonTrimmed("", _saveIcon, GUI.skin.button, "Save this entry"))
                {
                    playerPrefsEntry.Save();
                }

                // delete button
                if (ButtonTrimmed("", _deleteIcon, GUI.skin.button, "Delete this entry"))
                {
                    playerPrefsEntry.Delete();
                    _playerPrefsEntries.Remove(playerPrefsEntry);
                    break;
                }

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 22
0
        void OnGUI()
        {
            bool sliceTileset = false;

            m_scrollPos = EditorGUILayout.BeginScrollView(m_scrollPos, GUIStyle.none, GUI.skin.verticalScrollbar);
            {
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.LabelField("Atlas Texture:", EditorStyles.boldLabel);
                    EditorGUI.indentLevel += 1;
                    EditorGUI.BeginChangeCheck();
                    m_tileset = (Tileset)EditorGUILayout.ObjectField("Tileset (optional)", m_tileset, typeof(Tileset), false);
                    if (EditorGUI.EndChangeCheck() && m_tileset)
                    {
                        m_padding = (int)Mathf.Max(m_slicePadding.x, m_slicePadding.y);
                        m_extrude = 0;
                    }
                    // Read Data From Tileset
                    if (m_tileset)
                    {
                        m_tileSize     = m_tileset.TilePxSize;
                        m_slicePadding = m_tileset.SlicePadding;
                        m_sliceOffset  = m_tileset.SliceOffset;
                        m_atlasTexture = m_tileset.AtlasTexture;
                    }
                    m_atlasTexture         = (Texture2D)EditorGUILayout.ObjectField("Atlas texture", m_atlasTexture, typeof(Texture2D), false);
                    EditorGUI.indentLevel -= 1;
                }
                EditorGUILayout.EndHorizontal();

                GUI.enabled = m_atlasTexture != null;
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.LabelField("Slice Settings:", EditorStyles.boldLabel);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Tile Size (pixels)", GUILayout.MaxWidth(120f));
                    m_tileSize = EditorGUILayout.Vector2Field("", m_tileSize, GUILayout.MaxWidth(180f), GUILayout.MaxHeight(1f));
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Offset", GUILayout.MaxWidth(120f));
                    m_sliceOffset = EditorGUILayout.Vector2Field("", m_sliceOffset, GUILayout.MaxWidth(180f), GUILayout.MaxHeight(1f));
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField("Padding", GUILayout.MaxWidth(120f));
                    m_slicePadding = EditorGUILayout.Vector2Field("", m_slicePadding, GUILayout.MaxWidth(180f), GUILayout.MaxHeight(1f));
                    EditorGUILayout.EndHorizontal();
                    EditorGUI.indentLevel -= 1;
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
                EditorGUILayout.BeginVertical(EditorStyles.helpBox);
                {
                    EditorGUILayout.LabelField("New Settings:", EditorStyles.boldLabel);
                    EditorGUI.indentLevel += 1;
                    m_padding              = EditorGUILayout.IntField(new GUIContent("Padding (pixels)", "Separation between tiles in pixels"), m_padding);
                    m_extrude              = EditorGUILayout.IntField(new GUIContent("Extrude (pixels)", "How many pixels the color is extruded from tile border"), m_extrude);
                    m_padding              = Mathf.Max(0, m_padding, m_extrude * 2);
                    m_extrude              = Mathf.Max(0, m_extrude);
                    if (GUILayout.Button("Preview"))
                    {
                        m_previewTexture = BuildAtlas(m_atlasTexture, m_padding, m_extrude, m_tileSize, m_sliceOffset, m_slicePadding);
                        AtlasPreviewWindow atlasPreviewWnd = EditorWindow.GetWindow <AtlasPreviewWindow>(true, "Atlas Preview", true);
                        atlasPreviewWnd.Texture  = m_previewTexture;
                        atlasPreviewWnd.TileSize = m_tileSize;
                        atlasPreviewWnd.Padding  = m_padding;
                        atlasPreviewWnd.Extrude  = m_extrude;
                        atlasPreviewWnd.ShowUtility();
                    }
                    if (GUILayout.Button("Apply Settings"))
                    {
                        Texture2D outputAtlas      = BuildAtlas(m_atlasTexture, m_padding, m_extrude, m_tileSize, m_sliceOffset, m_slicePadding);
                        byte[]    pngData          = outputAtlas.EncodeToPNG();
                        string    atlasTexturePath = Application.dataPath + AssetDatabase.GetAssetPath(m_atlasTexture).Substring(6);
                        System.IO.File.WriteAllBytes(atlasTexturePath, pngData);
                        AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(m_atlasTexture));
                        Debug.Log("Saving atlas texture: " + atlasTexturePath);
                        if (m_tileset)
                        {
                            m_sliceOffset  = new Vector2(m_padding, m_padding);
                            m_slicePadding = m_sliceOffset;
                            sliceTileset   = true;
                        }
                    }
                    EditorGUI.indentLevel -= 1;
                }
                EditorGUILayout.EndVertical();

                if (m_previewTexture)
                {
                    GUILayout.Box(m_previewTexture, GUILayout.Width(position.width - 24f));
                }

                GUI.enabled = true;
            }
            EditorGUILayout.EndScrollView();

            // Save Data into tileset
            if (m_tileset)
            {
                m_tileset.TilePxSize   = m_tileSize;
                m_tileset.SlicePadding = m_slicePadding;
                m_tileset.SliceOffset  = m_sliceOffset;
                m_tileset.AtlasTexture = m_atlasTexture;
                if (sliceTileset)
                {
                    m_tileset.Slice();
                    foreach (Tilemap tilemap in FindObjectsOfType <Tilemap>())
                    {
                        if (tilemap.Tileset == m_tileset)
                        {
                            tilemap.Refresh(true, false);
                        }
                    }
                }
            }

            if (GUI.changed)
            {
                if (m_tileset)
                {
                    EditorUtility.SetDirty(m_tileset);
                }
            }
        }
Exemplo n.º 23
0
    private void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.BeginVertical(leftMenu);                                        //Left side menu

        if (GUILayout.Button("General", buttonStyle))
        {
            settingsMenu = "general";
        }
        if (GUILayout.Button("Console Output", buttonStyle))
        {
            settingsMenu = "consoleoutput";
        }
        if (GUILayout.Button("Console Input", buttonStyle))
        {
            settingsMenu = "consoleinput";
        }
        if (GUILayout.Button("Tracker", buttonStyle))
        {
            settingsMenu = "tracker";
        }
        if (GUILayout.Button("Graphing", buttonStyle))
        {
            settingsMenu = "grapher";
        }
        if (GUILayout.Button("Logging", buttonStyle))
        {
            settingsMenu = "logging";
        }
        if (GUILayout.Button("Key Bindings", buttonStyle))
        {
            settingsMenu = "keybindings";
        }

        GUILayout.FlexibleSpace();

        List <string> profileOptions = new List <string>();

        profileOptions.Add("Profile");
        profileOptions.Add("- - -");
        foreach (string str in AssetDatabase.FindAssets("t:DebugSettings"))
        {
            DebugSettings ds = (DebugSettings)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(str), typeof(DebugSettings));
            profileOptions.Add(ds.profileName);
        }


        EditorGUILayout.Popup(0, profileOptions.ToArray());
        if (GUILayout.Button("Information", buttonStyle))
        {
            settingsMenu = "information";
        }
        if (GUILayout.Button("Documentation", buttonStyle))
        {
            ShowDocumentation();
        }
        GUILayout.Label("");

        EditorGUILayout.EndVertical();
        EditorGUILayout.BeginVertical();                                        //Right Side menu


        switch (settingsMenu)
        {
        case "general":
        default:
            GUILayout.Label("General Settings", EditorStyles.boldLabel);
            break;
        }

        EditorGUILayout.BeginScrollView(Vector2.zero, new GUIStyle("HelpBox"));

        switch (settingsMenu)
        {
        case "consoleoutput":
            ShowConsoleOutputSettings();
            break;

        case "consoleinput":
            ShowConsoleInputSettings();
            break;

        case "tracker":
            ShowTrackerSettings();
            break;

        case "grapher":
            ShowGrapherSettings();
            break;

        case "logging":
            ShowLoggerSettings();
            break;

        case "keybindings":
            ShowKeyBindingSettings();
            break;

        case "information":
            ShowInformation();
            break;

        case "general":
        default:
            ShowGeneralSettings();
            break;
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndScrollView();

        GUILayout.Label("");
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("|         Clear Settings          |"))
        {
            ResetSettingsFile();
        }
        if (GUILayout.Button("|          Save Settings          |"))
        {
            SaveSettingsFile();
        }
        if (GUILayout.Button("|           Save Profile          |"))
        {
            SaveSettingsProfile();
        }
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        GUILayout.Label("");

        EditorGUILayout.EndVertical();
        EditorGUILayout.EndHorizontal();
    }
    private void OnGUI()
    {
        EditorGUILayout.BeginVertical();
        {
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Script Version", GUILayout.ExpandWidth(true));
                if (GUILayout.Button("Copy to Clipboard", GUILayout.Width(180)))
                {
                    EditorGUIUtility.systemCopyBuffer = PluginVersionsString();
                    GUI.FocusControl("");
                }
                if (GUILayout.Button("Reload", GUILayout.Width(80)))
                {
                    Reload(true);
                    GUI.FocusControl("");
                }
                EditorGUILayout.EndHorizontal();
            }
            /* スクリプトバージョン表示 */
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.LabelField("Ver." + CriWare.Common.GetScriptVersionString());
                EditorGUI.indentLevel--;
            }
            EditorGUILayout.Space();
            /* バイナリバージョン表示 */
            {
                EditorGUILayout.LabelField("Binary Version");
            }
            /* プラットフォーム別プラグインバイナリバージョン表示 */
            {
                EditorGUILayout.BeginVertical();
                GUILayoutOption   platformColumnWidth  = GUILayout.Width(80);
                GUILayoutOption   targetColumnWidth    = GUILayout.Width(120);
                GUILayoutOption   versionColumnWidth   = GUILayout.Width(140);
                GUILayoutOption   buildDateColumnWidth = GUILayout.Width(200);
                GUILayoutOption   appendixColumnWidth  = GUILayout.Width(200);
                GUILayoutOption[] pathColumnWidth      = { GUILayout.MinWidth(400), GUILayout.ExpandWidth(true) };
                if (pluginInfos != null)
                {
                    for (int i = 0; i < pluginInfos.Count; ++i)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.LabelField("", GUILayout.Width(15));
                            if (GUILayout.Button(pluginInfos[i].platform, EditorStyles.radioButton, platformColumnWidth))
                            {
                                /* 表示の制限のため表示可能な文字数で切り出す */
                                detailVersionsString  = ModuleInfosToAlignedString(pluginInfos[i].moduleVersionInfos);
                                detailVersionsStrings = SplitTextAreaMaxLength(detailVersionsString);
                                selectedInfoIndex     = i;
                                scrollPosition        = new Vector2(0.0f, 0.0f);
                                GUI.FocusControl("");
                            }

                            if (pluginInfos[i].info != null)
                            {
                                EditorGUILayout.LabelField((pluginInfos[i].target ?? "--"), targetColumnWidth);
                                EditorGUILayout.LabelField((pluginInfos[i].info.version ?? "--"), versionColumnWidth);
                                EditorGUILayout.LabelField((pluginInfos[i].info.buildDate ?? "--"), buildDateColumnWidth);
                                EditorGUILayout.LabelField((pluginInfos[i].info.appendix ?? "--"), appendixColumnWidth);
                            }
                            else
                            {
                                EditorGUILayout.LabelField("--", targetColumnWidth);
                                EditorGUILayout.LabelField("--", versionColumnWidth);
                                EditorGUILayout.LabelField("--", buildDateColumnWidth);
                                EditorGUILayout.LabelField("--", appendixColumnWidth);
                            }

                            EditorGUILayout.LabelField(pluginInfos[i].path, pathColumnWidth);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.Space();
            /* 詳細バージョン情報表示 */
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Details [ " + (pluginInfos != null ? pluginInfos[selectedInfoIndex].platform + " / " + pluginInfos[selectedInfoIndex].target : "") + " ]", GUILayout.ExpandWidth(true));
                if (GUILayout.Button("Copy Details to Clipboard", GUILayout.Width(180)))
                {
                    EditorGUIUtility.systemCopyBuffer = detailVersionsString;
                    GUI.FocusControl("");
                }
                EditorGUILayout.EndHorizontal();
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, EditorStyles.textArea);
                foreach (var item in detailVersionsStrings)
                {
                    EditorGUILayout.TextArea(item, detailStyle);
                }
                EditorGUILayout.EndScrollView();
            }
        }
        EditorGUILayout.EndVertical();
    }
        void ShowTabMain(Config conf, WindowData windowData)
        {
            var store = Globals <BacklinkStore> .Value;

            EditorGUIUtility.labelWidth = windowData.Window.position.width * .7f;

            int Hash() => DirtyUtils.HashCode(conf.Locked);

            var active = SearchArgMain.Get1[0];

            if (conf.Locked && (windowData.FindFrom == FindModeEnum.File &&
                                (active == null || active.Main == null || !AssetDatabase.Contains(active.Main))))
            {
                conf.Locked = false;
                AufCtx.World.NewEntityWith(out RequestRepaintEvt _);
            }

            var style = windowData.Style;
            var hash  = Hash();

            if (hash != Hash())
            {
                PersistenceUtils.Save(in conf);
                AufCtx.World.NewEntityWith(out RequestRepaintEvt _);
            }

            // if (Globals<WindowData>.Get() == null) return;
            EditorGUILayout.Space();

            SearchArg arg = default;

            foreach (var i in SearchArgMain)
            {
                arg = SearchArgMain.Get1[i];
                if (arg != null && arg.Main != null)
                {
                    break;
                }
            }

            if (arg == default)
            {
                return;
            }

            var targetTypeEnum = GetTargetType(windowData, arg?.Main);

            BacklinkStore.UnusedQty unusedQty = new BacklinkStore.UnusedQty(0, 0, 0);

            using (new EditorGUILayout.HorizontalScope()) {
                var enabledBuf    = GUI.enabled;
                var selectedGuids = Selection.assetGUIDs;

                var undoRedoState = Globals <UndoRedoState> .Value;

                GUI.enabled = selectedGuids != null && !conf.Locked && undoRedoState.UndoEnabled;
                if (GUILayout.Button(style.ArrowL, style.ArrowBtn))
                {
                    AufCtx.World.NewEntityWith(out UndoEvt _);
                }

                GUI.enabled = selectedGuids != null && !conf.Locked && undoRedoState.RedoEnabled;
                if (GUILayout.Button(style.ArrowR, style.ArrowBtn))
                {
                    AufCtx.World.NewEntityWith(out RedoEvt _);
                }

                GUI.enabled = enabledBuf;

                if (conf.Locked)
                {
                    if (GUILayout.Button(style.Lock, style.LockBtn))
                    {
                        AufCtx.World.NewEntityWith(out SelectionChanged selectionChanged);
                        conf.Locked = false;
                        if (Selection.activeObject != arg.Target)
                        {
                            selectionChanged.From   = FindModeEnum.Scene;
                            selectionChanged.Scene  = SceneManager.GetActiveScene();
                            selectionChanged.Target = Selection.activeObject;
                        }
                        else if (Selection.assetGUIDs is string[] guids)
                        {
                            // todo show info box multiple selection is unsupported
                            if (guids.Length > 0)
                            {
                                var path = AssetDatabase.GUIDToAssetPath(guids[0]);
                                selectionChanged.Target = AssetDatabase.LoadAssetAtPath <Object>(path);
                                switch (Selection.selectionChanged.Target)
                                {
                                case DefaultAsset _:
                                    selectionChanged.From = FindModeEnum.File;
                                    break;

                                case GameObject go when go.scene.isLoaded:
                                    selectionChanged.From  = FindModeEnum.Scene;
                                    selectionChanged.Scene = SceneManager.GetActiveScene();
                                    break;

                                default:
                                    selectionChanged.From = FindModeEnum.File;
                                    break;
                                }
                            }
                            else if (Selection.activeObject is GameObject go && go.scene.isLoaded)
                            {
                                selectionChanged.From   = FindModeEnum.Scene;
                                selectionChanged.Target = Selection.activeObject;
                                selectionChanged.Scene  = SceneManager.GetActiveScene();
                            }
                        }
                    }
                }
                else
                {
                    var enabled = GUI.enabled;
                    GUI.enabled = selectedGuids != null && selectedGuids.Length == 1;
                    if (GUILayout.Button(style.Unlock, style.UnlockBtn))
                    {
                        conf.Locked = true;
                    }

                    GUI.enabled = enabled;
                }

                unusedQty = ShowObjectName(store, windowData, targetTypeEnum, arg, selectedGuids);
            }

            bool isMultiSelect = Selection.assetGUIDs != null && Selection.assetGUIDs.Length > 1;

            if (conf.ShowInfoBox)
            {
                if (isMultiSelect && (unusedQty.UnusedFilesQty + unusedQty.UnusedScenesQty > 0))
                {
                    var msgUnusedFiles = (unusedQty.UnusedFilesQty > 0)
                        ? $"unused files ({unusedQty.UnusedFilesQty}),"
                        : "";
                    var msgUnusedScenes = (unusedQty.UnusedScenesQty > 0)
                        ? $"unused scenes ({unusedQty.UnusedScenesQty}),"
                        : "";
                    var msgMultiSelect = $"This multi-selection contains: " +
                                         msgUnusedFiles + msgUnusedScenes +
                                         $"\nYou could delete them pressing corresponding button to the right.";
                    EditorGUILayout.HelpBox(msgMultiSelect, MessageType.Info);
                }
                else if (TryGetHelpInfo(arg, out var msg, out var msgType))
                {
                    EditorGUILayout.HelpBox(msg, msgType);
                }
            }

            if (targetTypeEnum != TargetTypeEnum.Directory && !isMultiSelect)
            {
                var windowData2 = Globals <WindowData> .Value;

                EditorGUILayout.BeginVertical();
                {
                    windowData2.ScrollPos = EditorGUILayout.BeginScrollView(windowData2.ScrollPos);
                    {
                        RenderRows(windowData2); //TODO?
                        EditorGUILayout.Space();
                    }
                    EditorGUILayout.EndScrollView();
                }
                EditorGUILayout.EndVertical();
                EditorGUILayout.Space();
            }
        }
Exemplo n.º 26
0
    void OnGUI()
    {
        if (!ECLProjectSetting.isProjectExit(ECLProjectManager.self))
        {
            GUIStyle style = new GUIStyle();
            style.fontSize         = 20;
            style.normal.textColor = Color.yellow;
            GUILayout.Label("The scene is not ready, create it now?", style);
            if (GUILayout.Button("Show Project Manager"))
            {
                EditorWindow.GetWindow <ECLProjectManager> (false, "CoolapeProject", true);
            }
            Close();
            return;
        }

        if (ECLProjectManager.data.hotUpgradeServers.Count > 0)
        {
            ECLEditorUtl.BeginContents();
            {
                List <string> toolbarNames = new List <string> ();
                for (int i = 0; i < ECLProjectManager.data.hotUpgradeServers.Count; i++)
                {
                    HotUpgradeServerInfor dd = ECLProjectManager.data.hotUpgradeServers [i] as HotUpgradeServerInfor;
                    toolbarNames.Add(dd.name);
                }
                selectedServerIndex = GUILayout.Toolbar(selectedServerIndex, toolbarNames.ToArray());
                HotUpgradeServerInfor hsi = ECLProjectManager.data.hotUpgradeServers [selectedServerIndex] as HotUpgradeServerInfor;
                selectedServer = hsi;
//						ECLProjectSetting.cellServerInor (hsi, false);
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Key:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.key);
                }
                GUILayout.EndHorizontal();
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Hot Upgrade Base Url:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.hotUpgradeBaseUrl);
                }
                GUILayout.EndHorizontal();
                //===================================================
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Host 4 Upload Upgrade Package:", ECLEditorUtl.width200);
                    GUILayout.TextField(selectedServer.host4UploadUpgradePackage);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Port 4 Upload Upgrade Package:", ECLEditorUtl.width200);
                    EditorGUILayout.IntField(selectedServer.port4UploadUpgradePackage);
                }
                GUILayout.EndHorizontal();
            }
            ECLEditorUtl.EndContents();
        }

        if (selectedServer == null)
        {
            GUILayout.Label("Please select a server!");
            return;
        }

        EditorGUILayout.BeginHorizontal();
        {
            GUI.color = Color.green;
            if (GUILayout.Button("Refresh", GUILayout.Height(40f)))
            {
                setData();
            }
            GUI.color = Color.white;
            if (!isSelectMod)
            {
                if (GUILayout.Button("Save", GUILayout.Height(40f)))
                {
                    if (mList == null || mList.Count == 0)
                    {
                        Debug.LogWarning("Nothing need to save!");
                        return;
                    }
                    string str = JSON.JsonEncode(mList);
                    File.WriteAllText(Application.dataPath + "/" + cfgPath, str);
                }
            }
        }
        EditorGUILayout.EndHorizontal();

        ECLEditorUtl.BeginContents();
        {
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.LabelField("Package Name", GUILayout.Width(160));
                EditorGUILayout.LabelField("MD5", GUILayout.Width(250));
                EditorGUILayout.LabelField("Exist?", GUILayout.Width(40));
                EditorGUILayout.LabelField("Upload?", GUILayout.Width(60));
                EditorGUILayout.LabelField("...", GUILayout.Width(60));
                EditorGUILayout.LabelField("Notes");
            }
            EditorGUILayout.EndHorizontal();
            if (mList == null)
            {
                return;
            }
            scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 75));
            {
                for (int i = mList.Count - 1; i >= 0; i--)
                {
                    item = ListEx.getMap(mList, i);

                    EditorGUILayout.BeginHorizontal();
                    {
                        EditorGUILayout.TextField(MapEx.getString(item, "name"), GUILayout.Width(160));
                        EditorGUILayout.TextField(MapEx.getString(item, "md5"), GUILayout.Width(250));

                        if (!MapEx.getBool(item, "exist"))
                        {
                            GUI.color = Color.red;
                        }
                        EditorGUILayout.TextField(MapEx.getBool(item, "exist") ? "Yes" : "No", GUILayout.Width(40));
                        GUI.color = Color.white;
                        if (!isUploaded(item))
                        {
                            GUI.color = Color.red;
                        }
                        EditorGUILayout.TextField(isUploaded(item) ? "Yes" : "No", GUILayout.Width(60));
                        GUI.color = Color.white;
                        if (MapEx.getBool(item, "exist"))
                        {
                            GUI.enabled = true;
                        }
                        else
                        {
                            GUI.enabled = false;
                        }
                        GUI.color = Color.yellow;
                        if (isSelectMod)
                        {
                            if (GUILayout.Button("select", GUILayout.Width(60f)))
                            {
                                Close();
                                Utl.doCallback(onSelectedCallback, item, selectedCallbackParams);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("upload", GUILayout.Width(60f)))
                            {
                                if (EditorUtility.DisplayDialog("Alert", "Really want to upload the upgrade package?", "Okey", "cancel"))
                                {
                                    selectedPackageName = MapEx.getString(item, "name");
                                    uploadUpgradePackage(MapEx.getString(item, "name"));
                                }
                            }
                            if (GUILayout.Button("同步OSS", GUILayout.Width(60f)))
                            {
                                if (EditorUtility.DisplayDialog("Alert", "Really want to upload the upgrade package?", "Okey", "cancel"))
                                {
                                    uploadOss(MapEx.getString(item, "name"));
                                }
                            }
                        }

                        GUI.color       = Color.white;
                        GUI.enabled     = true;
                        item ["remark"] = EditorGUILayout.TextArea(MapEx.getString(item, "remark"));

                        GUILayout.Space(5);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            EditorGUILayout.EndScrollView();
        }
        ECLEditorUtl.EndContents();
    }
Exemplo n.º 27
0
        public override void OnInspectorGUI()
        {
            EditorGUIUtility.LookLikeControls();

            slot.slotName = EditorGUILayout.TextField("Slot Name", slot.slotName);
            slot.slotDNA  = EditorGUILayout.ObjectField("DNA Converter", slot.slotDNA, typeof(DnaConverterBehaviour), false) as DnaConverterBehaviour;

            EditorGUILayout.Space();

            SkinnedMeshRenderer renderer = EditorGUILayout.ObjectField("Renderer", slot.meshRenderer, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;

            if (renderer != slot.meshRenderer)
            {
                slot.umaBoneData   = null;
                slot.animatedBones = new Transform[0];

                slot.meshRenderer = renderer;
                if (renderer != null)
                {
                    slot.umaBoneData = GetTransformsInPrefab(slot.meshRenderer.rootBone);
                }
            }
            slot.subMeshIndex = EditorGUILayout.IntField("Sub Mesh Index", slot.subMeshIndex);
            Material material = EditorGUILayout.ObjectField("Material", slot.materialSample, typeof(Material), false) as Material;

            if (material != slot.materialSample)
            {
                slot.materialSample = material;
            }

            EditorGUILayout.Space();

            if (slot.umaBoneData == null)
            {
                showBones   = false;
                GUI.enabled = false;
            }
            showBones = EditorGUILayout.Foldout(showBones, "Bones");
            if (showBones)
            {
                EditorGUI.indentLevel++;
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Name");
                GUILayout.FlexibleSpace();
                EditorGUILayout.LabelField("Animated");
                GUILayout.Space(40f);
                EditorGUILayout.EndHorizontal();

                boneScroll = EditorGUILayout.BeginScrollView(boneScroll);
                EditorGUILayout.BeginVertical();

                Transform deletedBone = null;
                foreach (Transform bone in slot.umaBoneData)
                {
                    bool wasAnimated = ArrayUtility.Contains <Transform>(slot.animatedBones, bone);

                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(bone.name);
                    bool animated = EditorGUILayout.Toggle(wasAnimated, GUILayout.Width(40f));
                    if (animated != wasAnimated)
                    {
                        if (animated)
                        {
                            Undo.RecordObject(slot, "Add Animated Bone");
                            ArrayUtility.Add <Transform>(ref slot.animatedBones, bone);
                        }
                        else
                        {
                            Undo.RecordObject(slot, "Remove Animated Bone");
                            ArrayUtility.Remove <Transform>(ref slot.animatedBones, bone);
                        }
                    }
                    if (GUILayout.Button("-", GUILayout.Width(20f)))
                    {
                        deletedBone = bone;
                        break;
                    }
                    EditorGUILayout.EndHorizontal();
                }
                if (deletedBone != null)
                {
                    Undo.RecordObject(slot, "Delete Bone");
                    ArrayUtility.Remove <Transform>(ref slot.umaBoneData, deletedBone);
                    ArrayUtility.Remove <Transform>(ref slot.animatedBones, deletedBone);
                }

                EditorGUILayout.EndVertical();
                EditorGUILayout.EndScrollView();
                EditorGUI.indentLevel--;

                if (GUILayout.Button("Reset Bones"))
                {
                    Undo.RecordObject(slot, "Reset Bones");
                    slot.umaBoneData   = GetTransformsInPrefab(slot.meshRenderer.rootBone);
                    slot.animatedBones = new Transform[0];
                }
            }

            GUI.enabled = true;

            EditorGUILayout.Space();

            slot.slotGroup = EditorGUILayout.TextField("Slot Group", slot.slotGroup);
            var textureNameList = serializedObject.FindProperty("textureNameList");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(textureNameList, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }



            SerializedProperty tags = serializedObject.FindProperty("tags");

            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(tags, true);
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
            }

            EditorGUIUtility.LookLikeControls();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(slot);
                AssetDatabase.SaveAssets();
            }
        }
Exemplo n.º 28
0
    private void OnGUI()
    {
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Filter:", GUILayout.MaxWidth(50));

        EditorGUIUtility.labelWidth = 80;
        GUILayout.ExpandWidth(false);

        filter     = GUILayout.TextField(filter, 25, GUILayout.MaxWidth(800));
        ignoreCase = GUILayout.Toggle(ignoreCase, "Ignore Case", options: GUILayout.MaxWidth(100));
        _orderBy   = (OrderType)EditorGUILayout.EnumPopup("Oder By:", _orderBy);
        EditorGUILayout.EndHorizontal();



        var bindings = FindObjectsOfType <DataBindingBase>().OrderBy(e => _orderBy == OrderType.GameObject ? e.gameObject.name : e.ViewModelName);

        var oneWays = bindings.Where(e => e is OneWayDataBinding && !(e is TwoWayDataBinding)).Select(e => e as OneWayDataBinding).Where(
            e =>
        {
            if (_filterBy == FilterType.None)
            {
                return(true);
            }
            if (e.Connection == null)
            {
                return(false);
            }
            return(_filterBy == FilterType.Bound ? e.Connection.IsBound : !e.Connection.IsBound);
        });
        var twoWays = bindings.Where(e => e is TwoWayDataBinding).Select(e => e as TwoWayDataBinding);

        var eventPropBindings = FindObjectsOfType <EventPropertyBinding>();
        var eventBindings     = FindObjectsOfType <EventBinding>();

        GUILayout.Label(string.Format("OneWayBindings: {0}", oneWays.Count()), EditorStyles.boldLabel);

        onewWayScrollPos = EditorGUILayout.BeginScrollView(onewWayScrollPos, GUILayout.MaxHeight(600));
        var style = new GUIStyle(GUI.skin.label);

        style.richText = true;

        foreach (var item in oneWays)
        {
            var str = string.Format("<b>{0}</b> Src: <b>{1}:{2}</b> Dst: <b>{3}:{4}</b> Bound: <b>{5}</b>", item.gameObject.name, item.ViewModelName, item.SrcPropertyName, item._dstView.GetType().Name, item.DstPropertyName.PropertyName, item.Connection == null ? false : item.Connection.IsBound);

            bool contains = ignoreCase ? str.ToLower().Contains(filter.ToLower()) : str.Contains(filter);

            if (string.IsNullOrEmpty(filter) || contains)
            {
                EditorGUILayout.LabelField(str, style);
            }
        }

        EditorGUILayout.EndScrollView();

        GUILayout.Label(string.Format("TwoWay Bindings: {0}", twoWays.Count()), EditorStyles.boldLabel);

        twoWayScrollPos = EditorGUILayout.BeginScrollView(twoWayScrollPos, GUILayout.MaxHeight(400));
        foreach (var item in twoWays)
        {
            var str = string.Format("<b>{0}</b> Src: <b>{1}/{2}</b> Dst: <b>{3}/{4}</b> Event: <b>{4}</b> Bound: <b>{5}</b>", item.gameObject.name, item.ViewModelName, item.SrcPropertyName, item._dstView.GetType().Name, item.DstPropertyName.PropertyName, item._dstChangedEventName, item.Connection == null ? false : item.Connection.IsBound);

            if (string.IsNullOrEmpty(filter) || str.Contains(filter))
            {
                EditorGUILayout.LabelField(str, style);
            }
        }
        EditorGUILayout.EndScrollView();


        GUILayout.Label(string.Format("Event Bindings: {0}", eventPropBindings.Count()), EditorStyles.boldLabel);

        eventPropScrollPos = EditorGUILayout.BeginScrollView(eventPropScrollPos, GUILayout.MaxHeight(400));
        foreach (var item in eventPropBindings)
        {
            var str = string.Format("<b>{0}</b> SrcEvent: <b>{1}/{2}</b> DstProp: <b>{3}/{4}</b>", item.gameObject.name, item._srcView.GetType().Name, item.SrcEventName, item.ViewModelName, item.DstPropName);

            if (string.IsNullOrEmpty(filter) || str.Contains(filter))
            {
                EditorGUILayout.LabelField(str, style);
            }
        }
        EditorGUILayout.EndScrollView();


        var conns = BindingMonitor.Connections;

        GUILayout.Label(string.Format("Active Connections: {0}", conns.Count()), EditorStyles.boldLabel);

        if (GUILayout.Button("Reset"))
        {
            BindingMonitor.Reset();
        }

        connectionScrollPos = EditorGUILayout.BeginScrollView(connectionScrollPos, GUILayout.MaxHeight(600));

        foreach (var item in conns)
        {
            var str = string.Format("<b>{0}</b> Src: <b>{1}/{2}</b> Dst: <b>{3}/{4}</b> Bound: <b>{5}</b>", item.Owner, item.SrcTarget.propertyOwner.GetType().Name, item.SrcTarget.propertyName, item.DstTarget.propertyOwner.GetType().Name, item.DstTarget.propertyName, item.IsBound);

            bool contains = ignoreCase ? str.ToLower().Contains(filter.ToLower()) : str.Contains(filter);

            if (string.IsNullOrEmpty(filter) || contains)
            {
                EditorGUILayout.LabelField(str, style);
            }
        }


        EditorGUILayout.EndScrollView();
    }
Exemplo n.º 29
0
    void MainMenu()
    {
        mainMenu.scrollPosition = EditorGUILayout.BeginScrollView(mainMenu.scrollPosition, false, false, docSize);

        GUILayout.Space(25);
        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("How To", buttonSize))
        {
            NavigateForward(howTo);
        }

        var rect = GUILayoutUtility.GetLastRect();

        EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Overview", buttonSize))
        {
            NavigateForward(overview);
        }

        rect = GUILayoutUtility.GetLastRect();
        EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Documentation", buttonSize))
        {
            NavigateForward(documentation);
        }

        rect = GUILayoutUtility.GetLastRect();
        EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Other Products", buttonSize))
        {
            NavigateForward(otherProducts);
        }

        rect = GUILayoutUtility.GetLastRect();
        EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Feedback", buttonSize))
        {
            NavigateForward(feedback);
        }

        rect = GUILayoutUtility.GetLastRect();
        EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);

        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        GUILayout.FlexibleSpace();

        EditorGUILayout.EndScrollView();
    }
Exemplo n.º 30
0
    private void ShowVersion2()
    {
        GUILayout.Label("Generates XML based on image and settings selected", EditorStyles.boldLabel);
        EditorGUILayout.Space();

        if (showInstructions)
        {
            EditorGUILayout.BeginVertical("Box");
            GUILayout.Label("Instructions", EditorStyles.boldLabel);
            GUILayout.Label("1. Select the image you want an XML for ");
            GUILayout.Label("2. Specify the rows and columns of the image ");
            GUILayout.Label("3. Select the folder to output the sprite and xml");
            GUILayout.Label("4. Press 'Export' button");
            GUILayout.Label("5. XML will generate and sprite will be moved to the specified folder");
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
        }

        GUILayout.BeginHorizontal();

        if (GUILayout.Button("Select Image"))
        {
            inputDirPath = EditorUtility.OpenFilePanelWithFilters("Select file to generate a XML for", inputDirPath, new string[] { "Image files", "png,jpg,jpeg" });
            if (File.Exists(inputDirPath))
            {
                LoadImage(inputDirPath);
            }
        }

        if (GUILayout.Button("Set Output Folder"))
        {
            outputDirPath = EditorUtility.OpenFolderPanel("Select folder to save XML", outputDirPath, string.Empty);
        }

        GUILayout.EndHorizontal();
        EditorGUILayout.Space();

        GUILayout.Label("Settings:", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical("Box");
        GUILayout.BeginHorizontal();

        GUILayout.Label("Pixels Per Unit:", EditorStyles.boldLabel);
        index = EditorGUILayout.Popup(index, pixelPerUnitOptions);

        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        GUILayout.BeginHorizontal();

        isMultipleSprite = EditorGUILayout.ToggleLeft("Is this a Multiple Sprite image?", isMultipleSprite);
        useCustomPivot   = EditorGUILayout.ToggleLeft("Use a custom pivot?", useCustomPivot);

        GUILayout.EndHorizontal();
        EditorGUILayout.Space();

        if (isMultipleSprite)
        {
            GUILayout.BeginVertical("Box");
            GUILayout.Label("Select Rows/Columns:", EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label("Rows:", EditorStyles.boldLabel);
            rowIndex = EditorGUILayout.Popup(rowIndex, columnRowOptions);

            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();

            GUILayout.Label("Columns:", EditorStyles.boldLabel);
            columnIndex = EditorGUILayout.Popup(columnIndex, columnRowOptions);

            GUILayout.EndHorizontal();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            EditorGUILayout.Space();
        }

        if (useCustomPivot)
        {
            EditorGUILayout.BeginVertical("Box");
            GUILayout.Label("Custom Pivot Settings:", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal("Box");
            pivotX = Mathf.Clamp01(EditorGUILayout.FloatField("Pivot X", pivotX));
            pivotY = Mathf.Clamp01(EditorGUILayout.FloatField("Pivot Y", pivotY));
            EditorGUILayout.EndHorizontal();
            EditorGUILayout.EndVertical();
            EditorGUILayout.Space();
        }

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

        if (textureLoaded == true)
        {
            GUILayout.Label(imageName + " Preview:", EditorStyles.boldLabel);
            EditorGUILayout.BeginVertical("Box");

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.Width(446), GUILayout.Height(210));
            GUILayout.Label(myTexture);

            EditorGUILayout.EndScrollView();
            EditorGUILayout.EndVertical();
        }

        if (textureLoaded == true && outputDirPath != string.Empty)
        {
            EditorGUILayout.Space();

            if (GUILayout.Button("Export " + imageName + ".xml"))
            {
                if ((columnIndex == 0 && rowIndex == 0) && isMultipleSprite == true)
                {
                    EditorUtility.DisplayDialog("Select proper Row/Column count", "Please select more than 1 Row/Column!", "OK");
                    UnityDebugger.Debugger.LogError("SpriteToXML", "Please select more than 1 Row/Column");
                }
                else
                {
                    GenerateXML(inputDirPath, myTexture);
                }
            }
        }

        if (outputDirPath != string.Empty)
        {
            EditorGUILayout.Space();
            EditorGUILayout.BeginVertical("Box");
            GUILayout.Label("Current Path: " + outputDirPath);

            if (GUILayout.Button("Open Output Folder"))
            {
                EditorUtility.RevealInFinder(outputDirPath);
            }

            EditorGUILayout.EndVertical();
        }
    }