Beispiel #1
0
        public static void MainWindow(int id)
        {
            // Close Button
            if (GUI.Button(new Rect(AHEditor.rectMainWindow.size.x - 22, 2, 20, 20), "X"))
            {
                AHEditor.CloseMainWindow();
            }

            GUILayout.BeginVertical();

            // Choose direct / relay antennas
            GUILayout.Label(/*Selected type*/ Localizer.Format("#autoLOC_AH_0004") + " : " + antennaTypeStr);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button(
                    /*Direct*/ Localizer.Format("#autoLOC_AH_0002")
                    + " (" + /*All Antennas*/ Localizer.Format("#autoLOC_AH_0005") + ")"))
            {
                antennaTypeStr      = /*Direct*/ Localizer.Format("#autoLOC_AH_0002");
                antennaTypeIsDirect = true;
            }
            if (GUILayout.Button(/*Relay*/ Localizer.Format("#autoLOC_AH_0003")))
            {
                antennaTypeStr      = /*Relay*/ Localizer.Format("#autoLOC_AH_0003");
                antennaTypeIsDirect = false;
            }
            GUILayout.EndHorizontal();

            // Pick a target :
            GUILayout.Label(
                /*Current target*/ Localizer.Format("#autoLOC_AH_0006")
                + " : " + AHEditor.targetName
                + "  (" + AHEditor.targetPower.ToString("N0") + ")");
            if (GUILayout.Button(/*Pick A Target*/ Localizer.Format("#autoLOC_AH_0007")))
            {
                if (AHEditor.showTargetWindow)
                {
                    AHEditor.CloseTargetWindow();
                }
                else
                {
                    AHEditor.showTargetWindow = true;
                }
            }

            // Number display :
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            GUILayout.Label(/*Status*/ Localizer.Format("#autoLOC_AH_0008") + " : ");
            GUILayout.Label(/*Power*/ Localizer.Format("#autoLOC_AH_0009") + " : ");
            GUILayout.Label(/*Max Range*/ Localizer.Format("#autoLOC_AH_0010") + " : ");
            GUILayout.Label(/*Max Distance At 100%*/ Localizer.Format("#autoLOC_AH_0011") + " : ");
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            if (antennaTypeIsDirect)
            {
                GUILayout.Label(AHEditor.statusStringDirect);
                GUILayout.Label(AHEditor.directBetterPower.ToString("N0"));
                GUILayout.Label(AHEditor.directBetterRange.ToString("N0") + "m");
                GUILayout.Label(AHEditor.directDistanceAt100.ToString("N0") + "m");
            }
            else
            {
                GUILayout.Label(AHEditor.statusStringRelay);
                GUILayout.Label(AHEditor.relayBetterPower.ToString("N0"));
                GUILayout.Label(AHEditor.relayBetterRange.ToString("N0") + "m");
                GUILayout.Label(AHEditor.relayDistanceAt100.ToString("N0") + "m");
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.Space(16f);
            GUIStyle guiStyleCenter = new GUIStyle(GUI.skin.GetStyle("Label"));

            guiStyleCenter.alignment = TextAnchor.MiddleCenter;

            GUILayout.BeginHorizontal();
            if (antennaTypeIsDirect)
            {
                GUILayout.Label(AHEditor.directDistanceAt75.ToString("N0") + "m", guiStyleCenter);
                GUILayout.Label(AHEditor.directDistanceAt25.ToString("N0") + "m", guiStyleCenter);
            }
            else
            {
                GUILayout.Label(AHEditor.relayDistanceAt75.ToString("N0") + "m", guiStyleCenter);
                GUILayout.Label(AHEditor.relayDistanceAt25.ToString("N0") + "m", guiStyleCenter);
            }
            GUILayout.EndHorizontal();

            GUILayout.Label(AHUtil.signalPerDistanceTex);

            if (antennaTypeIsDirect)
            {
                GUILayout.Label(AHEditor.directDistanceAt50.ToString("N0") + "m", guiStyleCenter);
            }
            else
            {
                GUILayout.Label(AHEditor.relayDistanceAt50.ToString("N0") + "m", guiStyleCenter);
            }

            // Planet view button :
            if (GUILayout.Button(/*Signal Strength / Distance*/ Localizer.Format("#autoLOC_AH_0060")
                                 + " / " + Localizer.Format("#autoLOC_AH_0059")))
            {
                if (AHEditor.showPlanetWindow)
                {
                    AHEditor.ClosePlanetWindow();
                }
                else
                {
                    AHEditor.showPlanetWindow = true;
                }
            }

            if (GUILayout.Button(/*Add Ship to the Target List*/ Localizer.Format("#autoLOC_AH_0013")))
            {
                AHEditor.AddShipToShipList();
            }

            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Beispiel #2
0
        private void TypePane()
        {
            if (selectedType < 0)
            {
                return;
            }

            var style = EditorStyle.Get;

            var typeListItem = types[selectedType];
            var type         = typeListItem.type;

            typePaneScrollPos = EditorGUILayout.BeginScrollView(typePaneScrollPos, style.area);

            GUILayout.Label(typeListItem.name, style.subheading);
            GUILayout.Label(typeListItem.namespaceName);

            EditorGUILayout.BeginVertical(style.area);

            bool hasParameterlessConstructor = ES3Reflection.HasParameterlessConstructor(type);
            bool isComponent = ES3Reflection.IsAssignableFrom(typeof(Component), type);

            string path = GetOutputPath(types[selectedType].type);

            // An ES3Type file already exists.
            if (File.Exists(path))
            {
                if (hasParameterlessConstructor || isComponent)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (GUILayout.Button("Reset to Default"))
                    {
                        SelectNone(true, true);
                        AssetDatabase.MoveAssetToTrash("Assets" + path.Remove(0, Application.dataPath.Length));
                        SelectType(selectedType);
                    }
                    if (GUILayout.Button("Edit ES3Type Script"))
                    {
                        UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(path, 1);
                    }
                    EditorGUILayout.EndHorizontal();
                }
                else
                {
                    EditorGUILayout.HelpBox("This type has no public parameterless constructors.\n\nTo support this type you will need to modify the ES3Type script to use a specific constructor instead of the parameterless constructor.", MessageType.Info);
                    if (GUILayout.Button("Click here to edit the ES3Type script"))
                    {
                        UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal(path, 1);
                    }
                    if (GUILayout.Button("Reset to Default"))
                    {
                        SelectAll(true, true);
                        File.Delete(path);
                        AssetDatabase.Refresh();
                    }
                }
            }
            // No ES3Type file and no fields.
            else if (fields.Length == 0)
            {
                if (!hasParameterlessConstructor && !isComponent)
                {
                    EditorGUILayout.HelpBox("This type has no public parameterless constructors.\n\nTo support this type you will need to create an ES3Type script and modify it to use a specific constructor instead of the parameterless constructor.", MessageType.Info);
                }

                if (GUILayout.Button("Create ES3Type Script"))
                {
                    Generate();
                }
            }
            // No ES3Type file, but fields are selectable.
            else
            {
                if (!hasParameterlessConstructor && !isComponent)
                {
                    EditorGUILayout.HelpBox("This type has no public parameterless constructors.\n\nTo support this type you will need to select the fields you wish to serialize below, and then modify the generated ES3Type script to use a specific constructor instead of the parameterless constructor.", MessageType.Info);
                    if (GUILayout.Button("Select all fields and generate ES3Type script"))
                    {
                        SelectAll(true, false);
                        Generate();
                    }
                }
                else
                {
                    if (GUILayout.Button("Create ES3Type Script"))
                    {
                        Generate();
                    }
                }
            }

            EditorGUILayout.EndVertical();

            PropertyPane();

            EditorGUILayout.EndScrollView();
        }
Beispiel #3
0
    public override void OnInspectorGUI()
    {
        this.m_Target = (PhotonView)target;
        bool isProjectPrefab = EditorUtility.IsPersistent(this.m_Target.gameObject);

        if (this.m_Target.ObservedComponents == null)
        {
            this.m_Target.ObservedComponents = new System.Collections.Generic.List <Component>();
        }

        if (this.m_Target.ObservedComponents.Count == 0)
        {
            this.m_Target.ObservedComponents.Add(null);
        }

        EditorGUILayout.BeginHorizontal();
        // Owner
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("Owner:", "Set at runtime");
        }
        else if (!this.m_Target.isOwnerActive)
        {
            EditorGUILayout.LabelField("Owner", "Scene");
        }
        else
        {
            PhotonPlayer owner     = this.m_Target.owner;
            string       ownerInfo = (owner != null) ? owner.NickName : "<no PhotonPlayer found>";

            if (string.IsNullOrEmpty(ownerInfo))
            {
                ownerInfo = "<no playername set>";
            }

            EditorGUILayout.LabelField("Owner", "[" + this.m_Target.ownerId + "] " + ownerInfo);
        }

        // ownership requests
        EditorGUI.BeginDisabledGroup(Application.isPlaying);
        OwnershipOption own = (OwnershipOption)EditorGUILayout.EnumPopup(this.m_Target.ownershipTransfer, GUILayout.Width(100));

        if (own != this.m_Target.ownershipTransfer)
        {
            // jf: fixed 5 and up prefab not accepting changes if you quit Unity straight after change.
            // not touching the define nor the rest of the code to avoid bringing more problem than solving.
            EditorUtility.SetDirty(this.m_Target);

            Undo.RecordObject(this.m_Target, "Change PhotonView Ownership Transfer");
            this.m_Target.ownershipTransfer = own;
        }
        EditorGUI.EndDisabledGroup();

        EditorGUILayout.EndHorizontal();


        // View ID
        if (isProjectPrefab)
        {
            EditorGUILayout.LabelField("View ID", "Set at runtime");
        }
        else if (EditorApplication.isPlaying)
        {
            EditorGUILayout.LabelField("View ID", this.m_Target.viewID.ToString());
        }
        else
        {
            int idValue = EditorGUILayout.IntField("View ID [1.." + (PhotonNetwork.MAX_VIEW_IDS - 1) + "]", this.m_Target.viewID);
            if (this.m_Target.viewID != idValue)
            {
                Undo.RecordObject(this.m_Target, "Change PhotonView viewID");
                this.m_Target.viewID = idValue;
            }
        }

        // Locally Controlled
        if (EditorApplication.isPlaying)
        {
            string masterClientHint = PhotonNetwork.isMasterClient ? "(master)" : "";
            EditorGUILayout.Toggle("Controlled locally: " + masterClientHint, this.m_Target.isMine);
        }

        // ViewSynchronization (reliability)
        if (this.m_Target.synchronization == ViewSynchronization.Off)
        {
            GUI.color = Color.grey;
        }

        EditorGUILayout.PropertyField(serializedObject.FindProperty("synchronization"), new GUIContent("Observe option:"));

        if (this.m_Target.synchronization != ViewSynchronization.Off && this.m_Target.ObservedComponents.FindAll(item => item != null).Count == 0)
        {
            GUILayout.BeginVertical(GUI.skin.box);
            GUILayout.Label("Warning", EditorStyles.boldLabel);
            GUILayout.Label("Setting the synchronization option only makes sense if you observe something.");
            GUILayout.EndVertical();
        }

        DrawSpecificTypeSerializationOptions();

        GUI.color = Color.white;
        DrawObservedComponentsList();

        // Cleanup: save and fix look
        if (GUI.changed)
        {
            #if !UNITY_MIN_5_3
            EditorUtility.SetDirty(this.m_Target);
            #endif
            PhotonViewHandler.HierarchyChange(); // TODO: check if needed
        }

        GUI.color = Color.white;
        #if !UNITY_MIN_5_3
        EditorGUIUtility.LookLikeControls();
        #endif
    }
Beispiel #4
0
        void DrawBackgroundTexture(Rect rect, int pass)
        {
            if (s_MaterialGrid == null)
            {
                s_MaterialGrid = new Material(Shader.Find("Hidden/PostProcessing/Editor/CurveGrid"))
                {
                    hideFlags = HideFlags.HideAndDontSave
                }
            }
            ;

            float scale = EditorGUIUtility.pixelsPerPoint;

        #if UNITY_2018_1_OR_NEWER
            const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.sRGB;
        #else
            const RenderTextureReadWrite kReadWrite = RenderTextureReadWrite.Linear;
        #endif

            var oldRt = RenderTexture.active;
            var rt    = RenderTexture.GetTemporary(Mathf.CeilToInt(rect.width * scale), Mathf.CeilToInt(rect.height * scale), 0, RenderTextureFormat.ARGB32, kReadWrite);
            s_MaterialGrid.SetFloat("_DisabledState", GUI.enabled ? 1f : 0.5f);
            s_MaterialGrid.SetFloat("_PixelScaling", EditorGUIUtility.pixelsPerPoint);

            Graphics.Blit(null, rt, s_MaterialGrid, pass);
            RenderTexture.active = oldRt;

            GUI.DrawTexture(rect, rt);
            RenderTexture.ReleaseTemporary(rt);
        }

        int DoCurveSelectionPopup(int id, bool hdr)
        {
            GUILayout.Label(s_Curves[id], EditorStyles.toolbarPopup, GUILayout.MaxWidth(150f));

            var lastRect = GUILayoutUtility.GetLastRect();
            var e        = Event.current;

            if (e.type == EventType.MouseDown && e.button == 0 && lastRect.Contains(e.mousePosition))
            {
                var menu = new GenericMenu();

                for (int i = 0; i < s_Curves.Length; i++)
                {
                    if (i == 4)
                    {
                        menu.AddSeparator("");
                    }

                    if (hdr && i < 4)
                    {
                        menu.AddDisabledItem(s_Curves[i]);
                    }
                    else
                    {
                        int current = i; // Capture local for closure
                        menu.AddItem(s_Curves[i], current == id, () => GlobalSettings.currentCurve = current);
                    }
                }

                menu.DropDown(new Rect(lastRect.xMin, lastRect.yMax, 1f, 1f));
            }

            return(id);
        }
    }
        void OnGUI()
        {
            if (EditorApplication.isPlayingOrWillChangePlaymode && !EditorApplication.isPlaying)
            {
                // Brute force hack to stop us calling DLL functions while Unity is starting up
                // playing in editor mode and will cause us to leak system objects
                this.ShowNotification(new GUIContent("Playing In Editor Starting"));
                return;
            }

            if (!EventManager.IsValid)
            {
                this.ShowNotification(new GUIContent("No FMOD Studio banks loaded. Please check your settings."));
                return;
            }

            if (Event.current.type == EventType.Layout)
            {
                RebuildDisplayFromCache();
            }

            //if (eventStyle == null)
            {
                eventStyle = new GUIStyle(GUI.skin.button);
                eventStyle.normal.background    = null;
                eventStyle.focused.background   = null;
                eventStyle.active.background    = null;
                eventStyle.onFocused.background = null;
                eventStyle.onNormal.background  = null;
                eventStyle.onHover.background   = null;
                eventStyle.onActive.background  = null;
                eventStyle.stretchWidth         = false;
                eventStyle.padding.left         = 0;
                eventStyle.stretchHeight        = false;
                eventStyle.fixedHeight          = eventStyle.lineHeight + eventStyle.margin.top + eventStyle.margin.bottom;
                eventStyle.alignment            = TextAnchor.MiddleLeft;

                eventIcon        = EditorGUIUtility.Load("FMOD/EventIcon.png") as Texture;
                folderOpenIcon   = EditorGUIUtility.Load("FMOD/FolderIconOpen.png") as Texture;
                folderClosedIcon = EditorGUIUtility.Load("FMOD/FolderIconClosed.png") as Texture;
                searchIcon       = EditorGUIUtility.Load("FMOD/SearchIcon.png") as Texture;
                bankIcon         = EditorGUIUtility.Load("FMOD/BankIcon.png") as Texture;
                snapshotIcon     = EditorGUIUtility.Load("FMOD/SnapshotIcon.png") as Texture;
                borderIcon       = EditorGUIUtility.Load("FMOD/Border.png") as Texture2D;
            }

            if (fromInspector)
            {
                var border = new GUIStyle(GUI.skin.box);
                border.normal.background = borderIcon;
                GUI.Box(new Rect(1, 1, position.width - 1, position.height - 1), GUIContent.none, border);
            }

            // Split the window int search box, tree view, preview pane (only if full browser)
            Rect searchRect, listRect, previewRect;

            SplitWindow(out searchRect, out listRect, out previewRect);

            // Scroll the selected item in the tree view - put above the search box otherwise it will take
            // our key presses
            if (selectedItem != null && Event.current.type == EventType.keyDown)
            {
                if (Event.current.keyCode == KeyCode.UpArrow)
                {
                    if (selectedItem.Prev != null)
                    {
                        SetSelectedItem(selectedItem.Prev);

                        // make sure it's visible
                        if (selectedItem.Rect.y < treeScroll.y)
                        {
                            treeScroll.y = selectedItem.Rect.y;
                        }
                    }
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.DownArrow)
                {
                    if (selectedItem.Next != null)
                    {
                        SetSelectedItem(selectedItem.Next);
                        // make sure it's visible
                        if (selectedItem.Rect.y + selectedItem.Rect.height > treeScroll.y + listRect.height)
                        {
                            treeScroll.y += (selectedItem.Rect.y + selectedItem.Rect.height) - listRect.height;
                        }
                    }
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.RightArrow)
                {
                    selectedItem.Expanded = true;
                    Event.current.Use();
                }
                if (Event.current.keyCode == KeyCode.LeftArrow)
                {
                    selectedItem.Expanded = false;
                    Event.current.Use();
                }
            }

            // Show the search box at the top
            GUILayout.BeginArea(searchRect);
            GUILayout.BeginHorizontal();
            GUILayout.Label(new GUIContent(searchIcon), GUILayout.ExpandWidth(false));
            GUI.SetNextControlName("SearchBox");
            searchString = EditorGUILayout.TextField(searchString);
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            if (fromInspector)
            {
                EditorGUI.FocusTextInControl("SearchBox");

                if (selectedItem != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return &&
                    !(selectedItem.EventRef == null && selectedItem.BankRef == null))
                {
                    Event.current.Use();

                    if (selectedItem.EventRef != null)
                    {
                        outputProperty.stringValue = "";
                        outputProperty.stringValue = selectedItem.EventRef.Path;
                        EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, selectedItem.EventRef.Path);
                    }
                    else
                    {
                        outputProperty.stringValue = selectedItem.BankRef.Name;
                    }
                    outputProperty.serializedObject.ApplyModifiedProperties();
                    Close();
                }
                if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape)
                {
                    Close();
                }
            }

            // Show the tree view

            Predicate <TreeItem> searchFilter = null;

            searchFilter = (x) => (x.Name.ToLower().Contains(searchString.ToLower()) || x.Children.Exists(searchFilter));

            // Check if our selected item still matches the search string
            if (selectedItem != null && !String.IsNullOrEmpty(searchString) && selectedItem.Children.Count == 0)
            {
                Predicate <TreeItem> containsSelected = null;
                containsSelected = (x) => (x == selectedItem || x.Children.Exists(containsSelected));
                Predicate <TreeItem> matchForSelected = null;
                matchForSelected = (x) => (x.Name.ToLower().Contains(searchString.ToLower()) && (x == selectedItem || x.Children.Exists(containsSelected))) || x.Children.Exists(matchForSelected);
                if (!treeItems.Exists(matchForSelected))
                {
                    SetSelectedItem(null);
                }
            }

            GUILayout.BeginArea(listRect);
            treeScroll = GUILayout.BeginScrollView(treeScroll, GUILayout.ExpandHeight(true));

            lastDrawnItem = null;
            itemCount     = 0;

            if (showEvents)
            {
                treeItems[0].Expanded = fromInspector ? true : treeItems[0].Expanded;
                ShowEventFolder(treeItems[0], searchFilter);
                ShowEventFolder(treeItems[1], searchFilter);
            }
            if (showBanks)
            {
                treeItems[2].Expanded = fromInspector ? true : treeItems[2].Expanded;
                ShowEventFolder(treeItems[2], searchFilter);
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();

            // If the standalone event browser show a preview of the selected item
            if (!fromInspector)
            {
                GUI.Box(previewRect, GUIContent.none);

                if (selectedItem != null && selectedItem.EventRef != null && selectedItem.EventRef.Path.StartsWith("event:"))
                {
                    PreviewEvent(previewRect, selectedItem.EventRef);
                }

                if (selectedItem != null && selectedItem.EventRef != null && selectedItem.EventRef.Path.StartsWith("snapshot:"))
                {
                    PreviewSnapshot(previewRect, selectedItem.EventRef);
                }

                if (selectedItem != null && selectedItem.BankRef != null)
                {
                    PreviewBank(previewRect, selectedItem.BankRef);
                }
            }
        }
Beispiel #6
0
    void OnGUI()
    {
        EditorGUILayout.BeginVertical(GUI.skin.box, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

        GUILayout.Label("Incremental Splatmapping", EditorStyles.boldLabel);
        EditorGUILayout.Separator();

        // bold titles
        GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);

        myFoldoutStyle.fontStyle = FontStyle.Bold;

        EditorGUILayout.Separator();
        GUILayout.BeginHorizontal();
        GUILayout.Label("Terrain");
        MyTerrain = (Terrain)EditorGUILayout.ObjectField("", MyTerrain, typeof(Terrain), true);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Splatmap");
        GUILayout.FlexibleSpace();
        Splatmap = (Texture2D)EditorGUILayout.ObjectField("", Splatmap, typeof(Texture2D), false);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Red");
        GUILayout.FlexibleSpace();
        TextureRed = (Texture2D)EditorGUILayout.ObjectField("", TextureRed, typeof(Texture2D), false);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Tile Size Red");
        GUILayout.FlexibleSpace();
        TileSizeRed = EditorGUILayout.IntSlider(TileSizeRed, 4, 512);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Green");
        GUILayout.FlexibleSpace();
        TextureGreen = (Texture2D)EditorGUILayout.ObjectField("", TextureGreen, typeof(Texture2D), false);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Tile Size Green");
        GUILayout.FlexibleSpace();
        TileSizeGreen = EditorGUILayout.IntSlider(TileSizeGreen, 4, 512);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        EditorGUILayout.PrefixLabel("Texture Blue");
        GUILayout.FlexibleSpace();
        TextureBlue = (Texture2D)EditorGUILayout.ObjectField("", TextureBlue, typeof(Texture2D), false);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Tile Size Blue");
        GUILayout.FlexibleSpace();
        TileSizeBlue = EditorGUILayout.IntSlider(TileSizeBlue, 4, 512);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Strength of this layer");
        GUILayout.FlexibleSpace();
        bias = EditorGUILayout.Slider(bias, 0.1f, 10.0f);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.Label("replace old textures");
        GUILayout.FlexibleSpace();
        Replacing = EditorGUILayout.Toggle("", Replacing);
        GUILayout.EndHorizontal();

        EditorGUILayout.Separator();

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Add Splat Texture", GUILayout.Width(200), GUILayout.Height(32)))
        {
            if (CheckSplatmap())
            {
                AddSplatTexture();
            }
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        EditorGUILayout.EndScrollView();
        EditorGUILayout.EndVertical();
    }
    private void DrawSourceGUI()
    {
        EditorGUI.BeginDisabledGroup(isPlay);

        EditorGUILayout.PropertyField(pSource);

#if UNITY_WEBPLAYER || UNITY_WEBGL
        if (pSource.enumValueIndex != (int)OnlineMapsSource.Resources)
        {
            EditorGUILayout.PropertyField(pUseProxy, new GUIContent("Use Proxy"));
            EditorGUI.BeginDisabledGroup(!pUseProxy.boolValue);

            EditorGUILayout.PropertyField(pWebplayerProxyURL, new GUIContent("Proxy"));
            EditorGUI.EndDisabledGroup();
        }
#endif

        if (pSource.enumValueIndex != (int)OnlineMapsSource.Online)
        {
            if (GUILayout.Button("Fix Import Settings for Tiles"))
            {
                FixImportSettings();
            }
            if (GUILayout.Button("Import from GMapCatcher"))
            {
                ImportFromGMapCatcher();
            }

            EditorGUILayout.PropertyField(pResourcesPath);

            EditorGUILayout.BeginVertical(GUI.skin.box);
            showResourcesTokens = Foldout(showResourcesTokens, "Available Tokens");
            if (showResourcesTokens)
            {
                GUILayout.Label("{zoom}");
                GUILayout.Label("{x}");
                GUILayout.Label("{y}");
                GUILayout.Label("{quad}");
                GUILayout.Space(10);
            }
            EditorGUILayout.EndVertical();
        }

        EditorGUI.EndDisabledGroup();

        if (pSource.enumValueIndex != (int)OnlineMapsSource.Resources)
        {
            DrawProviderGUI();

            if (mapType.provider.types.Length > 1)
            {
                GUIContent[] availableTypes = mapType.provider.types.Select(t => new GUIContent(t.title)).ToArray();
                if (availableTypes != null)
                {
                    int index = mapType.index;
                    EditorGUI.BeginChangeCheck();
                    index = EditorGUILayout.Popup(new GUIContent("Type", "Type of map texture"), index, availableTypes);
                    if (EditorGUI.EndChangeCheck())
                    {
                        mapType = mapType.provider.types[index];
                        pMapType.stringValue = mapType.ToString();
                    }
                }
            }

            DrawProviderExtraFields();
            DrawLabelsGUI();
        }
    }
Beispiel #8
0
        public static void Draw(float widht, float height)
        {
            if (!Show)
            {
                return;
            }
            Rect backButton = new Rect(1, 1, 100, 30);

            EditorGUI.DrawRect(backButton, Color.gray);
            GUI.Label(backButton, "back");
            if (backButton.Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseUp)
            {
                Event.current.Use();
                Show = false;
                return;
            }
            InitStyles();

            GUILayout.BeginArea(new Rect(0, 40, widht, height - 40));

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.Box(_logoTexture);
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Graph Development Interface \n", _headline1);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Version " + Config.Version);
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Made for Unity 5.4");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("Copyright  Luca Hofmann");
            GUILayout.EndHorizontal();

            GUILayout.Space(30);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Notice:", _headline2);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("This tool gives you the freedom to create complex graphs that can lead to heavy computations.");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("This can cause Unity to freeze or even crash. Make sure to frequently save your progress to avoid");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("loss of work. Read the node help text to learn more about performance optimizations of your graphs.");
            GUILayout.EndHorizontal();

            GUILayout.Space(30);
            GUILayout.BeginHorizontal();
            GUILayout.Label("Used software:", _headline2);
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Based on 'Brotherhood of Node' (MIT Licence).");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Some noise nodes are based on Jasper Flick tutorials.");
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            GUILayout.Label("Unity vector color shader by @defaxer");
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
Beispiel #9
0
    void OnGUI()
    {
        GUI.Box(new Rect(0, 0, 320, Screen.height), "");

        GUILayout.BeginVertical(GUILayout.Width(300));
        GUILayout.Label("Wiimote Found: " + WiimoteManager.HasWiimote());
        if (GUILayout.Button("Find Wiimote"))
        {
            WiimoteManager.FindWiimotes();
        }

        if (GUILayout.Button("Cleanup"))
        {
            WiimoteManager.Cleanup(wiimote);
            wiimote = null;
        }

        if (wiimote == null)
        {
            return;
        }

        GUILayout.Label("Extension: " + wiimote.current_ext.ToString());

        GUILayout.Label("LED Test:");
        GUILayout.BeginHorizontal();
        for (int x = 0; x < 4; x++)
        {
            if (GUILayout.Button("" + x, GUILayout.Width(300 / 4)))
            {
                wiimote.SendPlayerLED(x == 0, x == 1, x == 2, x == 3);
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("Set Report:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("But/Acc", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL);
        }
        if (GUILayout.Button("But/Ext8", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_EXT8);
        }
        if (GUILayout.Button("B/A/Ext16", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_BUTTONS_ACCEL_EXT16);
        }
        if (GUILayout.Button("Ext21", GUILayout.Width(300 / 4)))
        {
            wiimote.SendDataReportMode(InputDataType.REPORT_EXT21);
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Request Status Report"))
        {
            wiimote.SendStatusInfoRequest();
        }

        GUILayout.Label("IR Setup Sequence:");
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Basic", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.BASIC);
        }
        if (GUILayout.Button("Extended", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.EXTENDED);
        }
        if (GUILayout.Button("Full", GUILayout.Width(100)))
        {
            wiimote.SetupIRCamera(IRDataType.FULL);
        }
        GUILayout.EndHorizontal();

        GUILayout.Label("WMP Attached: " + wiimote.wmp_attached);
        if (GUILayout.Button("Request Identify WMP"))
        {
            wiimote.RequestIdentifyWiiMotionPlus();
        }
        if ((wiimote.wmp_attached || wiimote.Type == WiimoteType.PROCONTROLLER) && GUILayout.Button("Activate WMP"))
        {
            wiimote.ActivateWiiMotionPlus();
        }
        if ((wiimote.current_ext == ExtensionController.MOTIONPLUS ||
             wiimote.current_ext == ExtensionController.MOTIONPLUS_CLASSIC ||
             wiimote.current_ext == ExtensionController.MOTIONPLUS_NUNCHUCK) && GUILayout.Button("Deactivate WMP"))
        {
            wiimote.DeactivateWiiMotionPlus();
        }

        GUILayout.Label("Calibrate Accelerometer");
        GUILayout.BeginHorizontal();
        for (int x = 0; x < 3; x++)
        {
            AccelCalibrationStep step = (AccelCalibrationStep)x;
            if (GUILayout.Button(step.ToString(), GUILayout.Width(100)))
            {
                wiimote.Accel.CalibrateAccel(step);
            }
        }
        GUILayout.EndHorizontal();

        if (GUILayout.Button("Print Calibration Data"))
        {
            StringBuilder str = new StringBuilder();
            for (int x = 0; x < 3; x++)
            {
                for (int y = 0; y < 3; y++)
                {
                    str.Append(wiimote.Accel.accel_calib[y, x]).Append(" ");
                }
                str.Append("\n");
            }
            Debug.Log(str.ToString());
        }

        if (wiimote != null && wiimote.current_ext != ExtensionController.NONE)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            GUIStyle bold = new GUIStyle(GUI.skin.button);
            bold.fontStyle = FontStyle.Bold;
            if (wiimote.current_ext == ExtensionController.NUNCHUCK)
            {
                GUILayout.Label("Nunchuck:", bold);
                NunchuckData data = wiimote.Nunchuck;
                GUILayout.Label("Stick: " + data.stick[0] + ", " + data.stick[1]);
                GUILayout.Label("C: " + data.c);
                GUILayout.Label("Z: " + data.z);
            }
            else if (wiimote.current_ext == ExtensionController.CLASSIC)
            {
                GUILayout.Label("Classic Controller:", bold);
                ClassicControllerData data = wiimote.ClassicController;
                GUILayout.Label("Stick Left: " + data.lstick[0] + ", " + data.lstick[1]);
                GUILayout.Label("Stick Right: " + data.rstick[0] + ", " + data.rstick[1]);
                GUILayout.Label("Trigger Left: " + data.ltrigger_range);
                GUILayout.Label("Trigger Right: " + data.rtrigger_range);
                GUILayout.Label("Trigger Left Button: " + data.ltrigger_switch);
                GUILayout.Label("Trigger Right Button: " + data.rtrigger_switch);
                GUILayout.Label("A: " + data.a);
                GUILayout.Label("B: " + data.b);
                GUILayout.Label("X: " + data.x);
                GUILayout.Label("Y: " + data.y);
                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Home: " + data.home);
                GUILayout.Label("ZL: " + data.zl);
                GUILayout.Label("ZR: " + data.zr);
                GUILayout.Label("D-Up: " + data.dpad_up);
                GUILayout.Label("D-Down: " + data.dpad_down);
                GUILayout.Label("D-Left: " + data.dpad_left);
                GUILayout.Label("D-Right: " + data.dpad_right);
            }
            else if (wiimote.current_ext == ExtensionController.MOTIONPLUS)
            {
                GUILayout.Label("Wii Motion Plus:", bold);
                MotionPlusData data = wiimote.MotionPlus;
                GUILayout.Label("Pitch Speed: " + data.PitchSpeed);
                GUILayout.Label("Yaw Speed: " + data.YawSpeed);
                GUILayout.Label("Roll Speed: " + data.RollSpeed);
                GUILayout.Label("Pitch Slow: " + data.PitchSlow);
                GUILayout.Label("Yaw Slow: " + data.YawSlow);
                GUILayout.Label("Roll Slow: " + data.RollSlow);
                if (GUILayout.Button("Zero Out WMP"))
                {
                    data.SetZeroValues();
                    model.rot.rotation = Quaternion.FromToRotation(model.rot.rotation * GetAccelVector(), Vector3.up) * model.rot.rotation;
                    model.rot.rotation = Quaternion.FromToRotation(model.rot.forward, Vector3.forward) * model.rot.rotation;
                }
                if (GUILayout.Button("Reset Offset"))
                {
                    wmpOffset = Vector3.zero;
                }
                GUILayout.Label("Offset: " + wmpOffset.ToString());
            }
            else if (wiimote.current_ext == ExtensionController.WIIU_PRO)
            {
                GUILayout.Label("Wii U Pro Controller:", bold);
                WiiUProData data = wiimote.WiiUPro;
                GUILayout.Label("Stick Left: " + data.lstick[0] + ", " + data.lstick[1]);
                GUILayout.Label("Stick Right: " + data.rstick[0] + ", " + data.rstick[1]);
                GUILayout.Label("A: " + data.a);
                GUILayout.Label("B: " + data.b);
                GUILayout.Label("X: " + data.x);
                GUILayout.Label("Y: " + data.y);

                GUILayout.Label("D-Up: " + data.dpad_up);
                GUILayout.Label("D-Down: " + data.dpad_down);
                GUILayout.Label("D-Left: " + data.dpad_left);
                GUILayout.Label("D-Right: " + data.dpad_right);

                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Home: " + data.home);

                GUILayout.Label("L: " + data.l);
                GUILayout.Label("R: " + data.r);
                GUILayout.Label("ZL: " + data.zl);
                GUILayout.Label("ZR: " + data.zr);
            }
            else if (wiimote.current_ext == ExtensionController.GUITAR)
            {
                GUILayout.Label("Guitar", bold);
                GuitarData data  = wiimote.Guitar;
                float[]    stick = data.GetStick01();
                GUILayout.Label("Stick: " + stick [0] + ", " + stick [1]);
                GUILayout.Label("Slider: " + (data.has_slider ? Convert.ToString(data.GetSlider01()) : "unsupported"));
                GUILayout.Label("Green: " + data.green);
                GUILayout.Label("Red: " + data.red);
                GUILayout.Label("Yellow: " + data.yellow);
                GUILayout.Label("Blue: " + data.blue);
                GUILayout.Label("Orange: " + data.orange);
                GUILayout.Label("Strum Up: " + data.strum_up);
                GUILayout.Label("Strum Down: " + data.strum_down);
                GUILayout.Label("Minus: " + data.minus);
                GUILayout.Label("Plus: " + data.plus);
                GUILayout.Label("Whammy: " + data.GetWhammy01());
            }
            GUILayout.EndScrollView();
        }
        else
        {
            scrollPosition = Vector2.zero;
        }
        GUILayout.EndVertical();
    }
Beispiel #10
0
        private void DrawServerList()
        {
            GUILayout.BeginHorizontal();

            if (DisplayedServers == null || !DisplayedServers.Any())
            {
                GUILayout.BeginHorizontal();
                GUILayout.Space(WindowWidth * 0.25f);
                GUILayout.BeginVertical();
                GUILayout.Space(WindowHeight * 0.25f);
                GUILayout.Label("No servers!", BigLabelStyle);
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.BeginVertical();
                foreach (var currentEntry in DisplayedServers)
                {
                    GUILayout.BeginHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(25));
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("▶", ButtonStyle))
                    {
                        NetworkServerList.IntroduceToServer(currentEntry.Id);
                        Display = false;
                    }
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(50));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{currentEntry.Ping}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(50));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{currentEntry.PlayerCount}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(90));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{currentEntry.MaxPlayers}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(85));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{(GameMode)currentEntry.GameMode}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(85));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{(WarpMode)currentEntry.WarpMode}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(50));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{(TerrainQuality)currentEntry.TerrainQuality}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(35));
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(new GUIContent($"{currentEntry.Cheats}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(325));
                    GUILayout.Space(20);
                    GUILayout.Label(new GUIContent($"{currentEntry.ServerName}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal(GUILayout.Width(1000));
                    GUILayout.Space(20);
                    GUILayout.Label(new GUIContent($"{currentEntry.Description}"));
                    GUILayout.FlexibleSpace();
                    GUILayout.EndHorizontal();

                    GUILayout.EndHorizontal();
                }
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
        }
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();

            var thisSP  = target as SplinePoint;
            var thisIdx = thisSP.transform.GetSiblingIndex();

            var parent = thisSP.transform.parent;

            if (parent == null || parent.GetComponent <Spline>() == null)
            {
                EditorGUILayout.HelpBox("Spline component must be present on parent of this GameObject.", MessageType.Error);
                return;
            }

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

            GUILayout.BeginHorizontal();
            if (thisIdx == 0)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Select previous"))
            {
                Selection.activeObject = parent.GetChild(thisIdx - 1).gameObject;
            }
            GUI.enabled = true;
            if (thisIdx == parent.childCount - 1)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Select next"))
            {
                Selection.activeObject = parent.GetChild(thisIdx + 1).gameObject;
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Select spline"))
            {
                Selection.activeObject = parent.gameObject;
            }

            GUILayout.Label("Spline actions", EditorStyles.boldLabel);

            GUILayout.BeginHorizontal();
            string label;

            label = thisIdx == 0 ? "Add before (extend)" : "Add before";
            if (GUILayout.Button(label))
            {
                var newPoint = AddSplinePointBefore(parent, thisIdx);

                Undo.RegisterCreatedObjectUndo(newPoint, "Add Crest Spline Point");

                Selection.activeObject = newPoint;
            }

            label = (thisIdx == parent.childCount - 1 || parent.childCount == 0) ? "Add after (extend)" : "Add after";
            if (GUILayout.Button(label))
            {
                var newPoint = AddSplinePointAfter(parent, thisIdx);

                Undo.RegisterCreatedObjectUndo(newPoint, "Add Crest Spline Point");

                Selection.activeObject = newPoint;
            }
            GUILayout.EndHorizontal();

            if (GUILayout.Button("Delete"))
            {
                if (thisIdx > 0)
                {
                    Selection.activeObject = parent.GetChild(thisIdx - 1);
                }
                else
                {
                    // If there is more than one child, select the first
                    if (parent.childCount > 1)
                    {
                        Selection.activeObject = parent.GetChild(1);
                    }
                    else
                    {
                        // No children - select the parent
                        Selection.activeObject = parent;
                    }
                }
                DestroyImmediate(thisSP.gameObject);
            }
        }
Beispiel #12
0
        public static void PlanetWindow(int id)
        {
            // Close Button
            if (GUI.Button(new Rect(AHEditor.rectPlanetWindow.size.x - 22, 2, 20, 20), "X"))
            {
                AHEditor.ClosePlanetWindow();
            }

            GUILayout.BeginVertical();
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            // Planet name
            GUILayout.Label(/*Planet / Moon*/ Localizer.Format("#autoLOC_AH_0024"));
            foreach (MyTuple planet in AHUtil.signalPlanetList)
            {
                GUILayout.Label(
                    new GUIContent(
                        planet.item1,
                        /*Min*/ Localizer.Format("#autoLOC_AH_0025") + " = " + planet.item2.ToString("N0") + "m | "
                        + /*Max*/ Localizer.Format("#autoLOC_AH_0026") + " = " + planet.item3.ToString("N0") + "m"));
//				GUI.Label (new Rect (Mouse.screenPos.x, Mouse.screenPos.y, 50, 20), GUI.tooltip);
                GUILayout.BeginArea(new Rect
                                        (Mouse.screenPos.x - AHEditor.rectPlanetWindow.position.x,
                                        Mouse.screenPos.y - AHEditor.rectPlanetWindow.position.y - 15, 450, 30));
                GUILayout.Label(GUI.tooltip);
                GUILayout.EndArea();
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            // Min distance
            GUILayout.Label(/*Signal at Min Distance*/ Localizer.Format("#autoLOC_AH_0027"));
            if (antennaTypeIsDirect)
            {
                foreach (double signal in AHEditor.signalMinDirect)
                {
                    GUILayout.Label(signal.ToString("0.00%"));
                }
            }
            else
            {
                foreach (double signal in AHEditor.signalMinRelay)
                {
                    GUILayout.Label(signal.ToString("0.00%"));
                }
            }

            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            // Max distance
            GUILayout.Label(/*Signal at Max Distance*/ Localizer.Format("#autoLOC_AH_0028"));
            if (antennaTypeIsDirect)
            {
                foreach (double signal in AHEditor.signalMaxDirect)
                {
                    GUILayout.Label(signal.ToString("0.00%"));
                }
            }
            else
            {
                foreach (double signal in AHEditor.signalMaxRelay)
                {
                    GUILayout.Label(signal.ToString("0.00%"));
                }
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            // Custom distance
            GUILayout.Label(/*Check the Signal Strength at a given distance*/ Localizer.Format("#autoLOC_AH_0029") + " :");
            GUILayout.BeginHorizontal();
            GUILayout.BeginVertical();
            AHEditor.customDistance = GUILayout.TextField(AHEditor.customDistance);
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            if (antennaTypeIsDirect)
            {
                GUILayout.Label(AHEditor.signalCustomDistanceDirect.ToString("0.00%"));
            }
            else
            {
                GUILayout.Label(AHEditor.signalCustomDistanceRelay.ToString("0.00%"));
            }
            GUILayout.EndVertical();
            GUILayout.BeginVertical();
            if (GUILayout.Button(/*Math !*/ Localizer.Format("#autoLOC_AH_0030")))
            {
                AHEditor.CalcCustomDistance();
            }
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUI.DragWindow();
        }
Beispiel #13
0
        public static void TargetWindowPart(int id)
        {
            GUIStyle guiStyleLabel;
            GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label"));
            GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label"));

            guiStyleLabelBold.fontStyle = FontStyle.Bold;

            GUIStyle guiStyleButtonBold = new GUIStyle(GUI.skin.GetStyle("Button"));

            guiStyleButtonBold.fontStyle = FontStyle.Bold;

            // Close Button
            if (GUI.Button(new Rect(AHEditor.rectTargetPartWindow.size.x - 20, 2, 18, 18), "X"))
            {
                AHEditor.CloseTargetPartWindow();
            }

            GUILayout.BeginVertical();
            scrollVectorPart = GUILayout.BeginScrollView(scrollVectorPart);

            foreach (ModuleDataTransmitter antenna in AHShipList.listAntennaPart)
            {
                if (antenna.antennaType != AntennaType.RELAY)
                {
                    continue;
                }

                if (AHEditor.listAntennaPart [antenna] > 0)
                {
                    guiStyleLabel = guiStyleLabelBold;
                }
                else
                {
                    guiStyleLabel = guiStyleLabelNorm;
                }

                GUILayout.BeginHorizontal();

                GUILayout.Label(AHEditor.listAntennaPart [antenna].ToString(), guiStyleLabel, GUILayout.Width(15f));

                if (GUILayout.Button("+", guiStyleButtonBold, GUILayout.Width(20f)))
                {
                    AHEditor.listAntennaPart [antenna]++;
                    AHEditor.UpdateTargetPartPower();
                }
                if (GUILayout.Button("-", guiStyleButtonBold, GUILayout.Width(20f)))
                {
                    AHEditor.listAntennaPart [antenna]--;
                    AHEditor.UpdateTargetPartPower();
                }

                GUILayout.Label(
                    "(" + AHUtil.TruePower(antenna.antennaPower).ToString("N0") + ")  "
                    + antenna.part.partInfo.title, guiStyleLabel);

                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            GUILayout.Space(10f);

            GUILayout.BeginHorizontal();
            GUILayout.Label(/*Power*/ Localizer.Format("#autoLOC_AH_0009") + " : " + AHEditor.targetPartPower.ToString("N0"));
            if (GUILayout.Button(/*Set As Target*/ Localizer.Format("#autoLOC_AH_0023")))
            {
                AHEditor.SetTargetAsPart();
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
Beispiel #14
0
        public static void TargetWindowShipEditor(int id)
        {
            GUIStyle guiStyleLabel;
            GUIStyle guiStyleLabelNorm = new GUIStyle(GUI.skin.GetStyle("Label"));
            GUIStyle guiStyleLabelBold = new GUIStyle(GUI.skin.GetStyle("Label"));

            guiStyleLabelBold.fontStyle = FontStyle.Bold;

            GUIStyle guiStyleButton;
            GUIStyle guiStyleButtonNorm = new GUIStyle(GUI.skin.GetStyle("Button"));
            GUIStyle guiStyleButtonBold = new GUIStyle(GUI.skin.GetStyle("Button"));

            guiStyleButtonBold.fontStyle = FontStyle.Bold;

            GUIStyle guiStyleButtonRed = new GUIStyle(GUI.skin.GetStyle("Button"));

            guiStyleButtonRed.fontStyle        = FontStyle.Bold;
            guiStyleButtonRed.normal.textColor = Color.red;
            guiStyleButtonRed.hover.textColor  = Color.red;

            // Close Button
            if (GUI.Button(new Rect(AHEditor.rectTargetShipEditorWindow.size.x - 20, 2, 18, 18), "X"))
            {
                AHEditor.CloseTargetShipEditorWindow();
            }

            GUILayout.BeginVertical();

            GUILayout.BeginHorizontal();
            if (vab)
            {
                guiStyleButton = guiStyleButtonBold;
            }
            else
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            if (GUILayout.Button(/*VAB*/ Localizer.Format("#autoLOC_AH_0019"), guiStyleButton))
            {
                vab = true;
            }

            if (vab)
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            else
            {
                guiStyleButton = guiStyleButtonBold;
            }
            if (GUILayout.Button(/*SPH*/ Localizer.Format("#autoLOC_AH_0020"), guiStyleButton))
            {
                vab = false;
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Space(35f);
            if (relay)
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            else
            {
                guiStyleButton = guiStyleButtonBold;
            }
            if (GUILayout.Button(/*All*/ Localizer.Format("#autoLOC_AH_0021"), guiStyleButton))
            {
                relay = false;
            }

            if (relay)
            {
                guiStyleButton = guiStyleButtonBold;
            }
            else
            {
                guiStyleButton = guiStyleButtonNorm;
            }
            if (GUILayout.Button(/*Relay*/ Localizer.Format("#autoLOC_AH_0003"), guiStyleButton))
            {
                relay = true;
            }
            GUILayout.Space(35f);
            GUILayout.EndHorizontal();

            scrollVectorEditor = GUILayout.BeginScrollView(scrollVectorEditor);
            if (vab)
            {
                if (relay)
                {
                    displayList = AHEditor.guiExternListShipEditorVabRelay;
                }
                else
                {
                    displayList = AHEditor.guiExternListShipEditorVabAll;
                }
            }
            else
            {
                if (relay)
                {
                    displayList = AHEditor.guiExternListShipEditorSphRelay;
                }
                else
                {
                    displayList = AHEditor.guiExternListShipEditorSphAll;
                }
            }

            foreach (Dictionary <string, string> vesselInfo in displayList)
            {
                if ((vab && (vesselInfo ["type"] != "VAB")) || (!vab && (vesselInfo ["type"] != "SPH")))
                {
                    continue;
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button(Localizer.Format("#autoLOC_AH_0022"), GUILayout.Width(60f)))
                {
                    AHEditor.SetTarget(vesselInfo ["pid"]);
                }

                if (AHEditor.targetPid == vesselInfo ["pid"])
                {
                    guiStyleLabel = guiStyleLabelBold;
                }
                else
                {
                    guiStyleLabel = guiStyleLabelNorm;
                }
                GUILayout.Label(
                    "("
                    + AHUtil.TruePower(Double.Parse(vesselInfo ["powerRelay"])).ToString("N0")
                    + ")  "
                    + vesselInfo ["name"], guiStyleLabel);
                if (GUILayout.Button("X", guiStyleButtonRed, GUILayout.Width(22f)))
                {
                    AHEditor.RemoveShipFromShipList(vesselInfo ["pid"]);
                }
                GUILayout.EndHorizontal();
            }
            GUILayout.EndScrollView();

            GUILayout.EndVertical();
        }
	void DrawPaintPanel()
	{
		var activeBrush = editorData.activeBrush;
		
		if (Ready && (activeBrush == null || activeBrush.Empty))
		{
			editorData.InitBrushes(tileMap.SpriteCollectionInst);
		}
		
		// Draw layer selector
		if (tileMap.data.NumLayers > 1)
		{
			GUILayout.BeginVertical();
			GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
			GUILayout.Label("Layers", EditorStyles.toolbarButton);	GUILayout.FlexibleSpace();	
			GUILayout.EndHorizontal();
			DrawLayersPanel(false);
			EditorGUILayout.Space();
			GUILayout.EndVertical();
		}

#if TK2D_TILEMAP_EXPERIMENTAL
		DrawLoadSaveBrushSection(activeBrush);
#endif

		// Draw palette
		if (!showLoadSection && !showSaveSection)
		{
			editorData.showPalette = EditorGUILayout.Foldout(editorData.showPalette, "Palette");
			if (editorData.showPalette)
			{
				// brush name
				string selectionDesc = "";
				if (activeBrush.tiles.Length == 1) {
					int tile = tk2dRuntime.TileMap.BuilderUtil.GetTileFromRawTile(activeBrush.tiles[0].spriteId);
					if (tile >= 0 && tile < SpriteCollection.spriteDefinitions.Length)
						selectionDesc = SpriteCollection.spriteDefinitions[tile].name;
				}
				GUILayout.Label(selectionDesc);
			
				
				Rect innerRect = brushRenderer.GetBrushViewRect(editorData.paletteBrush, editorData.paletteTilesPerRow);
				paletteScrollPos = EditorGUILayout.BeginScrollView(paletteScrollPos, GUILayout.MinHeight(innerRect.height * editorData.brushDisplayScale + 32.0f));
				innerRect.width *= editorData.brushDisplayScale;
				innerRect.height *= editorData.brushDisplayScale;
				tk2dGrid.Draw(innerRect);

				// palette
				Rect rect = brushRenderer.DrawBrush(tileMap, editorData.paletteBrush, editorData.brushDisplayScale, true, editorData.paletteTilesPerRow);
				float displayScale = brushRenderer.LastScale;
				
				Rect tileSize = new Rect(0, 0, brushRenderer.TileSizePixels.width * displayScale, brushRenderer.TileSizePixels.height * displayScale);
				guiBrushBuilder.HandleGUI(rect, tileSize, editorData.paletteTilesPerRow, tileMap.SpriteCollectionInst, activeBrush);
				EditorGUILayout.Separator();

				EditorGUILayout.EndScrollView();
			}
			EditorGUILayout.Separator();
		}

		// Draw brush
		if (!showLoadSection)
		{
			editorData.showBrush = EditorGUILayout.Foldout(editorData.showBrush, "Brush");
			if (editorData.showBrush)
			{
				GUILayout.BeginHorizontal();
				EditorGUILayout.PrefixLabel("Cursor Tile Opacity");
				tk2dTileMapToolbar.workBrushOpacity = EditorGUILayout.Slider(tk2dTileMapToolbar.workBrushOpacity, 0.0f, 1.0f);
				GUILayout.EndHorizontal();

				Rect innerRect = brushRenderer.GetBrushViewRect(editorData.activeBrush, editorData.paletteTilesPerRow);
				activeBrushScrollPos = EditorGUILayout.BeginScrollView(activeBrushScrollPos, GUILayout.MinHeight(innerRect.height * editorData.brushDisplayScale + 32.0f));
				innerRect.width *= editorData.brushDisplayScale;
				innerRect.height *= editorData.brushDisplayScale;
				tk2dGrid.Draw(innerRect);
				brushRenderer.DrawBrush(tileMap, editorData.activeBrush, editorData.brushDisplayScale, false, editorData.paletteTilesPerRow);
				EditorGUILayout.EndScrollView();
				EditorGUILayout.Separator();
			}
		}
	}
Beispiel #16
0
    void DisplayLatitudeSettings()
    {
        GUILayout.Label("Latitude", EditorStyles.boldLabel);

        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal(GUILayout.MaxWidth(300));

        GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(90) };

        GUIStyle myStyle = new GUIStyle(GUI.skin.textField);

        myStyle.alignment = TextAnchor.MiddleRight;

        GUIStyle shiftStyle = new GUIStyle();

        shiftStyle.alignment        = TextAnchor.UpperLeft;
        shiftStyle.fontStyle        = FontStyle.Bold;
        EditorGUIUtility.labelWidth = 0;

        int textFieldWidth  = 30;
        int textFieldHeight = 18;

        GUILayoutOption[] textFieldoptions = new GUILayoutOption[] { GUILayout.MinWidth(textFieldWidth), GUILayout.MinHeight(textFieldHeight) };

        GUI.SetNextControlName(LATITUDE_DEGREES);
        latDegrees = EditorGUILayout.IntField("", locSettings.LatitudeDegrees(), myStyle, textFieldoptions);

        GUILayout.Label("º", shiftStyle);

        //NORTH-SOUTH button
        options          = new GUILayoutOption[] { GUILayout.Width(50), GUILayout.Height(20) };
        toggleNorthSouth = GUILayout.Button(locSettings.NorthOrSouth(), options);

        GUILayout.FlexibleSpace();

        //Latitude minutes
        EditorGUIUtility.labelWidth = 0;
        options = new GUILayoutOption[] { GUILayout.Width(textFieldWidth) };
        GUI.SetNextControlName(LATITUDE_MINUTES);
        latMinutes = EditorGUILayout.IntField("", locSettings.LatitudeMinutes(), myStyle, textFieldoptions);

        GUILayout.Label("'", shiftStyle);
        GUILayout.FlexibleSpace();

        EditorGUIUtility.labelWidth = 0;
        options = new GUILayoutOption[] { GUILayout.Width(60) };

        string secondStr = locSettings.LatitudeSeconds().ToString("##.##");

        float.TryParse(secondStr, out latSeconds);

        //Latitude seconds
        GUI.SetNextControlName(LATITUDE_SECONDS);
        latSeconds = EditorGUILayout.FloatField("", latSeconds, myStyle, textFieldoptions);

        GUILayout.Label("\"", shiftStyle);

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

        locSettings.UpdateLatitude(latDegrees, latMinutes, latSeconds, toggleNorthSouth);
    }
Beispiel #17
0
        public override void Draw()
        {
            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.FlexibleSpace();
                GUILayout.Label(
                    "Link your PatchKit account",
                    EditorStyles.boldLabel);
                GUILayout.FlexibleSpace();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            {
                GUILayout.Label("API Key:");
                _newApiKey = EditorGUILayout.TextField(_newApiKey);

                if (GUILayout.Button(
                        new GUIContent(
                            PluginResources.Search,
                            "Find your API key"),
                        GUILayout.Width(20),
                        GUILayout.Height(20)))
                {
                    Dispatch(() => OpenProfileWebpage());
                }
            }
            EditorGUILayout.EndHorizontal();

            if (!string.IsNullOrEmpty(_newApiKey))
            {
                if (NewApiKeyValidationError != null)
                {
                    EditorGUILayout.HelpBox(
                        NewApiKeyValidationError,
                        MessageType.Error);
                }
                else
                {
                    EditorGUILayout.Separator();
                    EditorGUILayout.BeginHorizontal();
                    {
                        GUILayout.FlexibleSpace();

                        if (GUILayout.Button("Submit", GUILayout.Width(100)))
                        {
                            Dispatch(() => Link());
                        }

                        GUILayout.FlexibleSpace();
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                EditorGUILayout.HelpBox(
                    "Please enter your API key to link your PatchKit account with extension.",
                    MessageType.Info);
            }

            EditorGUILayout.Separator();
        }
Beispiel #18
0
    void DisplayLongitudeSettings()
    {
        GUILayout.Label("Longitude", EditorStyles.boldLabel);

        GUILayout.BeginVertical();
        GUILayout.BeginHorizontal(GUILayout.MaxWidth(300));

        GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.Width(90) };

        GUIStyle myStyle = new GUIStyle(GUI.skin.textField);

        myStyle.alignment = TextAnchor.MiddleRight;

        GUIStyle shiftStyle = new GUIStyle();

        shiftStyle.alignment        = TextAnchor.UpperLeft;
        shiftStyle.fontStyle        = FontStyle.Bold;
        EditorGUIUtility.labelWidth = 0;

        int textFieldWidth  = 30;
        int textFieldHeight = 18;

        GUILayoutOption[] textFieldoptions = new GUILayoutOption[] { GUILayout.MinWidth(textFieldWidth), GUILayout.MinHeight(textFieldHeight) };

        GUI.SetNextControlName(LONGITUDE_DEGREES);
        lonDegrees = EditorGUILayout.IntField("", locSettings.LongitudeDegrees(), myStyle, textFieldoptions);

        GUILayout.Label("º", shiftStyle);


        //WEST-EAST button
        options        = new GUILayoutOption[] { GUILayout.Width(50), GUILayout.Height(20) };
        toggleWestEast = GUILayout.Button(locSettings.WestOrEast(), options);

        GUILayout.FlexibleSpace();

        EditorGUIUtility.labelWidth = 0;
        options = new GUILayoutOption[] { GUILayout.Width(textFieldWidth) };
        GUI.SetNextControlName(LONGITUDE_MINUTES);
        lonMinutes = EditorGUILayout.IntField("", locSettings.LongitudeMinutes(), myStyle, textFieldoptions);

        GUILayout.Label("'", shiftStyle);
        GUILayout.FlexibleSpace();

        EditorGUIUtility.labelWidth = 0;
        options = new GUILayoutOption[] { GUILayout.Width(60) };

        string secondStr = locSettings.LongitudeSeconds().ToString("##.##");

        float.TryParse(secondStr, out lonSeconds);
        GUI.SetNextControlName(LONGITUDE_SECONDS);
        lonSeconds = EditorGUILayout.FloatField("", lonSeconds, myStyle, textFieldoptions);

        GUILayout.Label("\"", shiftStyle);
        EditorGUILayout.EndHorizontal(  );
        GUILayout.EndVertical();

        locSettings.UpdateLongitude(lonDegrees, lonMinutes, lonSeconds, toggleWestEast);

        /*
         * if(!IsLocationBeingEdited()){
         *      GUI.FocusControl (SEARCH_INPUT);
         *      locSettings.searchInput = "";
         *      Repaint ();
         * }
         */
    }
        private void drawLeftCenterGUI()
        {
            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);
            GUILayout.Toggle(false, "Configs", EditorStyles.toolbarButton);
            EditorGUILayout.EndHorizontal();

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            GUILayout.Label("Asset Version", GUILayout.MaxWidth(100));
            GUI.color = Color.gray;
            GUILayout.TextField(mainBuilder.GameVersion.ToString());
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            GUILayout.Label("App   Version", GUILayout.MaxWidth(100));
            GUI.color = Color.gray;
            GUILayout.TextField(mainBuilder.ApkVersion.ToString());
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("SDK Config", GUILayout.Width(100)))
            {
                BuildUtil.DisableCacheServer();
                Debug.Log("编辑打开!!!!");
            }
            GUI.backgroundColor = Color.red;
            sdkConfigIndex      = EditorGUILayout.Popup(sdkConfigIndex, mainBuilder.NameSDKs, GUILayout.MaxWidth(160));
            GUI.backgroundColor = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.Space(10);

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Development Build", mainBuilder.IsBuildDev ? EditorStyles.boldLabel : EditorStyles.label, GUILayout.MaxWidth(160));
            mainBuilder.IsBuildDev = EditorGUILayout.Toggle(mainBuilder.IsBuildDev, GUILayout.MaxWidth(30));
            GUILayout.EndHorizontal();
            if (!this.mainBuilder.IsBuildDev)
            {
                this.mainBuilder.IsAutoConnectProfile = false;
                this.mainBuilder.IsScriptDebug        = false;
            }

            EditorGUI.BeginDisabledGroup(!this.mainBuilder.IsBuildDev);
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Script Debugging", this.mainBuilder.IsScriptDebug ? EditorStyles.boldLabel : EditorStyles.label, GUILayout.MaxWidth(160));
            this.mainBuilder.IsScriptDebug = EditorGUILayout.Toggle(this.mainBuilder.IsScriptDebug, GUILayout.MaxWidth(30));
            GUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Autoconnect Profile", this.mainBuilder.IsAutoConnectProfile ? EditorStyles.boldLabel : EditorStyles.label, GUILayout.MaxWidth(160));
            this.mainBuilder.IsAutoConnectProfile = EditorGUILayout.Toggle(this.mainBuilder.IsAutoConnectProfile, GUILayout.MaxWidth(30));
            GUILayout.EndHorizontal();
            EditorGUI.EndDisabledGroup();

            //            EditorGUILayout.BeginHorizontal();
            //            EditorGUILayout.LabelField("Config Table", GUILayout.MaxWidth(160));
            //            this.mainBuilder.IsDebug = EditorGUILayout.Toggle(this.mainBuilder.IsDebug, GUILayout.MaxWidth(30));
            //            GUILayout.EndHorizontal();
            //
            //            EditorGUILayout.BeginHorizontal();
            //            EditorGUILayout.LabelField("Lua Script", GUILayout.MaxWidth(160));
            //            this.mainBuilder.IsDebug = EditorGUILayout.Toggle(this.mainBuilder.IsDebug, GUILayout.MaxWidth(30));
            //            GUILayout.EndHorizontal();

            GUILayout.Space(10);
            GUI.backgroundColor = Color.yellow;
            if (GUILayout.Button("Debug Build"))
            {
                mainBuilder.OnClickDebugBuild(true);
            }
            GUI.backgroundColor = Color.white;

            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Buildings", GUILayout.Width(100));
            buildingIndex = EditorGUILayout.Popup(buildingIndex, styles.BuildContents);
            GUILayout.EndHorizontal();
            if (GUILayout.Button("Build"))
            {
                int packageBuildins = styles.BuildPackageOpts[buildingIndex];
                if ((packageBuildins & (int)PackageBuildings.BuildApp) != 0)
                {
                    string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, "../"));
                    string filePath = EditorUtility.SaveFilePanel("Tip", rootPath, PlayerSettings.productName,
                                                                  BuilderPreference.AppExtension.Substring(1));
                    if (!string.IsNullOrEmpty(filePath))
                    {
                        mainBuilder.ApkSavePath = filePath;
                        mainBuilder.OnClickBuild(styles.BuildingOpts[buildingIndex], packageBuildins);
                    }
                }
                else
                {
                    mainBuilder.OnClickBuild(styles.BuildingOpts[buildingIndex], packageBuildins);
                }
            }

            GUILayout.Space(10);
            //GUILayout.Label("", "IN Title");
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("Auto Build", GUILayout.Width(100));
            autoBuildIndex = EditorGUILayout.Popup(autoBuildIndex, styles.OnekeyBuilds);

            GUILayout.EndHorizontal();
            GUI.backgroundColor = Color.green;
            if (GUILayout.Button("Go"))
            {
                string rootPath = Path.GetFullPath(Path.Combine(Application.dataPath, "../"));
                string filePath = EditorUtility.SaveFilePanel("Tip", rootPath, PlayerSettings.productName, BuilderPreference.AppExtension.Substring(1));
                if (!string.IsNullOrEmpty(filePath))
                {
                    mainBuilder.OnClickAutoBuild(filePath, styles.AutoBuilds[autoBuildIndex]);
                }
            }
            GUI.backgroundColor = Color.white;

            GUILayout.Space(5);
            GUILayout.Label("", "IN Title");
            GUILayout.Space(-5);

            GUILayout.BeginVertical(GUILayout.MaxHeight(this.Position.height * 0.5f));
            drawBundleRulePropertys();
            GUILayout.EndVertical();
        }
        public override void OnInspectorGUI()
        {
            bool GUIEnabledValue = GUI.enabled;

            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                GUI.enabled = false;
            }

            if (m_Edited)
            {
                UpdateOrder(m_Edited);
                m_Edited = null;
            }

            EditorGUILayout.BeginVertical(EditorStyles.inspectorFullWidthMargins);
            {
                GUILayout.Label(Content.helpText, EditorStyles.helpBox);

                EditorGUILayout.Space();

                // Vertical that contains box and the toolbar below it
                Rect listRect = EditorGUILayout.BeginVertical();
                {
                    int        dropFieldId = EditorGUIUtility.GetControlID(s_DropFieldHash, FocusType.Passive, listRect);
                    MonoScript dropped     = EditorGUI.DoDropField(listRect, dropFieldId, typeof(MonoScript), MonoScriptValidatorCallback, false, Styles.dropField) as MonoScript;
                    if (dropped)
                    {
                        AddScriptToCustomOrder(dropped);
                    }

                    // Vertical that is used as a border around the scrollview
                    EditorGUILayout.BeginVertical(Styles.boxBackground);
                    {
                        // The scrollview itself
                        m_Scroll = EditorGUILayout.BeginVerticalScrollView(m_Scroll);
                        {
                            // List
                            Rect r       = GUILayoutUtility.GetRect(10, kListElementHeight * m_CustomTimeScripts.Count, GUILayout.ExpandWidth(true));
                            int  changed = DragReorderGUI.DragReorder(r, kListElementHeight, m_CustomTimeScripts, DrawElement);
                            if (changed >= 0)
                            {
                                // Give dragged item value in between neighbors
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                                // Update neighbors if needed
                                UpdateOrder(m_CustomTimeScripts[changed]);
                                // Neighbors may have been moved so there's more space around dragged item,
                                // so set order again to get possible rounding benefits
                                SetExecutionOrderAtIndexAccordingToNeighbors(changed, 0);
                            }
                        } EditorGUILayout.EndScrollView();
                    } EditorGUILayout.EndVertical();

                    // The toolbar below the box
                    GUILayout.BeginHorizontal(Styles.toolbar);
                    {
                        GUILayout.FlexibleSpace();
                        Rect       r2;
                        GUIContent content = Content.iconToolbarPlus;
                        r2 = GUILayoutUtility.GetRect(content, Styles.toolbarDropDown);
                        if (EditorGUI.DropdownButton(r2, content, FocusType.Passive, Styles.toolbarDropDown))
                        {
                            ShowScriptPopup(r2);
                        }
                    } GUILayout.EndHorizontal();
                } GUILayout.EndVertical();

                ApplyRevertGUI();
            } GUILayout.EndVertical();

            GUI.enabled = GUIEnabledValue;
            if (Provider.enabled && !Provider.isActive && !EditorUserSettings.WorkOffline)
            {
                EditorGUILayout.HelpBox("Version control is disconnected", MessageType.Warning);
            }

            GUILayout.FlexibleSpace();
        }
    private void Tab_DrawPhysics()
    {
        FGUI_Inspector.VSpace(-2, -4);

        GUILayout.BeginVertical(FGUI_Resources.ViewBoxStyle);


        // Gravity power
        GUILayout.Space(7f);
        EditorGUILayout.PropertyField(sp_GravityPower, true);
        GUILayout.Space(5f);


        // Physics switch button
        GUILayout.BeginVertical(FGUI_Resources.BGInBoxLightStyle);
        GUILayout.Space(2f);

        // Tab to switch collisions
        GUILayout.BeginHorizontal();

        if (Get.UseCollisions)
        {
            if (GUILayout.Button(new GUIContent(" " + FGUI_Resources.GetFoldSimbol(drawColl, 8, "►") + "  " + Lang("Use Collisions") + " (Experimental)", FGUI_Resources.Tex_Collider, sp_UseCollisions.tooltip), FGUI_Resources.FoldStyle, GUILayout.Height(21)))
            {
                drawColl = !drawColl;
            }
        }
        else
        if (GUILayout.Button(new GUIContent("  " + Lang("Use Collisions") + " (Experimental)", FGUI_Resources.Tex_Collider, sp_UseCollisions.tooltip), FGUI_Resources.FoldStyle, GUILayout.Height(21)))
        {
            Get.UseCollisions = !Get.UseCollisions; serializedObject.ApplyModifiedProperties();
        }

        GUILayout.FlexibleSpace();
        EditorGUILayout.PropertyField(sp_UseCollisions, new GUIContent("", sp_UseCollisions.tooltip), GUILayout.Width(22));

        GUILayout.EndHorizontal();


        //
        if (Get.UseCollisions && drawColl)
        {
            GUILayout.Space(5f);
            GUI.color = new Color(0.85f, 1f, 0.85f, 1f);
            EditorGUILayout.BeginHorizontal(FGUI_Resources.HeaderBoxStyleH);
            string f = FGUI_Resources.GetFoldSimbol(drawInclud); int iconSize = 24; int inclC = Get.IncludedColliders.Count;
            GUI.color = c;

            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));
            if (GUILayout.Button(new GUIContent(" " + f + "  " + Lang("Collide With") + " (" + (inclC == 0 ? "0 !!!)" : inclC + ")"), FGUI_Resources.TexBehaviourIcon), FGUI_Resources.FoldStyle, GUILayout.Height(24)))
            {
                drawInclud = !drawInclud;
            }

            if (drawInclud)
            {
                if (GUILayout.Button("+", new GUILayoutOption[2] {
                    GUILayout.MaxWidth(24), GUILayout.MaxHeight(22)
                }))
                {
                    Get.IncludedColliders.Add(null);
                    serializedObject.Update();
                    serializedObject.ApplyModifiedProperties();
                }
            }

            EditorGUILayout.EndHorizontal();

            if (drawInclud)
            {
                FGUI_Inspector.VSpace(-3, -5);
                GUI.color = new Color(0.6f, .9f, 0.6f, 1f);
                EditorGUILayout.BeginVertical(FGUI_Resources.BGInBoxStyleH);
                GUI.color = c;
                GUILayout.Space(5f);


                // Drawing colliders from list
                if (Get.IncludedColliders.Count == 0)
                {
                    EditorGUILayout.LabelField("Please add here colliders", FGUI_Resources.HeaderStyle);
                    GUILayout.Space(2f);
                }
                else
                {
                    EditorGUI.BeginChangeCheck();
                    for (int i = 0; i < Get.IncludedColliders.Count; i++)
                    {
                        EditorGUILayout.BeginHorizontal();
                        Get.IncludedColliders[i] = (Collider)EditorGUILayout.ObjectField(Get.IncludedColliders[i], typeof(Collider), true);
                        if (GUILayout.Button("X", new GUILayoutOption[2] {
                            GUILayout.MaxWidth(22), GUILayout.MaxHeight(16)
                        }))
                        {
                            Get.IncludedColliders.RemoveAt(i);
                            serializedObject.Update();
                            serializedObject.ApplyModifiedProperties();
                            return;
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        Get.CheckForColliderDuplicates();
                        serializedObject.Update();
                        serializedObject.ApplyModifiedProperties();
                    }
                }

                GUILayout.Space(6f);

                // Lock button
                GUILayout.BeginVertical();
                if (ActiveEditorTracker.sharedTracker.isLocked)
                {
                    GUI.color = new Color(0.44f, 0.44f, 0.44f, 0.8f);
                }
                else
                {
                    GUI.color = new Color(0.95f, 0.95f, 0.99f, 0.9f);
                }
                if (GUILayout.Button(new GUIContent("Lock Inspector for Drag & Drop Colliders", "Drag & drop colliders to 'Included Colliders' List from the hierarchy"), FGUI_Resources.ButtonStyle, GUILayout.Height(18)))
                {
                    ActiveEditorTracker.sharedTracker.isLocked = !ActiveEditorTracker.sharedTracker.isLocked;
                }
                GUI.color = c;
                GUILayout.EndVertical();

                // Drag and drop box
                El_DrawDragAndDropCollidersBox();

                GUILayout.Space(3f);
                EditorGUILayout.EndVertical();
            }


            GUILayout.Space(5f);

            f         = FGUI_Resources.GetFoldSimbol(drawCollSetup);
            GUI.color = new Color(1f, .85f, .85f, 1f);
            EditorGUILayout.BeginHorizontal(FGUI_Resources.HeaderBoxStyleH); iconSize = 22;
            GUI.color = c;
            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));
            if (GUILayout.Button(FGUI_Resources.Tex_GearSetup, EditorStyles.label, new GUILayoutOption[2] {
                GUILayout.Width(iconSize), GUILayout.Height(iconSize)
            }))
            {
                drawCollSetup = !drawCollSetup;
            }
            if (GUILayout.Button(f + "     " + "Colliders Setup" + "     " + f, FGUI_Resources.HeaderStyle, GUILayout.Height(24)))
            {
                drawCollSetup = !drawCollSetup;
            }
            if (GUILayout.Button(FGUI_Resources.Tex_GearSetup, EditorStyles.label, new GUILayoutOption[2] {
                GUILayout.Width(iconSize), GUILayout.Height(iconSize)
            }))
            {
                drawCollSetup = !drawCollSetup;
            }
            GUILayout.Label(new GUIContent(" "), GUILayout.Width(1));
            EditorGUILayout.EndHorizontal();

            if (drawCollSetup)
            {
                FGUI_Inspector.VSpace(-3, -5);
                GUI.color = new Color(1f, .55f, .55f, 1f);
                EditorGUILayout.BeginVertical(FGUI_Resources.BGInBoxStyleH);
                GUI.color = c;
                GUILayout.Space(6f);
                EditorGUILayout.PropertyField(sp_CollidersScaleMul, new GUIContent("Scale Multiplier"));
                EditorGUILayout.PropertyField(sp_CollidersScale, new GUIContent("Scale Curve"));
                EditorGUILayout.PropertyField(sp_CollidersAutoCurve, new GUIContent("Auto Curve"));
                EditorGUILayout.PropertyField(sp_AllCollidersOffset, true);
                GUILayout.Space(6f);


                El_DrawSelectiveCollision();

                GUILayout.Space(3f);
                EditorGUILayout.EndVertical();
            }

            GUILayout.Space(5f);

            if (Get.UseTruePosition)
            {
                GUI.color = new Color(1f, 0.7f, 0.7f, 1f);
            }
            else
            {
                GUI.color = new Color(1f, 1f, 0.7f, 1f);
            }
            GUILayout.BeginVertical(FGUI_Resources.BGInBoxLightStyle);
            GUILayout.Space(2f); EditorGUILayout.PropertyField(sp_UseTruePosition, true); GUILayout.Space(2f);
            GUILayout.EndVertical(); GUI.color = c;

            GUILayout.BeginVertical(FGUI_Resources.BGInBoxStyle);
            GUILayout.Space(2f); EditorGUILayout.PropertyField(sp_DetailedCollision, true); GUILayout.Space(2f);
            GUILayout.EndVertical();
            GUILayout.Space(2f);
        }


        GUILayout.Space(2f);
        GUILayout.EndVertical();
        GUILayout.Space(-5f);
        GUILayout.EndVertical();
    }
Beispiel #22
0
 public static void Draw(GUIStyle icon, float iconSize)
 {
     GUILayout.Label(GUIContent.none, icon, GUILayout.Width(iconSize), GUILayout.Height(iconSize));
 }
Beispiel #23
0
        void ShowEventFolder(TreeItem item, Predicate <TreeItem> filter)
        {
            eventStyle.padding.left += 17;

            {
                // Highlight first found item
                if (item.EventRef != null || item.BankRef != null)
                {
                    if (!String.IsNullOrEmpty(searchString) &&
                        itemCount == 0 &&
                        selectedItem == null
                        )
                    {
                        SetSelectedItem(item);
                    }

                    itemCount++;
                }

                item.Next = null;
                item.Prev = lastDrawnItem;
                if (lastDrawnItem != null)
                {
                    lastDrawnItem.Next = item;
                }
                lastDrawnItem = item;
            }

            if (item.EventRef != null)
            {
                // Rendering and GUI event handling to show an event
                GUIContent content = new GUIContent(item.Name, item.EventRef.Path.StartsWith("snapshot") ? snapshotIcon : eventIcon);

                eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null;

                GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true));

                Event e = Event.current;

                Rect rect = GUILayoutUtility.GetLastRect();
                if (e.type == EventType.MouseDown &&
                    e.button == 0 &&
                    rect.Contains(e.mousePosition))
                {
                    e.Use();

                    if (fromInspector && e.clickCount >= 2)
                    {
                        outputProperty.stringValue = "";
                        outputProperty.stringValue = item.EventRef.Path;
                        EditorUtils.UpdateParamsOnEmitter(outputProperty.serializedObject, item.EventRef.Path);
                        outputProperty.serializedObject.ApplyModifiedProperties();

                        Close();
                    }

                    SetSelectedItem(item);
                }
                if (e.type == EventType.mouseDrag && rect.Contains(e.mousePosition) && !fromInspector)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.objectReferences = new UnityEngine.Object[] { ScriptableObject.Instantiate(item.EventRef) };
                    DragAndDrop.StartDrag("New FMOD Studio Emitter");
                    e.Use();
                }
                if (Event.current.type == EventType.Repaint)
                {
                    item.Rect = rect;
                }
            }
            else if (item.BankRef != null)
            {
                // Rendering and event handling for a bank
                GUIContent content = new GUIContent(item.Name, bankIcon);

                eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null;

                GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true));

                Event e = Event.current;

                Rect rect = GUILayoutUtility.GetLastRect();
                if (e.type == EventType.MouseDown &&
                    e.button == 0 &&
                    rect.Contains(e.mousePosition))
                {
                    e.Use();

                    if (fromInspector && e.clickCount >= 2)
                    {
                        outputProperty.stringValue = item.BankRef.Name;
                        outputProperty.serializedObject.ApplyModifiedProperties();
                        Close();
                    }

                    SetSelectedItem(item);
                }
                if (e.type == EventType.mouseDrag && rect.Contains(e.mousePosition) && !fromInspector)
                {
                    DragAndDrop.PrepareStartDrag();
                    DragAndDrop.objectReferences = new UnityEngine.Object[] { ScriptableObject.Instantiate(item.BankRef) };
                    DragAndDrop.StartDrag("New FMOD Studio Bank Loader");
                    e.Use();
                }
                if (Event.current.type == EventType.Repaint)
                {
                    item.Rect = rect;
                }
            }
            else
            {
                eventStyle.normal.background = selectedItem == item?EditorGUIUtility.Load("FMOD/Selected.png") as Texture2D : null;

                bool       expanded = item.Expanded || !string.IsNullOrEmpty(searchString);
                GUIContent content  = new GUIContent(item.Name, expanded ? folderOpenIcon : folderClosedIcon);
                GUILayout.Label(content, eventStyle, GUILayout.ExpandWidth(true));

                Rect rect = GUILayoutUtility.GetLastRect();
                if (Event.current.type == EventType.MouseDown &&
                    Event.current.button == 0 &&
                    rect.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    item.Expanded = !item.Expanded;
                    SetSelectedItem(item);
                }

                if (item.Expanded || !string.IsNullOrEmpty(searchString))
                {
                    item.Children.Sort((a, b) => a.Name.CompareTo(b.Name));
                    if (item.Name.ToLower().Contains(searchString.ToLower()))
                    {
                        foreach (var childFolder in item.Children)
                        {
                            ShowEventFolder(childFolder, (x) => true);
                        }
                    }
                    else
                    {
                        foreach (var childFolder in item.Children.FindAll(filter))
                        {
                            ShowEventFolder(childFolder, filter);
                        }
                    }
                }

                if (Event.current.type == EventType.Repaint)
                {
                    item.Rect = rect;
                }
            }
            eventStyle.padding.left -= 17;
        }
Beispiel #24
0
        public override void OnInspectorGUI()
        {
            var styleSheet = target as StyleSheet;

            if (styleSheet == null)
            {
                Debug.LogWarning("Expected target to be StyleSheer", target);
                return;
            }

            var parentStyleSheet = styleSheet.Parent;

            styleSheet.Parent = EditorGUILayout.ObjectField("Parent", styleSheet.Parent, typeof(StyleSheet), false) as StyleSheet;

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            EditorGUILayout.BeginVertical();

            // Draw table header
            EditorGUILayout.BeginHorizontal();

            GUILayout.Space(OverrideColumnWidth);
            GUILayout.Label("Name");
            GUILayout.Label("Img", GUILayout.Width(ColourColumnWidth));
            GUILayout.Label("Norm.", GUILayout.Width(ColourColumnWidth));
            GUILayout.Label("Hov.", GUILayout.Width(ColourColumnWidth));
            GUILayout.Label("Actv.", GUILayout.Width(ColourColumnWidth));
            GUILayout.Label("Dsbld.", GUILayout.Width(ColourColumnWidth));

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            var keys = styleSheet.GetStyleKeys(false);

            if (parentStyleSheet != null)
            {
                keys = keys.Union(parentStyleSheet.GetStyleKeys());
            }

            // Draw rows
            foreach (var key in keys)
            {
                // Style from the current stylesheet
                var style = styleSheet.GetStyle(key, false);

                // Style from the parent stylesheet
                Style parentStyle = null;

                if (parentStyleSheet != null)
                {
                    parentStyle = parentStyleSheet.GetStyle(key, true);
                }

                EditorGUILayout.BeginHorizontal();

                var canEdit = style != null;

                // If there is a parent stylesheet, and the parent contains this key
                if (parentStyleSheet != null && parentStyle != null)
                {
                    var overrideParent = GUILayout.Toggle(style != null, "", GUILayout.Width(OverrideColumnWidth));

                    if (overrideParent && style == null)
                    {
                        // Copy the style to the current stylesheet
                        Undo.RecordObject(styleSheet, "Override Style");
                        styleSheet.AddStyle(key);
                        style = styleSheet.GetStyle(key, false);
                        style.CopyFrom(parentStyle);
                        EditorUtility.SetDirty(styleSheet);
                        canEdit = true;
                    }
                    else if (!overrideParent && style != null)
                    {
                        Undo.RecordObject(styleSheet, "Delete Style");
                        styleSheet.DeleteStyle(key);
                        style = null;
                        EditorUtility.SetDirty(styleSheet);
                        canEdit = false;
                    }
                }
                else
                {
                    // Otherwise display a delete button

                    if (GUILayout.Button("X", GUILayout.Width(OverrideColumnWidth)))
                    {
                        Undo.RecordObject(styleSheet, "Delete Style");
                        styleSheet.DeleteStyle(key);
                        EditorUtility.SetDirty(styleSheet);

                        continue;
                    }
                }

                GUI.enabled = canEdit;

                GUILayout.Label(key);

                EditorGUI.BeginChangeCheck();

                var img =
                    EditorGUILayout.ObjectField(style != null ? style.Image : parentStyle.Image, typeof(Sprite), false,
                                                GUILayout.Width(ColourColumnWidth)) as Sprite;

                var normalColor = EditorGUILayout.ColorField(style != null ? style.NormalColor : parentStyle.NormalColor,
                                                             GUILayout.Width(ColourColumnWidth));
                var hoverColor = EditorGUILayout.ColorField(style != null ? style.HoverColor : parentStyle.HoverColor,
                                                            GUILayout.Width(ColourColumnWidth));
                var activeColor = EditorGUILayout.ColorField(style != null ? style.ActiveColor : parentStyle.ActiveColor,
                                                             GUILayout.Width(ColourColumnWidth));
                var disabledColor = EditorGUILayout.ColorField(style != null ? style.DisabledColor : parentStyle.DisabledColor,
                                                               GUILayout.Width(ColourColumnWidth));

                if (EditorGUI.EndChangeCheck() && canEdit)
                {
                    Undo.RecordObject(styleSheet, "Update Style");

                    style.Image         = img;
                    style.NormalColor   = normalColor;
                    style.HoverColor    = hoverColor;
                    style.ActiveColor   = activeColor;
                    style.DisabledColor = disabledColor;

                    EditorUtility.SetDirty(styleSheet);
                }

                GUI.enabled = true;

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();

            GUILayout.Label("New Style");

            _newKeyField = EditorGUILayout.TextField(_newKeyField);

            GUI.enabled = !string.IsNullOrEmpty(_newKeyField) && styleSheet.GetStyle(_newKeyField) == null;

            if (GUILayout.Button("Add"))
            {
                Undo.RecordObject(styleSheet, "Add Style");
                styleSheet.AddStyle(_newKeyField);
                EditorUtility.SetDirty(styleSheet);

                _newKeyField = "";
            }

            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();
        }
        /// <summary>
        /// Draws the given <see cref="NugetPackage"/>.
        /// </summary>
        /// <param name="package">The <see cref="NugetPackage"/> to draw.</param>
        private void DrawPackage(NugetPackage package, GUIStyle packageStyle, GUIStyle contrastStyle)
        {
            IEnumerable <NugetPackage> installedPackages = NugetHelper.InstalledPackages;
            var installed = installedPackages.FirstOrDefault(p => p.Id == package.Id);

            EditorGUILayout.BeginHorizontal();
            {
                // The Unity GUI system (in the Editor) is terrible.  This probably requires some explanation.
                // Every time you use a Horizontal block, Unity appears to divide the space evenly.
                // (i.e. 2 components have half of the window width, 3 components have a third of the window width, etc)
                // GUILayoutUtility.GetRect is SUPPOSED to return a rect with the given height and width, but in the GUI layout.  It doesn't.
                // We have to use GUILayoutUtility to get SOME rect properties, but then manually calculate others.
                EditorGUILayout.BeginHorizontal();
                {
                    const int iconSize = 32;
                    int       padding  = EditorStyles.label.padding.vertical;
                    Rect      rect     = GUILayoutUtility.GetRect(iconSize, iconSize);
                    // only use GetRect's Y position.  It doesn't correctly set the width, height or X position.

                    rect.x      = padding;
                    rect.y     += padding;
                    rect.width  = iconSize;
                    rect.height = iconSize;

                    if (package.Icon != null)
                    {
                        GUI.DrawTexture(rect, package.Icon, ScaleMode.StretchToFill);
                    }
                    else
                    {
                        GUI.DrawTexture(rect, defaultIcon, ScaleMode.StretchToFill);
                    }

                    rect.x     = iconSize + 2 * padding;
                    rect.width = position.width / 2 - (iconSize + padding);
                    rect.y    -= padding; // This will leave the text aligned with the top of the image


                    EditorStyles.label.fontStyle = FontStyle.Bold;
                    EditorStyles.label.fontSize  = 16;

                    Vector2 idSize = EditorStyles.label.CalcSize(new GUIContent(package.Id));
                    rect.y += (iconSize / 2 - idSize.y / 2) + padding;
                    GUI.Label(rect, package.Id, EditorStyles.label);
                    rect.x += idSize.x;

                    EditorStyles.label.fontSize  = 10;
                    EditorStyles.label.fontStyle = FontStyle.Normal;

                    Vector2 versionSize = EditorStyles.label.CalcSize(new GUIContent(package.Version));
                    rect.y += (idSize.y - versionSize.y - padding / 2);

                    if (!string.IsNullOrEmpty(package.Authors))
                    {
                        string  authorLabel = string.Format("by {0}", package.Authors);
                        Vector2 size        = EditorStyles.label.CalcSize(new GUIContent(authorLabel));
                        GUI.Label(rect, authorLabel, EditorStyles.label);
                        rect.x += size.x;
                    }

                    if (package.DownloadCount > 0)
                    {
                        string  downloadLabel = string.Format("{0} downloads", package.DownloadCount.ToString("#,#"));
                        Vector2 size          = EditorStyles.label.CalcSize(new GUIContent(downloadLabel));
                        GUI.Label(rect, downloadLabel, EditorStyles.label);
                        rect.x += size.x;
                    }
                }

                GUILayout.FlexibleSpace();
                if (installed != null && installed.Version != package.Version)
                {
                    GUILayout.Label(string.Format("Current Version {0}", installed.Version));
                }
                GUILayout.Label(string.Format("Version {0}", package.Version));


                if (installedPackages.Contains(package))
                {
                    // This specific version is installed
                    if (GUILayout.Button("Uninstall"))
                    {
                        // TODO: Perhaps use a "mark as dirty" system instead of updating all of the data all the time?
                        NugetHelper.Uninstall(package);
                        NugetHelper.UpdateInstalledPackages();
                        UpdateUpdatePackages();
                    }
                }
                else
                {
                    if (installed != null)
                    {
                        if (installed < package)
                        {
                            // An older version is installed
                            if (GUILayout.Button("Update"))
                            {
                                NugetHelper.Update(installed, package);
                                NugetHelper.UpdateInstalledPackages();
                                UpdateUpdatePackages();
                            }
                        }
                        else if (installed > package)
                        {
                            // A newer version is installed
                            if (GUILayout.Button("Downgrade"))
                            {
                                NugetHelper.Update(installed, package);
                                NugetHelper.UpdateInstalledPackages();
                                UpdateUpdatePackages();
                            }
                        }
                    }
                    else
                    {
                        if (GUILayout.Button("Install"))
                        {
                            NugetHelper.InstallIdentifier(package);
                            AssetDatabase.Refresh();
                            NugetHelper.UpdateInstalledPackages();
                            UpdateUpdatePackages();
                        }
                    }
                }
                EditorGUILayout.EndHorizontal();
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Space();
            EditorGUILayout.BeginHorizontal();
            {
                EditorGUILayout.BeginVertical();
                {
                    // Show the package details
                    EditorStyles.label.wordWrap  = true;
                    EditorStyles.label.fontStyle = FontStyle.Normal;

                    string summary = package.Summary;
                    if (string.IsNullOrEmpty(summary))
                    {
                        summary = package.Description;
                    }

                    if (!package.Title.Equals(package.Id, StringComparison.InvariantCultureIgnoreCase))
                    {
                        summary = string.Format("{0} - {1}", package.Title, summary);
                    }

                    if (summary.Length >= 240)
                    {
                        summary = string.Format("{0}...", summary.Substring(0, 237));
                    }

                    EditorGUILayout.LabelField(summary);

                    bool   detailsFoldout;
                    string detailsFoldoutId = string.Format("{0}.{1}", package.Id, "Details");
                    if (!foldouts.TryGetValue(detailsFoldoutId, out detailsFoldout))
                    {
                        foldouts[detailsFoldoutId] = detailsFoldout;
                    }
                    detailsFoldout             = EditorGUILayout.Foldout(detailsFoldout, "Details");
                    foldouts[detailsFoldoutId] = detailsFoldout;

                    if (detailsFoldout)
                    {
                        EditorGUI.indentLevel++;
                        if (!string.IsNullOrEmpty(package.Description))
                        {
                            EditorGUILayout.LabelField("Description", EditorStyles.boldLabel);
                            EditorGUILayout.LabelField(package.Description);
                        }

                        if (!string.IsNullOrEmpty(package.ReleaseNotes))
                        {
                            EditorGUILayout.LabelField("Release Notes", EditorStyles.boldLabel);
                            EditorGUILayout.LabelField(package.ReleaseNotes);
                        }

                        // Show project URL link
                        if (!string.IsNullOrEmpty(package.ProjectUrl))
                        {
                            EditorGUILayout.LabelField("Project Url", EditorStyles.boldLabel);
                            GUILayoutLink(package.ProjectUrl);
                            GUILayout.Space(4f);
                        }


                        // Show the dependencies
                        if (package.Dependencies.Count > 0)
                        {
                            EditorStyles.label.wordWrap  = true;
                            EditorStyles.label.fontStyle = FontStyle.Italic;
                            StringBuilder builder = new StringBuilder();

                            NugetFrameworkGroup frameworkGroup = NugetHelper.GetBestDependencyFrameworkGroupForCurrentSettings(package);
                            foreach (var dependency in frameworkGroup.Dependencies)
                            {
                                builder.Append(string.Format(" {0} {1};", dependency.Id, dependency.Version));
                            }
                            EditorGUILayout.Space();
                            EditorGUILayout.LabelField(string.Format("Depends on:{0}", builder.ToString()));
                            EditorStyles.label.fontStyle = FontStyle.Normal;
                        }

                        // Create the style for putting a box around the 'Clone' button
                        var cloneButtonBoxStyle = new GUIStyle("box");
                        cloneButtonBoxStyle.stretchWidth   = false;
                        cloneButtonBoxStyle.margin.top     = 0;
                        cloneButtonBoxStyle.margin.bottom  = 0;
                        cloneButtonBoxStyle.padding.bottom = 4;

                        var normalButtonBoxStyle = new GUIStyle(cloneButtonBoxStyle);
                        normalButtonBoxStyle.normal.background = packageStyle.normal.background;

                        bool showCloneWindow = openCloneWindows.Contains(package);
                        cloneButtonBoxStyle.normal.background = showCloneWindow ? contrastStyle.normal.background : packageStyle.normal.background;

                        // Create a simillar style for the 'Clone' window
                        var cloneWindowStyle = new GUIStyle(cloneButtonBoxStyle);
                        cloneWindowStyle.padding = new RectOffset(6, 6, 2, 6);

                        // Show button bar
                        EditorGUILayout.BeginHorizontal();
                        {
                            if (package.RepositoryType == RepositoryType.Git || package.RepositoryType == RepositoryType.TfsGit)
                            {
                                if (!string.IsNullOrEmpty(package.RepositoryUrl))
                                {
                                    EditorGUILayout.BeginHorizontal(cloneButtonBoxStyle);
                                    {
                                        var cloneButtonStyle = new GUIStyle(GUI.skin.button);
                                        cloneButtonStyle.normal = showCloneWindow ? cloneButtonStyle.active : cloneButtonStyle.normal;
                                        if (GUILayout.Button("Clone", cloneButtonStyle, GUILayout.ExpandWidth(false)))
                                        {
                                            showCloneWindow = !showCloneWindow;
                                        }

                                        if (showCloneWindow)
                                        {
                                            openCloneWindows.Add(package);
                                        }
                                        else
                                        {
                                            openCloneWindows.Remove(package);
                                        }
                                    }
                                    EditorGUILayout.EndHorizontal();
                                }
                            }

                            if (!string.IsNullOrEmpty(package.LicenseUrl) && package.LicenseUrl != "http://your_license_url_here")
                            {
                                // Creaete a box around the license button to keep it alligned with Clone button
                                EditorGUILayout.BeginHorizontal(normalButtonBoxStyle);
                                // Show the license button
                                if (GUILayout.Button("View License", GUILayout.ExpandWidth(false)))
                                {
                                    Application.OpenURL(package.LicenseUrl);
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        if (showCloneWindow)
                        {
                            EditorGUILayout.BeginVertical(cloneWindowStyle);
                            {
                                // Clone latest label
                                EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(20f);
                                EditorGUILayout.LabelField("clone latest");
                                EditorGUILayout.EndHorizontal();

                                // Clone latest row
                                EditorGUILayout.BeginHorizontal();
                                {
                                    if (GUILayout.Button("Copy", GUILayout.ExpandWidth(false)))
                                    {
                                        GUI.FocusControl(package.Id + package.Version + "repoUrl");
                                        GUIUtility.systemCopyBuffer = package.RepositoryUrl;
                                    }

                                    GUI.SetNextControlName(package.Id + package.Version + "repoUrl");
                                    EditorGUILayout.TextField(package.RepositoryUrl);
                                }
                                EditorGUILayout.EndHorizontal();

                                // Clone @ commit label
                                GUILayout.Space(4f);
                                EditorGUILayout.BeginHorizontal();
                                GUILayout.Space(20f);
                                EditorGUILayout.LabelField("clone @ commit");
                                EditorGUILayout.EndHorizontal();

                                // Clone @ commit row
                                EditorGUILayout.BeginHorizontal();
                                {
                                    // Create the three commands a user will need to run to get the repo @ the commit. Intentionally leave off the last newline for better UI appearance
                                    string commands = string.Format("git clone {0} {1} --no-checkout{2}cd {1}{2}git checkout {3}", package.RepositoryUrl, package.Id, Environment.NewLine, package.RepositoryCommit);

                                    if (GUILayout.Button("Copy", GUILayout.ExpandWidth(false)))
                                    {
                                        GUI.FocusControl(package.Id + package.Version + "commands");

                                        // Add a newline so the last command will execute when pasted to the CL
                                        GUIUtility.systemCopyBuffer = (commands + Environment.NewLine);
                                    }

                                    EditorGUILayout.BeginVertical();
                                    GUI.SetNextControlName(package.Id + package.Version + "commands");
                                    EditorGUILayout.TextArea(commands);
                                    EditorGUILayout.EndVertical();
                                }
                                EditorGUILayout.EndHorizontal();
                            }
                            EditorGUILayout.EndVertical();
                        }
                        EditorGUI.indentLevel--;
                    }

                    EditorGUILayout.Separator();
                    EditorGUILayout.Separator();
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
        }
Beispiel #26
0
    public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] properties)
    {
        targetMat = materialEditor.target as Material;
        string[] oldKeyWords = targetMat.shaderKeywords;
        GUIStyle style       = EditorStyles.helpBox;

        style.margin = new RectOffset(0, 0, 0, 0);

        materialEditor.ShaderProperty(properties[0], properties[0].displayName);
        materialEditor.ShaderProperty(properties[1], properties[1].displayName);
        materialEditor.ShaderProperty(properties[2], properties[2].displayName);

        //Not needed since Unity batches sprites on its own
        //EditorGUILayout.Separator();
        //materialEditor.EnableInstancingField();
        //Debug.Log(materialEditor.IsInstancingEnabled() + "  " + Application.isBatchMode);

        EditorGUILayout.Separator();
        Blending(materialEditor, properties, style, oldKeyWords.Contains("CUSTOMBLENDING_ON"), "Custom Blending", "CUSTOMBLENDING_ON");
        Billboard(materialEditor, properties, style, oldKeyWords.Contains("BILBOARD_ON"), "Bilboard active", "BILBOARD_ON");
        ZWrite(materialEditor, properties, style, "Depth Write");
        ZTest(materialEditor, properties, style, oldKeyWords.Contains("CUSTOMZTEST_ON"), "Z Test", "CUSTOMZTEST_ON");
        SpriteAtlas(materialEditor, style, oldKeyWords.Contains("ATLAS_ON"), "Sprite inside an atlas?", "ATLAS_ON");

        EditorGUILayout.Separator();
        GUILayout.Label("___Color Effects___", EditorStyles.boldLabel);

        Glow(materialEditor, properties, style, oldKeyWords.Contains("GLOW_ON"));
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("FADE_ON"), "2.Fade", "FADE_ON", 7, 13);
        Outline(materialEditor, properties, style, oldKeyWords.Contains("OUTBASE_ON"));
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("GRADIENT_ON"), "4.Gradient", "GRADIENT_ON", 31, 35);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("COLORSWAP_ON"), "5.Color Swap", "COLORSWAP_ON", 36, 42);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("HSV_ON"), "6.Hue Shift", "HSV_ON", 43, 45);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("CHANGECOLOR_ON"), "7.Change 1 Color", "CHANGECOLOR_ON", 123, 126);
        ColorRamp(materialEditor, properties, style, oldKeyWords.Contains("COLORRAMP_ON"));
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("HITEFFECT_ON"), "9.Hit Effect", "HITEFFECT_ON", 46, 48);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("NEGATIVE_ON"), "10.Negative", "NEGATIVE_ON", 49, 49);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("PIXELATE_ON"), "11.Pixelate", "PIXELATE_ON", 50, 50);
        GreyScale(materialEditor, properties, style, oldKeyWords.Contains("GREYSCALE_ON"));
        Posterize(materialEditor, properties, style, oldKeyWords.Contains("POSTERIZE_ON"));
        Blur(materialEditor, properties, style, oldKeyWords.Contains("BLUR_ON"));
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("MOTIONBLUR_ON"), "15.Motion Blur", "MOTIONBLUR_ON", 62, 63);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("GHOST_ON"), "16.Ghost", "GHOST_ON", 64, 65);
        InnerOutline(materialEditor, properties, style, oldKeyWords.Contains("INNEROUTLINE_ON"), "17.Inner Outline", "INNEROUTLINE_ON", 66, 69);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("HOLOGRAM_ON"), "18.Hologram", "HOLOGRAM_ON", 73, 77);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("CHROMABERR_ON"), "19.Chromatic Aberration", "CHROMABERR_ON", 78, 79);
        Glitch(materialEditor, properties, style, oldKeyWords.Contains("GLITCH_ON"), "20.Glitch", "GLITCH_ON");
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("FLICKER_ON"), "21.Flicker", "FLICKER_ON", 81, 83);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("SHADOW_ON"), "22.Shadow", "SHADOW_ON", 84, 87);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("SHINE_ON"), "23.Shine", "SHINE_ON", 133, 137);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("ALPHACUTOFF_ON"), "24.Alpha Cutoff", "ALPHACUTOFF_ON", 70, 70);

        EditorGUILayout.Separator();
        GUILayout.Label("___UV Effects___", EditorStyles.boldLabel);

        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("DOODLE_ON"), "25.Hand Drawn", "DOODLE_ON", 88, 89);
        Grass(materialEditor, properties, style, oldKeyWords.Contains("WIND_ON"));
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("WAVEUV_ON"), "27.Wave", "WAVEUV_ON", 94, 98);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("ROUNDWAVEUV_ON"), "28.Round Wave", "ROUNDWAVEUV_ON", 127, 128);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("RECTSIZE_ON"), "29.Rect Size (Enable wireframe to see result)", "RECTSIZE_ON", 99, 99);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("OFFSETUV_ON"), "30.Offset", "OFFSETUV_ON", 100, 101);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("CLIPPING_ON"), "31.Clipping / Fill Amount", "CLIPPING_ON", 102, 105);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("TEXTURESCROLL_ON"), "32.Texture Scroll", "TEXTURESCROLL_ON", 106, 107);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("ZOOMUV_ON"), "33.Zoom", "ZOOMUV_ON", 108, 108);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("DISTORT_ON"), "34.Distortion", "DISTORT_ON", 109, 112);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("TWISTUV_ON"), "35.Twist", "TWISTUV_ON", 113, 116);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("ROTATEUV_ON"), "36.Rotate", "ROTATEUV_ON", 117, 117);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("POLARUV_ON"), "37.Polar Coordinates (Tile texture for good results)", "POLARUV_ON", -1, -1);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("FISHEYE_ON"), "38.Fish Eye", "FISHEYE_ON", 118, 118);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("PINCH_ON"), "39.Pinch", "PINCH_ON", 119, 119);
        GenericEffect(materialEditor, properties, style, oldKeyWords.Contains("SHAKEUV_ON"), "40.Shake", "SHAKEUV_ON", 120, 122);
    }
Beispiel #27
0
        private void DisplayFieldsOrProperties(bool showFields, bool showProperties)
        {
            // Get field and property counts.
            int fieldCount    = 0;
            int propertyCount = 0;

            for (int i = 0; i < fields.Length; i++)
            {
                if (fields[i].isProperty && showProperties)
                {
                    propertyCount++;
                }
                else if ((!fields[i].isProperty) && showFields)
                {
                    fieldCount++;
                }
            }

            // If there is nothing to display, show message.
            if (showFields && showProperties && fieldCount == 0 && propertyCount == 0)
            {
                GUILayout.Label("This type has no serializable fields or properties.");
            }
            else if (showFields && fieldCount == 0)
            {
                GUILayout.Label("This type has no serializable fields.");
            }
            else if (showProperties && propertyCount == 0)
            {
                GUILayout.Label("This type has no serializable properties.");
            }

            // Display Select All/Select None buttons only if there are fields to display.
            if (fieldCount > 0 || propertyCount > 0)
            {
                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Select All", selectAllNoneButtonStyle))
                {
                    SelectAll(showFields, showProperties);
                    Generate();
                }

                if (GUILayout.Button("Select None", selectAllNoneButtonStyle))
                {
                    SelectNone(showFields, showProperties);
                    Generate();
                }
                EditorGUILayout.EndHorizontal();
            }

            for (int i = 0; i < fields.Length; i++)
            {
                var field = fields[i];
                if ((field.isProperty && !showProperties) || ((!field.isProperty) && !showFields))
                {
                    continue;
                }

                EditorGUILayout.BeginHorizontal();

                var content = new GUIContent(field.Name);

                if (typeof(UnityEngine.Object).IsAssignableFrom(field.MemberType))
                {
                    content.tooltip = field.MemberType.ToString() + "\nSaved by reference";
                }
                else
                {
                    content.tooltip = field.MemberType.ToString() + "\nSaved by value";
                }



                bool selected = EditorGUILayout.ToggleLeft(content, fieldSelected[i]);
                if (selected != fieldSelected[i])
                {
                    fieldSelected[i] = selected;
                    unsavedChanges   = true;
                }

                EditorGUILayout.EndHorizontal();
            }
        }
	void DrawLoadSaveBrushSection(tk2dTileMapEditorBrush activeBrush)
	{
		// Brush load & save handling
		bool startedSave = false;
		bool prevGuiEnabled = GUI.enabled;
		GUILayout.BeginHorizontal();
		if (showLoadSection) GUI.enabled = false;
		if (GUILayout.Button(showSaveSection?"Cancel":"Save"))
		{
			if (showSaveSection == false) startedSave = true;
			showSaveSection = !showSaveSection;
			if (showSaveSection) showLoadSection = false;
			Repaint();
		}
		GUI.enabled = prevGuiEnabled;

		if (showSaveSection) GUI.enabled = false;
		if (GUILayout.Button(showLoadSection?"Cancel":"Load"))
		{
			showLoadSection = !showLoadSection;
			if (showLoadSection) showSaveSection = false;
		}
		GUI.enabled = prevGuiEnabled;
		GUILayout.EndHorizontal();

		if (showSaveSection)
		{
			GUI.SetNextControlName("BrushNameEntry");
			activeBrush.name = EditorGUILayout.TextField("Name", activeBrush.name);
			if (startedSave)
				GUI.FocusControl("BrushNameEntry");

			if (GUILayout.Button("Save"))
			{
				if (activeBrush.name.Length == 0)
				{
					Debug.LogError("Active brush needs a name");
				}
				else
				{
					bool replaced = false;
					for (int i = 0; i < editorData.brushes.Count; ++i)
					{
						if (editorData.brushes[i].name == activeBrush.name)
						{
							editorData.brushes[i] = new tk2dTileMapEditorBrush(activeBrush);
							replaced = true;
						}
					}
					if (!replaced)
						editorData.brushes.Add(new tk2dTileMapEditorBrush(activeBrush));
					showSaveSection = false;
				}
			}
		}

		if (showLoadSection)
		{
			GUILayout.Space(8);

			if (editorData.brushes.Count == 0)
				GUILayout.Label("No saved brushes.");

			GUILayout.BeginVertical();
			int deleteBrushId = -1;
			for (int i = 0; i < editorData.brushes.Count; ++i)
			{
				var v = editorData.brushes[i];
				GUILayout.BeginHorizontal();
				if (GUILayout.Button(v.name, EditorStyles.miniButton))
				{
					showLoadSection = false;
					editorData.activeBrush = new tk2dTileMapEditorBrush(v);
				}
				if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(16)))
				{
					deleteBrushId = i;
				}
				GUILayout.EndHorizontal();
			}
			if (deleteBrushId != -1)
			{
				editorData.brushes.RemoveAt(deleteBrushId);
				Repaint();
			}
			GUILayout.EndVertical();
		}
	}
Beispiel #29
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        ToyxManager toyxManager = (ToyxManager)target;

        // Create session button
        if (GUILayout.Button("Create Session"))
        {
            toyxManager.CreateSession(null);
        }

        // Fetch if needed button
        if (GUILayout.Button("Fetch If Needed"))
        {
            toyxManager.FetchIfNeeded(null);
        }

        // Fetch button
        if (GUILayout.Button("Fetch"))
        {
            toyxManager.Fetch(null);
        }

        // Save button
        if (GUILayout.Button("Save"))
        {
            toyxManager.Save(null);
        }

        // SaveEventually button
        if (GUILayout.Button("Save Eventually"))
        {
            toyxManager.SaveEventually();
        }

        // Show Console button
        if (showConsole)
        {
            if (GUILayout.Button("Hide Console"))
            {
                showConsole = false;
            }
        }
        else
        {
            if (GUILayout.Button("Show Console"))
            {
                showConsole = true;
            }
        }

        // Clear console
        if (GUILayout.Button("Clear Console"))
        {
            toyxManager.infoMessage = "";
        }

        // Console
        if (showConsole && toyxManager.infoMessage != null)
        {
            GUILayout.Label(toyxManager.infoMessage);
        }
    }
    /// <summary>
    /// Draw the custom wizard.
    /// </summary>

    void OnGUI()
    {
        NGUIEditorTools.SetLabelWidth(80f);

        var atlas = NGUISettings.atlas;

        if (atlas == null)
        {
            GUILayout.Label("No Atlas selected.", "LODLevelNotifyText");
        }
        else
        {
            bool close = false;
            GUILayout.Label((atlas as Object).name + " Sprites", "LODLevelNotifyText");
            NGUIEditorTools.DrawSeparator();

            GUILayout.BeginHorizontal();
            GUILayout.Space(84f);

            string before = NGUISettings.partialSprite;
            string after  = EditorGUILayout.TextField("", before, "SearchTextField");
            if (before != after)
            {
                NGUISettings.partialSprite = after;
            }

            if (GUILayout.Button("", "SearchCancelButton", GUILayout.Width(18f)))
            {
                NGUISettings.partialSprite = "";
                GUIUtility.keyboardControl = 0;
            }
            GUILayout.Space(84f);
            GUILayout.EndHorizontal();

            var tex = atlas.texture as Texture2D;

            if (tex == null)
            {
                GUILayout.Label("The atlas doesn't have a texture to work with");
                return;
            }

            var sprites = atlas.GetListOfSprites(NGUISettings.partialSprite);

            if (sprites == null)
            {
                GUILayout.Label("No sprites found");
                return;
            }

            float size   = 80f;
            float padded = size + 10f;
#if UNITY_4_7
            int screenWidth = Screen.width;
#else
            int screenWidth = (int)EditorGUIUtility.currentViewWidth;
#endif
            int columns = Mathf.FloorToInt(screenWidth / padded);
            if (columns < 1)
            {
                columns = 1;
            }

            int  offset = 0;
            Rect rect   = new Rect(10f, 0, size, size);

            GUILayout.Space(10f);
            mPos = GUILayout.BeginScrollView(mPos);
            int rows = 1;

            while (offset < sprites.size)
            {
                GUILayout.BeginHorizontal();
                {
                    int col = 0;
                    rect.x = 10f;

                    for (; offset < sprites.size; ++offset)
                    {
                        var sprite = atlas.GetSprite(sprites.buffer[offset]);
                        if (sprite == null)
                        {
                            continue;
                        }

                        // Button comes first
                        if (GUI.Button(rect, ""))
                        {
                            if (Event.current.button == 0)
                            {
                                float delta = Time.realtimeSinceStartup - mClickTime;
                                mClickTime = Time.realtimeSinceStartup;

                                if (NGUISettings.selectedSprite != sprite.name)
                                {
                                    if (mSprite != null)
                                    {
                                        NGUIEditorTools.RegisterUndo("Atlas Selection", mSprite);
                                        mSprite.MakePixelPerfect();
                                        NGUITools.SetDirty(mSprite.gameObject);
                                    }

                                    NGUISettings.selectedSprite = sprite.name;
                                    NGUIEditorTools.RepaintSprites();
                                    if (mCallback != null)
                                    {
                                        mCallback(sprite.name);
                                    }
                                }
                                else if (delta < 0.5f)
                                {
                                    close = true;
                                }
                            }
                            else
                            {
                                NGUIContextMenu.AddItem("Edit", false, EditSprite, sprite);
                                NGUIContextMenu.AddItem("Delete", false, DeleteSprite, sprite);
                                NGUIContextMenu.Show();
                            }
                        }

                        if (Event.current.type == EventType.Repaint)
                        {
                            // On top of the button we have a checkboard grid
                            NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture);
                            Rect uv = new Rect(sprite.x, sprite.y, sprite.width, sprite.height);
                            uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);

                            // Calculate the texture's scale that's needed to display the sprite in the clipped area
                            float scaleX = rect.width / uv.width;
                            float scaleY = rect.height / uv.height;

                            // Stretch the sprite so that it will appear proper
                            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 = size * (1f - aspect) * 0.5f;
                                    clipRect.xMin += padding;
                                    clipRect.xMax -= padding;
                                }
                                else
                                {
                                    // The sprite is wider than it is taller
                                    float padding = size * (1f - 1f / aspect) * 0.5f;
                                    clipRect.yMin += padding;
                                    clipRect.yMax -= padding;
                                }
                            }

                            GUI.DrawTextureWithTexCoords(clipRect, tex, uv);

                            // Draw the selection
                            if (NGUISettings.selectedSprite == sprite.name)
                            {
                                NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f));
                            }
                        }

                        GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f);
                        GUI.contentColor    = new Color(1f, 1f, 1f, 0.7f);
                        GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, 32f), sprite.name, "ProgressBarBack");
                        GUI.contentColor    = Color.white;
                        GUI.backgroundColor = Color.white;

                        if (++col >= columns)
                        {
                            ++offset;
                            break;
                        }
                        rect.x += padded;
                    }
                }
                GUILayout.EndHorizontal();
                GUILayout.Space(padded);
                rect.y += padded + 26;
                ++rows;
            }
            GUILayout.Space(rows * 26);
            GUILayout.EndScrollView();

            if (close)
            {
                Close();
            }
        }
    }