Пример #1
0
        /// <summary>Shows a window that displays the recorded logs.</summary>
        /// <param name="windowID">Window ID.</param>
        void MakeConsoleWindow(int windowID)
        {
            // Only logs snapshot when it's safe to change GUI leayout.
            if (guiActions.ExecutePendingGuiActions())
            {
                UpdateLogsView(forceUpdate: logUpdateIsPaused);
            }

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            var logRecordStyle = new GUIStyle(GUI.skin.box)
            {
                alignment = TextAnchor.MiddleLeft,
            };
            var minSizeLayout = GUILayout.ExpandWidth(false);

            // Report if log interceptor is not handling logs.
            if (!LogInterceptor.isStarted)
            {
                GUI.contentColor = GetLogTypeColor(LogType.Error);
                GUILayout.Box("KSPDev is not handling system logs. Open standard in-game debug console to see"
                              + " the current logs", logRecordStyle);
            }

            foreach (var log in logsToShow.Where(LogLevelFilter))
            {
                var recordMsg = log.MakeTitle()
                                + (selectedLogRecordId == log.srcLog.id ? ":\n" + log.srcLog.stackTrace : "");
                GUI.contentColor = GetLogTypeColor(log.srcLog.type);
                GUILayout.Box(recordMsg, logRecordStyle);

                // Check if log record is selected.
                if (Event.current.type == EventType.MouseDown)
                {
                    Rect logBoxRect = GUILayoutUtility.GetLastRect();
                    if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
                    {
                        // Toggle selection.
                        var newSelectedId = selectedLogRecordId == log.srcLog.id ? -1 : log.srcLog.id;
                        guiActions.Add(() => GuiActionSelectLog(newSelectedId));
                    }
                }

                // Add source and filter controls when expanded.
                if (selectedLogRecordId == log.srcLog.id && log.srcLog.source.Any())
                {
                    GUI.contentColor = Color.white;
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Silence: source", minSizeLayout);
                    if (GUILayout.Button(log.srcLog.source, minSizeLayout))
                    {
                        guiActions.Add(() => GuiActionAddSilence(log.srcLog.source, isPrefix: false));
                    }
                    var sourceParts = log.srcLog.source.Split('.');
                    if (sourceParts.Length > 1)
                    {
                        GUILayout.Label("or by prefix", minSizeLayout);
                        for (var i = sourceParts.Length - 1; i > 0; --i)
                        {
                            var prefix = String.Join(".", sourceParts.Take(i).ToArray()) + '.';
                            if (GUILayout.Button(prefix, minSizeLayout))
                            {
                                guiActions.Add(() => GuiActionAddSilence(prefix, isPrefix: true));
                            }
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            GUILayout.EndScrollView();

            GUI.contentColor = Color.white;

            // Bottom menu.
            GUILayout.BeginHorizontal();

            // Clear logs in the current aggregator.
            if (GUILayout.Button(new GUIContent("Clear")))
            {
                guiActions.Add(GuiActionClearLogs);
            }

            // Log mode selection.
            GUI.changed = false;
            var showMode = GUILayout.SelectionGrid(
                (int)logShowMode, logShowingModes, logShowingModes.Length, GUILayout.ExpandWidth(false));

            logsViewChanged |= GUI.changed;
            if (GUI.changed)
            {
                guiActions.Add(() => GuiActionSetMode(mode: (ShowMode)showMode));
            }

            GUI.changed       = false;
            logUpdateIsPaused = GUILayout.Toggle(logUpdateIsPaused, "PAUSED", GUILayout.ExpandWidth(false));
            if (GUI.changed)
            {
                guiActions.Add(() => GuiActionSetPaused(isPaused: logUpdateIsPaused));
            }

            // Draw logs filter by level and refresh logs when filter changes.
            GUI.changed   = false;
            showInfo      = MakeFormattedToggle(showInfo, infoLogColor, "INFO ({0})", infoLogs);
            showWarning   = MakeFormattedToggle(showWarning, warningLogColor, "WARNING ({0})", warningLogs);
            showError     = MakeFormattedToggle(showError, errorLogColor, "ERROR ({0})", errorLogs);
            showException =
                MakeFormattedToggle(showException, exceptionLogColor, "EXCEPTION ({0})", exceptionLogs);
            logsViewChanged |= GUI.changed;
            GUILayout.EndHorizontal();

            // Allow the window to be dragged by its title bar.
            GUI.DragWindow(titleBarRect);
        }
 private void DrawSeperator()
 {
     GUILayout.Space(5);
     GUILayout.Box("", EditStyles.Border1, GUILayout.Height(1));
     GUILayout.Space(2);
 }
    private void OnGUI()
    {
        GUILayout.Label("Select character to edit");
        selectedCharacter = EditorGUILayout.Popup(selectedCharacter, existingCharacterList.ToArray());
        var currentCharacter = characterDataList[selectedCharacter];

        if (previousCharacterSelection != selectedCharacter)
        {
            if (currentCharacter.JsonAiData == null)
            {
                currentCharacter.JsonAiData = string.Empty;
            }
            currentAi = JsonConvert.DeserializeObject <AiData>(currentCharacter.JsonAiData);
            if (currentAi == null)
            {
                currentAi = new AiData();
            }
            if (currentAi.aiData == null)
            {
                currentAi.aiData = new List <CharacterAI>();
            }
            previousCharacterSelection = selectedCharacter;
        }

        if (currentAi.aiData.Count <= 0)
        {
            GUILayout.Label("Data is empty");
        }
        else
        {
            int index = 0;
            foreach (var ai in currentAi.aiData)
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Box(index.ToString());
                    GUILayout.Label("Target");
                    ai.Target = (AiTarget)EditorGUILayout.EnumPopup(ai.Target, GUILayout.Width(80f));
                    GUILayout.Label("Condition");
                    ai.ConditionToCheck = (Condition)EditorGUILayout.EnumPopup(ai.ConditionToCheck, GUILayout.Width(80f));
                    GUILayout.Label("Value1");
                    ai.ConditionValue1 = EditorGUILayout.IntField(ai.ConditionValue1, GUILayout.Width(100f));
                    GUILayout.Label("Value2");
                    ai.ConditionValue2 = EditorGUILayout.IntField(ai.ConditionValue2, GUILayout.Width(100f));
                    GUILayout.Label("Behavior");
                    ai.Behavior = (Behavior)EditorGUILayout.EnumPopup(ai.Behavior, GUILayout.Width(80f));
                    GUILayout.Label("BehaviorValue");
                    if (ai.Behavior == Behavior.UseSkill)
                    {
                        var popupList = currentCharacter.Skills.ToArray();
                        ai.BehaviorValue = EditorGUILayout.Popup(ai.BehaviorValue, popupList);
                    }
                    else
                    {
                        ai.BehaviorValue = EditorGUILayout.IntField(ai.BehaviorValue, GUILayout.Width(100f));
                    }
                }
                GUILayout.EndHorizontal();
                ++index;
            }
        }

        if (GUILayout.Button("+", GUILayout.Width(50f), GUILayout.Height(20f)))
        {
            CharacterAI newAi = new CharacterAI();
            currentAi.aiData.Add(newAi);
        }

        if (GUILayout.Button("Save", GUILayout.Width(200f), GUILayout.Height(40f)))
        {
            currentCharacter.JsonAiData = JsonConvert.SerializeObject(currentAi);
        }

        if (GUILayout.Button("Coroutine"))
        {
            EditorCoroutineUtility.StartCoroutine(CoroutineTest(), this);
        }
    }
Пример #4
0
    private void OnPreview(GPUSkinGenerator gen)
    {
        BeginBox();
        {
            if (GUILayout.Button("Preview And Edit"))
            {
                animData        = gen.animData;
                mesh            = gen.savedMesh;
                previewMaterial = gen.previewMaterial;

                if (animData == null || mesh == null || previewMaterial == null)
                {
                    EditorUtility.DisplayDialog("GPUSkin", "Missing Preview Resources", "OK");
                }
                else
                {
                    if (previewRenderTexture == null && !EditorApplication.isPlaying)
                    {
                        previewRenderTexture           = new RenderTexture(1024, 1024, 32, RenderTextureFormat.Default, RenderTextureReadWrite.Default);
                        previewRenderTexture.hideFlags = HideFlags.HideAndDontSave;

                        GameObject cameroGo = new GameObject("GPUSkinEditorCameraGo");
                        cameroGo.hideFlags               = HideFlags.HideAndDontSave;
                        previewCamera                    = cameroGo.AddComponent <Camera>();
                        previewCamera.hideFlags          = HideFlags.HideAndDontSave;
                        previewCamera.farClipPlane       = 100;
                        previewCamera.targetTexture      = previewRenderTexture;
                        previewCamera.enabled            = false;
                        previewCamera.clearFlags         = CameraClearFlags.SolidColor;
                        previewCamera.backgroundColor    = new Color(0.2f, 0.2f, 0.2f, 1.0f);
                        previewCamera.transform.position = new Vector3(999, 1002, 999);

                        GameObject previewGo = new GameObject("GPUSkinEditorPreviewGo");
                        previewGo.hideFlags          = HideFlags.HideAndDontSave;
                        previewGo.transform.position = new Vector3(999, 999, 1002);
                        previewAnimation             = previewGo.AddComponent <GPUSkinAnimation>();
                        previewAnimation.hideFlags   = HideFlags.HideAndDontSave;
                        previewAnimation.Init(animData, mesh, previewMaterial);
                        previewAnimation.CullingMode = GPUSkinCullingMode.AlwaysAnimate;
                    }
                }
            }

            GetLastGUIRect(ref previewEditBtnRect);

            if (previewRenderTexture != null)
            {
                int previewRectSize = Mathf.Min((int)(previewEditBtnRect.width * 0.98f), 512);
                EditorGUILayout.BeginHorizontal();
                {
                    EditorGUILayout.BeginVertical();
                    {
                        GUILayout.Box(previewRenderTexture, GUILayout.Width(previewRectSize), GUILayout.Height(previewRectSize));


                        GetLastGUIRect(ref previewInteractionRect);
                        PreviewInteraction(previewInteractionRect);

                        EditorGUILayout.HelpBox("Drag to Orbit\nCtrl + Drag to Pitch\nAlt+ Drag to Zoom\nPress P Key to Pause", MessageType.None);
                    }
                    EditorGUILayout.EndVertical();

                    //EditorGUI.ProgressBar(new Rect(previewInteractionRect.x, previewInteractionRect.y + previewInteractionRect.height, previewInteractionRect.width, 5), previewAnimation.NormalizedTime, string.Empty);
                }
                EditorGUILayout.EndHorizontal();
            }
        }
        EndBox();

        serializedObject.ApplyModifiedProperties();
    }
Пример #5
0
    void OnGUI()
    {
        if (overlay == null)
        {
            return;
        }

        var texture = overlay.texture as RenderTexture;

        var prevActive = RenderTexture.active;

        RenderTexture.active = texture;

        if (Event.current.type == EventType.Repaint)
        {
            GL.Clear(false, true, Color.clear);
        }

        var area = new Rect(0, 0, texture.width, texture.height);

        // Account for screen smaller than texture (since mouse position gets clamped)
        if (Screen.width < texture.width)
        {
            area.width         = Screen.width;
            overlay.uvOffset.x = -(float)(texture.width - Screen.width) / (2 * texture.width);
        }
        if (Screen.height < texture.height)
        {
            area.height        = Screen.height;
            overlay.uvOffset.y = (float)(texture.height - Screen.height) / (2 * texture.height);
        }

        GUILayout.BeginArea(area);

        if (background != null)
        {
            GUI.DrawTexture(new Rect(
                                (area.width - background.width) / 2,
                                (area.height - background.height) / 2,
                                background.width, background.height), background);
        }

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.BeginVertical();

        if (logo != null)
        {
            GUILayout.Space(area.height / 2 - logoHeight);
            GUILayout.Box(logo);
        }

        GUILayout.Space(menuOffset);

        bool bHideMenu = GUILayout.Button("[Esc] - Close menu");

        GUILayout.BeginHorizontal();
        GUILayout.Label(string.Format("Scale: {0:N4}", scale));
        {
            var result = GUILayout.HorizontalSlider(scale, scaleLimits.x, scaleLimits.y);
            if (result != scale)
            {
                SetScale(result);
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label(string.Format("Scale limits:"));
        {
            var result = GUILayout.TextField(scaleLimitX);
            if (result != scaleLimitX)
            {
                if (float.TryParse(result, out scaleLimits.x))
                {
                    scaleLimitX = result;
                }
            }
        }
        {
            var result = GUILayout.TextField(scaleLimitY);
            if (result != scaleLimitY)
            {
                if (float.TryParse(result, out scaleLimits.y))
                {
                    scaleLimitY = result;
                }
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        GUILayout.Label(string.Format("Scale rate:"));
        {
            var result = GUILayout.TextField(scaleRateText);
            if (result != scaleRateText)
            {
                if (float.TryParse(result, out scaleRate))
                {
                    scaleRateText = result;
                }
            }
        }
        GUILayout.EndHorizontal();

        if (SteamVR.active)
        {
            var vr = SteamVR.instance;

            GUILayout.BeginHorizontal();
            {
                var t   = SteamVR_Camera.sceneResolutionScale;
                int w   = (int)(vr.sceneWidth * t);
                int h   = (int)(vr.sceneHeight * t);
                int pct = (int)(100.0f * t);
                GUILayout.Label(string.Format("Scene quality: {0}x{1} ({2}%)", w, h, pct));
                var result = Mathf.RoundToInt(GUILayout.HorizontalSlider(pct, 50, 200));
                if (result != pct)
                {
                    SteamVR_Camera.sceneResolutionScale = (float)result / 100.0f;
                }
            }
            GUILayout.EndHorizontal();
        }

        overlay.highquality = GUILayout.Toggle(overlay.highquality, "High quality");

        if (overlay.highquality)
        {
            overlay.curved    = GUILayout.Toggle(overlay.curved, "Curved overlay");
            overlay.antialias = GUILayout.Toggle(overlay.antialias, "Overlay RGSS(2x2)");
        }
        else
        {
            overlay.curved    = false;
            overlay.antialias = false;
        }

        var tracker = SteamVR_Render.Top();

        if (tracker != null)
        {
            tracker.wireframe = GUILayout.Toggle(tracker.wireframe, "Wireframe");

            var render = SteamVR_Render.instance;
            if (render.trackingSpace == ETrackingUniverseOrigin.TrackingUniverseSeated)
            {
                if (GUILayout.Button("Switch to Standing"))
                {
                    render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseStanding;
                }
                if (GUILayout.Button("Center View"))
                {
                    var system = OpenVR.System;
                    if (system != null)
                    {
                        system.ResetSeatedZeroPose();
                    }
                }
            }
            else
            {
                if (GUILayout.Button("Switch to Seated"))
                {
                    render.trackingSpace = ETrackingUniverseOrigin.TrackingUniverseSeated;
                }
            }
        }

#if !UNITY_EDITOR
        if (GUILayout.Button("Exit"))
        {
            Application.Quit();
        }
#endif
        GUILayout.Space(menuOffset);

        var env = System.Environment.GetEnvironmentVariable("VR_OVERRIDE");
        if (env != null)
        {
            GUILayout.Label("VR_OVERRIDE=" + env);
        }

        GUILayout.Label("Graphics device: " + SystemInfo.graphicsDeviceVersion);

        GUILayout.EndVertical();
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.EndArea();

        if (cursor != null)
        {
            float x = Input.mousePosition.x, y = Screen.height - Input.mousePosition.y;
            float w = cursor.width, h = cursor.height;
            GUI.DrawTexture(new Rect(x, y, w, h), cursor);
        }

        RenderTexture.active = prevActive;

        if (bHideMenu)
        {
            HideMenu();
        }
    }
        /// <summary>Shows a window that displays the winch controls.</summary>
        /// <param name="windowId">Window ID.</param>
        void ConsoleWindowFunc(int windowId)
        {
            if (guiActions.ExecutePendingGuiActions())
            {
                if (parentPartTracking && Input.GetMouseButtonDown(0) &&
                    !windowRect.Contains(Mouse.screenPos))
                {
                    SetPart(Mouse.HoveredPart);
                    parentPartTracking = false;
                }
            }

            string parentPartName = parentPart != null?DbgFormatter.PartId(parentPart) : "NONE";

            if (!lockToPart)
            {
                if (GUILayout.Button(!parentPartTracking ? "Set part" : "Cancel set mode..."))
                {
                    guiActions.Add(() => { parentPartTracking = !parentPartTracking; });
                }
                if (parentPartTracking && Mouse.HoveredPart != null)
                {
                    parentPartName = "Select: " + DbgFormatter.PartId(Mouse.HoveredPart);
                }
                GUILayout.Label(parentPartName, new GUIStyle(GUI.skin.box)
                {
                    wordWrap = true
                });
            }

            // Render the adjustable fields.
            if (parentPart != null && adjustableModules != null)
            {
                if (adjustableModules.Length > 0)
                {
                    mainScrollView.BeginView(GUI.skin.box, Screen.height - 200);
                    for (var i = 0; i < adjustableModules.Length; i++)
                    {
                        var isSelected    = selectedModule == i;
                        var module        = adjustableModules[i];
                        var toggleCaption = (isSelected ? "\u25b2 " : "\u25bc ") + "Module: " + module.Key;
                        if (GUILayout.Button(toggleCaption))
                        {
                            var selectedModuleSnapshot = selectedModule == i ? -1 : i; // Make a copy for lambda!
                            guiActions.Add(() => selectedModule = selectedModuleSnapshot);
                        }
                        if (isSelected)
                        {
                            foreach (var control in module.Value)
                            {
                                control.RenderControl(
                                    guiActions, GUI.skin.label, new[] { GUILayout.Width(dialogValueSize) });
                            }
                        }
                    }
                    mainScrollView.EndView();
                }
                else
                {
                    GUILayout.Box("No adjustable members found");
                }
            }

            if (GUILayout.Button("Close", GUILayout.ExpandWidth(false)))
            {
                guiActions.Add(() => DebugGui.DestroyPartDebugDialog(this));
            }

            // Allow the window to be dragged by its title bar.
            GuiWindow.DragWindow(ref windowRect, titleBarRect);
        }
Пример #7
0
        public override void OnInspectorGUI()
        {
            var proCamera2D = (ProCamera2D)target;

            serializedObject.Update();


            EditorGUILayout.Space();

            // Draw User Guide link
            if (ProCamera2DEditorResources.UserGuideIcon != null)
            {
                var rect = GUILayoutUtility.GetRect(0f, 0f);
                rect.width  = ProCamera2DEditorResources.UserGuideIcon.width;
                rect.height = ProCamera2DEditorResources.UserGuideIcon.height;
                if (GUI.Button(new Rect(15, rect.y, 32, 32), new GUIContent(ProCamera2DEditorResources.UserGuideIcon, "User Guide")))
                {
                    Application.OpenURL("http://www.procamera2d.com/user-guide/");
                }
            }

            // Draw header
            if (ProCamera2DEditorResources.InspectorHeader != null)
            {
                var rect = GUILayoutUtility.GetRect(0f, 0f);
                rect.x     += 37;
                rect.width  = ProCamera2DEditorResources.InspectorHeader.width;
                rect.height = ProCamera2DEditorResources.InspectorHeader.height;
                GUILayout.Space(rect.height);
                GUI.DrawTexture(rect, ProCamera2DEditorResources.InspectorHeader);
            }

            EditorGUILayout.Space();


            // Review prompt
            if (_showReviewMessage)
            {
                EditorGUILayout.HelpBox("Sorry for the intrusion, but I need you for a second. Reviews on the Asset Store are very important for me to keep improving this product. Please take a minute to write a review and support ProCamera2D.", MessageType.Warning, true);
                EditorGUILayout.BeginHorizontal();
                if (GUILayout.Button("Sure, I'll write a review!"))
                {
                    _showReviewMessage = false;
                    EditorPrefs.SetInt("ProCamera2DReview", -1);
                    Application.OpenURL("http://u3d.as/i7L");
                }
                if (GUILayout.Button("No, thanks."))
                {
                    _showReviewMessage = false;
                    EditorPrefs.SetInt("ProCamera2DReview", -1);
                }
                EditorGUILayout.EndHorizontal();
                AddSpace();
            }


            // Assign game camera
            if (proCamera2D.GameCamera == null)
            {
                proCamera2D.GameCamera = proCamera2D.GetComponent <Camera>();
            }


            // Targets Drop Area
            Event evt       = Event.current;
            Rect  drop_area = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
            var   style     = new GUIStyle("box");

            if (EditorGUIUtility.isProSkin)
            {
                style.normal.textColor = Color.white;
            }
            GUI.Box(drop_area, "\nDROP CAMERA TARGETS HERE", style);

            switch (evt.type)
            {
            case EventType.DragUpdated:
            case EventType.DragPerform:
                if (!drop_area.Contains(evt.mousePosition))
                {
                    return;
                }

                DragAndDrop.visualMode = DragAndDropVisualMode.Copy;

                if (evt.type == EventType.DragPerform)
                {
                    DragAndDrop.AcceptDrag();

                    foreach (Object dragged_object in DragAndDrop.objectReferences)
                    {
                        var newCameraTarget = new CameraTarget
                        {
                            TargetTransform = ((GameObject)dragged_object).transform,
                            TargetInfluence = 1f
                        };

                        proCamera2D.CameraTargets.Add(newCameraTarget);
                        EditorUtility.SetDirty(proCamera2D);
                    }
                }
                break;
            }

            EditorGUILayout.Space();



            // Remove empty targets
            for (int i = 0; i < proCamera2D.CameraTargets.Count; i++)
            {
                if (proCamera2D.CameraTargets[i].TargetTransform == null)
                {
                    proCamera2D.CameraTargets.RemoveAt(i);
                }
            }



            // Targets List
            _targetsList.DoLayoutList();
            AddSpace();



            // Center target on start
            _tooltip = new GUIContent("Center target on start", "Should the camera move instantly to the target on game start?");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("CenterTargetOnStart"), _tooltip);

            AddSpace();



            // Axis
            _tooltip = new GUIContent("Axis", "Choose the axis in which the camera should move.");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("Axis"), _tooltip);

            AddSpace();



            // UpdateType
            _tooltip = new GUIContent("Update Type", "LateUpdate: Non physics based game\nFixedUpdate: Physics based game");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("UpdateType"), _tooltip);

            AddSpace();



            // Show correct axis name
            switch (proCamera2D.Axis)
            {
            case MovementAxis.XY:
                hAxis = "X";
                vAxis = "Y";
                break;

            case MovementAxis.XZ:
                hAxis = "X";
                vAxis = "Z";
                break;

            case MovementAxis.YZ:
                hAxis = "Y";
                vAxis = "Z";
                break;
            }



            // Follow horizontal
            EditorGUILayout.BeginHorizontal();
            _tooltip = new GUIContent("Follow " + hAxis, "Should the camera move on the horizontal axis?");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("FollowHorizontal"), _tooltip);
            if (proCamera2D.FollowHorizontal)
            {
                // Follow smoothness
                _tooltip = new GUIContent("Smoothness", "How long it takes the camera to reach the target horizontal position.");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("HorizontalFollowSmoothness"), _tooltip);

                if (proCamera2D.HorizontalFollowSmoothness < 0f)
                {
                    proCamera2D.HorizontalFollowSmoothness = 0f;
                }
            }
            EditorGUILayout.EndHorizontal();


            // Follow vertical
            EditorGUILayout.BeginHorizontal();
            _tooltip = new GUIContent("Follow " + vAxis, "Should the camera move on the vertical axis?");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("FollowVertical"), _tooltip);

            if (proCamera2D.FollowVertical)
            {
                // Follow smoothness
                _tooltip = new GUIContent("Smoothness", "How long it takes the camera to reach the target vertical position.");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("VerticalFollowSmoothness"), _tooltip);

                if (proCamera2D.VerticalFollowSmoothness < 0f)
                {
                    proCamera2D.VerticalFollowSmoothness = 0f;
                }
            }
            EditorGUILayout.EndHorizontal();

            if (!proCamera2D.FollowHorizontal && !proCamera2D.FollowVertical)
            {
                EditorGUILayout.HelpBox("Camera won't move if it's not following the targets on any axis.", MessageType.Error, true);
            }

            AddSpace();



            // Overall offset
            EditorGUILayout.LabelField("Offset");
            EditorGUI.indentLevel = 1;

            _tooltip = new GUIContent(hAxis, "Horizontal offset");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("OverallOffset.x"), _tooltip);

            _tooltip = new GUIContent(vAxis, "Vertical offset");
            EditorGUILayout.PropertyField(serializedObject.FindProperty("OverallOffset.y"), _tooltip);

            EditorGUI.indentLevel = 0;

            AddSpace();



            // Zoom with FOV
            if (!proCamera2D.GameCamera.orthographic)
            {
                GUI.enabled = !Application.isPlaying;
                _tooltip    = new GUIContent("Zoom With FOV", "If enabled, when using a perspective camera, the camera will zoom by changing the FOV instead of moving the camera closer/further from the objects.");
                EditorGUILayout.PropertyField(serializedObject.FindProperty("ZoomWithFOV"), _tooltip);
                GUI.enabled = true;
                AddSpace();
            }



            // Divider
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            GUILayout.Label("EXTENSIONS", EditorStyles.boldLabel);



            // Extensions
            for (int i = 0; i < _extensions.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(_extensions[i].ExtName);
                if (_extensions[i].Component == null)
                {
                    GUI.color = Color.green;
                    if (GUILayout.Button("Enable"))
                    {
                        _extensions[i].Component             = proCamera2D.gameObject.AddComponent(_extensions[i].ExtType) as BasePC2D;
                        _extensions[i].Component.ProCamera2D = proCamera2D;
                    }
                }
                else
                {
                    GUI.color = Color.red;
                    if (GUILayout.Button("Disable"))
                    {
                        if (EditorUtility.DisplayDialog("Warning!", "Are you sure you want to remove this plugin?", "Yes", "No"))
                        {
                            DestroyImmediate(_extensions[i].Component);
                            EditorGUIUtility.ExitGUI();
                        }
                    }
                }
                GUI.color = Color.white;
                EditorGUILayout.EndHorizontal();
            }



            // Divider
            EditorGUILayout.Space();
            GUI.color = Color.white;
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            GUILayout.Label("TRIGGERS", EditorStyles.boldLabel);



            // Triggers
            for (int i = 0; i < _triggers.Count; i++)
            {
                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(_triggers[i].TriggerName + " (" + _triggers[i].AllTriggers.Count() + ")");

                if (GUILayout.Button("Add"))
                {
                    var newGo = new GameObject(_triggers[i].TriggerType.Name);
                    newGo.transform.localScale = new Vector3(5, 5, 5);
                    var trigger = newGo.AddComponent(_triggers[i].TriggerType) as BasePC2D;
                    trigger.ProCamera2D = proCamera2D;
                    _triggers[i].AllTriggers.Add(trigger);
                }

                GUI.enabled = _triggers[i].AllTriggers.Count() > 0;

                if (GUILayout.Button(">"))
                {
                    Selection.activeGameObject = ((BasePC2D)_triggers[i].AllTriggers[_triggers[i].TriggerCurrentIndex]).gameObject;
                    SceneView.FrameLastActiveSceneView();
                    EditorGUIUtility.PingObject(((BasePC2D)_triggers[i].AllTriggers[_triggers[i].TriggerCurrentIndex]).gameObject);

                    Selection.activeGameObject = proCamera2D.gameObject;

                    _triggers[i].TriggerCurrentIndex = _triggers[i].TriggerCurrentIndex >= _triggers[i].AllTriggers.Count - 1 ? 0 : _triggers[i].TriggerCurrentIndex + 1;
                }

                GUI.enabled = true;

                EditorGUILayout.EndHorizontal();
            }

            AddSpace();


            serializedObject.ApplyModifiedProperties();
        }
Пример #8
0
        void DrawChannelGUI()
        {
            EditorGUILayout.Separator();
            GUI.skin.box.normal.textColor = Color.white;
            if (DrawRollup("Vertex Painter"))
            {
                bool oldEnabled = enabled;
                if (Event.current.isKey && Event.current.keyCode == KeyCode.Escape && Event.current.type == EventType.KeyUp)
                {
                    enabled = !enabled;
                }
                enabled = GUILayout.Toggle(enabled, "Active (ESC)");
                if (enabled != oldEnabled)
                {
                    InitMeshes();
                    UpdateDisplayMode();
                }
                var oldShow = showVertexShader;
                EditorGUILayout.BeginHorizontal();
                showVertexShader = GUILayout.Toggle(showVertexShader, "Show Vertex Data (ctrl-V)");
                if (oldShow != showVertexShader)
                {
                    UpdateDisplayMode();
                }
                bool emptyStreams = false;
                for (int i = 0; i < jobs.Length; ++i)
                {
                    if (!jobs[i].HasStream())
                    {
                        emptyStreams = true;
                    }
                }
                if (emptyStreams)
                {
                    if (GUILayout.Button("Add Streams"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            jobs[i].EnforceStream();
                        }
                        UpdateDisplayMode();
                    }
                }
                EditorGUILayout.EndHorizontal();

                brushVisualization = (BrushVisualization)EditorGUILayout.EnumPopup("Brush Visualization", brushVisualization);

                showVertexPoints = GUILayout.Toggle(showVertexPoints, "Show Brush Influence");

                bool oldHideMeshWireframe = hideMeshWireframe;
                hideMeshWireframe = !GUILayout.Toggle(!hideMeshWireframe, "Show Wireframe (ctrl-W)");

                if (hideMeshWireframe != oldHideMeshWireframe)
                {
                    for (int i = 0; i < jobs.Length; ++i)
                    {
                        EditorUtility.SetSelectedWireframeHidden(jobs[i].renderer, hideMeshWireframe);
                    }
                }

                multMouse2X = GUILayout.Toggle(multMouse2X, "2X mouse position");
                bool hasColors    = false;
                bool hasUV0       = false;
                bool hasUV1       = false;
                bool hasUV2       = false;
                bool hasUV3       = false;
                bool hasPositions = false;
                bool hasNormals   = false;
                bool hasStream    = false;
                for (int i = 0; i < jobs.Length; ++i)
                {
                    var stream = jobs[i]._stream;
                    if (stream != null)
                    {
                        int vertexCount = jobs[i].verts.Length;
                        hasStream    = true;
                        hasColors    = (stream.colors != null && stream.colors.Length == vertexCount);
                        hasUV0       = (stream.uv0 != null && stream.uv0.Count == vertexCount);
                        hasUV1       = (stream.uv1 != null && stream.uv1.Count == vertexCount);
                        hasUV2       = (stream.uv2 != null && stream.uv2.Count == vertexCount);
                        hasUV3       = (stream.uv3 != null && stream.uv3.Count == vertexCount);
                        hasPositions = (stream.positions != null && stream.positions.Length == vertexCount);
                        hasNormals   = (stream.normals != null && stream.normals.Length == vertexCount);
                    }
                }

                if (hasStream && (hasColors || hasUV0 || hasUV1 || hasUV2 || hasUV3 || hasPositions || hasNormals))
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.PrefixLabel("Clear Channel:");
                    if (hasColors && DrawClearButton("Colors"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            var stream = jobs[i].stream;
                            stream.colors = null;
                            stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    if (hasUV0 && DrawClearButton("UV0"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            var stream = jobs[i].stream;
                            stream.uv0 = null;
                            stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    if (hasUV1 && DrawClearButton("UV1"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            var stream = jobs[i].stream;
                            stream.uv1 = null;
                            stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    if (hasUV2 && DrawClearButton("UV2"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            var stream = jobs[i].stream;
                            stream.uv2 = null;
                            stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    if (hasUV3 && DrawClearButton("UV3"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            var stream = jobs[i].stream;
                            stream.uv3 = null;
                            stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    if (hasPositions && DrawClearButton("Pos"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            jobs[i].stream.positions = null;
                            Mesh m = jobs[i].stream.GetModifierMesh();
                            if (m != null)
                            {
                                m.vertices = jobs[i].meshFilter.sharedMesh.vertices;
                            }
                            jobs[i].stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }
                    if (hasNormals && DrawClearButton("Norm"))
                    {
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            Undo.RecordObject(jobs[i].stream, "Vertex Painter Clear");
                            jobs[i].stream.normals  = null;
                            jobs[i].stream.tangents = null;
                            jobs[i].stream.Apply();
                        }
                        Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
                    }

                    EditorGUILayout.EndHorizontal();
                }
                else if (hasStream)
                {
                    if (GUILayout.Button("Remove Unused Stream Components"))
                    {
                        RevertMat();
                        for (int i = 0; i < jobs.Length; ++i)
                        {
                            if (jobs[i].HasStream())
                            {
                                DestroyImmediate(jobs[i].stream);
                            }
                        }
                        UpdateDisplayMode();
                    }
                }
            }
            EditorGUILayout.Separator();
            GUILayout.Box("", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1) });
            EditorGUILayout.Separator();
        }
Пример #9
0
        void DrawPaintGUI()
        {
            GUILayout.Box("Brush Settings", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(20) });
            var oldBM = brushMode;

            brushMode = (BrushTarget)EditorGUILayout.EnumPopup("Target Channel", brushMode);
            if (oldBM != brushMode)
            {
                UpdateDisplayMode();
            }
            if (brushMode == BrushTarget.Color || brushMode == BrushTarget.UV0_AsColor || brushMode == BrushTarget.UV1_AsColor ||
                brushMode == BrushTarget.UV2_AsColor || brushMode == BrushTarget.UV3_AsColor)
            {
                brushColorMode = (BrushColorMode)EditorGUILayout.EnumPopup("Blend Mode", (System.Enum)brushColorMode);

                if (brushColorMode == BrushColorMode.Overlay || brushColorMode == BrushColorMode.Normal)
                {
                    brushColor = EditorGUILayout.ColorField("Brush Color", brushColor);

                    if (GUILayout.Button("Reset Palette", EditorStyles.miniButton, GUILayout.Width(80), GUILayout.Height(16)))
                    {
                        if (swatches != null)
                        {
                            DestroyImmediate(swatches);
                        }
                        swatches = ColorSwatches.CreateInstance <ColorSwatches>();
                        EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches, false));
                    }

                    GUILayout.BeginHorizontal();

                    for (int i = 0; i < swatches.colors.Length; ++i)
                    {
                        if (GUILayout.Button("", EditorStyles.textField, GUILayout.Width(16), GUILayout.Height(16)))
                        {
                            brushColor = swatches.colors[i];
                        }
                        EditorGUI.DrawRect(new Rect(GUILayoutUtility.GetLastRect().x + 1, GUILayoutUtility.GetLastRect().y + 1, 14, 14), swatches.colors[i]);
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.BeginHorizontal();
                    for (int i = 0; i < swatches.colors.Length; i++)
                    {
                        if (GUILayout.Button("+", EditorStyles.miniButton, GUILayout.Width(16), GUILayout.Height(12)))
                        {
                            swatches.colors[i] = brushColor;
                            EditorPrefs.SetString(sSwatchKey, JsonUtility.ToJson(swatches, false));
                        }
                    }
                    GUILayout.EndHorizontal();
                }
            }
            else if (brushMode == BrushTarget.ValueR || brushMode == BrushTarget.ValueG || brushMode == BrushTarget.ValueB || brushMode == BrushTarget.ValueA)
            {
                brushValue = (int)EditorGUILayout.Slider("Brush Value", (float)brushValue, 0.0f, 256.0f);
            }
            else
            {
                floatBrushValue = EditorGUILayout.FloatField("Brush Value", floatBrushValue);
                var oldUVRange = uvVisualizationRange;
                uvVisualizationRange = EditorGUILayout.Vector2Field("Visualize Range", uvVisualizationRange);
                if (oldUVRange != uvVisualizationRange)
                {
                    UpdateDisplayMode();
                }
            }

            DrawBrushSettingsGUI();

            //GUILayout.Box("", new GUILayoutOption[]{GUILayout.ExpandWidth(true), GUILayout.Height(1)});
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("Fill"))
            {
                for (int i = 0; i < jobs.Length; ++i)
                {
                    Undo.RecordObject(jobs[i].stream, "Vertex Painter Fill");
                    FillMesh(jobs[i]);
                }
                Undo.CollapseUndoOperations(Undo.GetCurrentGroup());
            }
            if (GUILayout.Button("Random"))
            {
                for (int i = 0; i < jobs.Length; ++i)
                {
                    Undo.RecordObject(jobs[i].stream, "Vertex Painter Fill");
                    RandomMesh(jobs[i]);
                }
            }
            EditorGUILayout.EndHorizontal();
        }
    public override void OnInspectorGUI()
    {
        serializedObject.Update();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box(logo, GUIStyle.none);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("Project Settings", EditorStyles.boldLabel);
        GUILayout.FlexibleSpace();
        EditorGUILayout.EndHorizontal();
        GUILayout.Space(20);
        EditorGUILayout.PropertyField(phonemeSet, new GUIContent("Phoneme Set"));
        GUILayout.Space(15);
        GUILayout.Box("Animation Emotions", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        Undo.RecordObject(myTarget, "Change Project Settings");

        for (int a = 0; a < myTarget.emotions.Length; a++)
        {
            Rect lineRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(25));
            if (a % 2 == 0)
            {
                GUI.Box(lineRect, "", (GUIStyle)"hostview");
            }
            GUILayout.Space(10);
            GUILayout.Box((a + 1).ToString(), EditorStyles.label);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            emotions.GetArrayElementAtIndex(a).stringValue = GUILayout.TextArea(emotions.GetArrayElementAtIndex(a).stringValue, EditorStyles.label, GUILayout.MinWidth(130));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                emotions.GetArrayElementAtIndex(a).stringValue = Validate(a, myTarget.emotions);
            }


            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Text);
            GUILayout.FlexibleSpace();
            emotionColors.GetArrayElementAtIndex(a).colorValue = EditorGUILayout.ColorField(emotionColors.GetArrayElementAtIndex(a).colorValue, GUILayout.MaxWidth(280));
            GUILayout.FlexibleSpace();
            GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
            if (GUILayout.Button("Delete", GUILayout.MaxWidth(70), GUILayout.Height(18)))
            {
                emotions.DeleteArrayElementAtIndex(a);
                emotionColors.DeleteArrayElementAtIndex(a);
                break;
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.Space(10);
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Add Emotion", GUILayout.MaxWidth(300), GUILayout.Height(25)))
        {
            emotions.arraySize++;
            emotionColors.arraySize++;

            emotions.GetArrayElementAtIndex(emotions.arraySize - 1).stringValue          = "New Emotion";
            emotionColors.GetArrayElementAtIndex(emotionColors.arraySize - 1).colorValue = Color.white;

            serializedObject.ApplyModifiedProperties();
            emotions.GetArrayElementAtIndex(emotions.arraySize - 1).stringValue = Validate(emotions.arraySize - 1, myTarget.emotions);
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(20);

        GUILayout.Box("Animation Gestures", EditorStyles.boldLabel);
        EditorGUILayout.Space();
        for (int a = 0; a < myTarget.gestures.Count; a++)
        {
            Rect lineRect = EditorGUILayout.BeginHorizontal(GUILayout.Height(25));
            if (a % 2 == 0)
            {
                GUI.Box(lineRect, "", (GUIStyle)"hostview");
            }
            GUILayout.Box((a + 1).ToString(), EditorStyles.label);
            EditorGUILayout.Space();

            EditorGUI.BeginChangeCheck();
            gestures.GetArrayElementAtIndex(a).stringValue = GUILayout.TextArea(gestures.GetArrayElementAtIndex(a).stringValue, EditorStyles.label, GUILayout.MinWidth(130));
            if (EditorGUI.EndChangeCheck())
            {
                serializedObject.ApplyModifiedProperties();
                gestures.GetArrayElementAtIndex(a).stringValue = Validate(a, myTarget.gestures.ToArray());
            }

            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Text);
            GUILayout.FlexibleSpace();
            GUI.backgroundColor = new Color(0.8f, 0.3f, 0.3f);
            if (GUILayout.Button("Delete", GUILayout.MaxWidth(70), GUILayout.Height(18)))
            {
                gestures.DeleteArrayElementAtIndex(a);
                break;
            }
            GUI.backgroundColor = Color.white;
            GUILayout.Space(10);
            EditorGUILayout.EndHorizontal();
        }

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Add Gesture", GUILayout.MaxWidth(300), GUILayout.Height(25)))
        {
            gestures.arraySize++;
            gestures.GetArrayElementAtIndex(gestures.arraySize - 1).stringValue = "New Gesture";

            serializedObject.ApplyModifiedProperties();
            gestures.GetArrayElementAtIndex(gestures.arraySize - 1).stringValue = Validate(gestures.arraySize - 1, myTarget.gestures.ToArray());
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.Space(20);

        EditorGUILayout.HelpBox("Thank you for buying LipSync Pro! If you are finding it useful, please help us out by leaving a review on the Asset Store.", MessageType.Info);

        if (GUILayout.Button("Get LipSync Extensions"))
        {
            RDExtensionWindow.ShowWindow("LipSync_Pro");
        }
        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("Asset Store"))
        {
            Application.OpenURL("http://u3d.as/cag");
        }
        if (GUILayout.Button("Forum Thread"))
        {
            Application.OpenURL("http://forum.unity3d.com/threads/released-lipsync-and-eye-controller-lipsyncing-and-facial-animation-tools.309324/");
        }
        if (GUILayout.Button("Email Support"))
        {
            Application.OpenURL("mailto:[email protected]");
        }
        if (GUILayout.Button("Documentation"))
        {
            Application.OpenURL("https://lipsync.rogodigital.com/documentation");
        }
        EditorGUILayout.EndHorizontal();
        serializedObject.ApplyModifiedProperties();
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            if (toolbars != null && toolbars.Count > 1)
            {
                GUILayout.BeginVertical(headerAttribute != null ? headerAttribute.header : target.GetType().Name, skin.window);
                GUILayout.Label(m_Logo, skin.label, GUILayout.MaxHeight(30));
                GUILayout.Space(10);
                if (headerAttribute.openClose)
                {
                    openCloseWindow = GUILayout.Toggle(openCloseWindow, openCloseWindow ? "Close Properties" : "Open Properties", EditorStyles.toolbarButton);
                }

                if (!headerAttribute.openClose || openCloseWindow)
                {
                    var titles = getToobarTitles();
                    EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
                    GUILayout.Space(10);
                    var customToolbar = skin.GetStyle("customToolbar");
                    selectedToolBar = GUILayout.SelectionGrid(selectedToolBar, titles, 3, customToolbar, GUILayout.MinWidth(250));
                    if (!(selectedToolBar < toolbars.Count))
                    {
                        selectedToolBar = 0;
                    }
                    GUILayout.Space(10);
                    GUILayout.Box(toolbars[selectedToolBar].title, skin.box, GUILayout.ExpandWidth(true));
                    var ignore           = getIgnoreProperties(toolbars[selectedToolBar]);
                    var ignoreProperties = ignore.Append(ignore_vMono);
                    DrawPropertiesExcluding(serializedObject, ignoreProperties);
                }

                GUILayout.EndVertical();
            }
            else
            {
                if (headerAttribute == null)
                {
                    if (((UBehaviour)target) != null)
                    {
                        DrawPropertiesExcluding(serializedObject, ignore_vMono);
                    }
                    else
                    {
                        base.OnInspectorGUI();
                    }
                }
                else
                {
                    GUILayout.BeginVertical(headerAttribute.header, skin.window);
                    GUILayout.Label(m_Logo, skin.label, GUILayout.MaxHeight(40));
                    GUILayout.Space(10);
                    if (headerAttribute.openClose)
                    {
                        openCloseWindow = GUILayout.Toggle(openCloseWindow, openCloseWindow ? "Close Properties" : "Open Properties", EditorStyles.toolbarButton);
                    }

                    if (!headerAttribute.openClose || openCloseWindow)
                    {
                        if (headerAttribute.useHelpBox)
                        {
                            EditorGUILayout.HelpBox(headerAttribute.helpBoxText, MessageType.Info);
                        }
                        if (ignoreEvents != null && ignoreEvents.Length > 0)
                        {
                            var ignoreProperties = ignoreEvents.Append(ignore_vMono);
                            DrawPropertiesExcluding(serializedObject, ignoreProperties);
                            openCloseEvents = GUILayout.Toggle(openCloseEvents, (openCloseEvents ? "Close " : "Open ") + "Events ", skin.button);
                            if (openCloseEvents)
                            {
                                foreach (string propName in ignoreEvents)
                                {
                                    var prop = serializedObject.FindProperty(propName);
                                    if (prop != null)
                                    {
                                        EditorGUILayout.PropertyField(prop);
                                    }
                                }
                            }
                        }
                        else
                        {
                            var ignoreProperties = ignoreEvents.Append(ignore_vMono);
                            DrawPropertiesExcluding(serializedObject, ignoreProperties);
                        }
                    }

                    EditorGUILayout.EndVertical();
                }
            }

            if (GUI.changed)
            {
                serializedObject.ApplyModifiedProperties();
                EditorUtility.SetDirty(serializedObject.targetObject);
            }
        }
Пример #12
0
        private void GrasSelectorWindow(int WindowID)
        {
            GUI.enabled = true;

            GUILayout.BeginHorizontal();
            {
                GUI.enabled = false;
                GUILayout.Button("-KK-", UIMain.DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUILayout.Button(titleText, UIMain.DeadButton, GUILayout.Height(21));

                GUILayout.FlexibleSpace();

                GUI.enabled = true;

                if (GUILayout.Button("X", UIMain.DeadButtonRed, GUILayout.Height(21)))
                {
                    this.Close();
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep.texture, UIMain.BoxNoBorder, GUILayout.Height(4));

            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Select Preset", GUILayout.Height(23), GUILayout.Width(120)))
                {
                    GrassColorPresetUI.callBack = UpdateCallBack;
                    GrassColorPresetUI.instance.Open();
                }

                GUILayout.Space(20);
                if (GUILayout.Button("Pick Surface Color", GUILayout.Height(23), GUILayout.Width(120)))
                {
                    selectedInstance.GrasColor = GrassColorUtils.GetUnderGroundColor(selectedInstance);
                    selectedInstance.Update();
                    SetupFields();
                }
                GUILayout.FlexibleSpace();
            }
            GUILayout.EndHorizontal();

            GUILayout.Space(3);
            GUI.enabled = true;
            {
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Red: ", GUILayout.Height(23));
                    GUILayout.FlexibleSpace();
                    grasColorRStr = (GUILayout.TextField(grasColorRStr, 7, GUILayout.Width(90), GUILayout.Height(23)));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Green: ", GUILayout.Height(23));
                    GUILayout.FlexibleSpace();
                    grasColorGStr = (GUILayout.TextField(grasColorGStr, 7, GUILayout.Width(90), GUILayout.Height(23)));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Blue: ", GUILayout.Height(23));
                    GUILayout.FlexibleSpace();
                    grasColorBStr = (GUILayout.TextField(grasColorBStr, 7, GUILayout.Width(90), GUILayout.Height(23)));
                }
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
                {
                    GUILayout.Label("Alpha: ", GUILayout.Height(23));
                    GUILayout.FlexibleSpace();
                    grasColorAStr = (GUILayout.TextField(grasColorAStr, 7, GUILayout.Width(80), GUILayout.Height(23)));
                }
                GUILayout.EndHorizontal();

                if (GUILayout.Button("Edit Color", GUILayout.Height(23), GUILayout.Width(120)))
                {
                    UI2.ColorSelector.selectedColor = selectedInstance.GrasColor;
                    UI2.ColorSelector.callBack      = SetColorCallBack;
                    UI2.ColorSelector.Open();
                }
            }
            GUI.enabled = true;
            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep.texture, UIMain.BoxNoBorder, GUILayout.Height(4));


            GUILayout.Label("Grass Texture: ", GUILayout.Height(23));
            grasTextureName = (GUILayout.TextField(grasTextureName, 200, GUILayout.Width(280), GUILayout.Height(23)));

            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep.texture, UIMain.BoxNoBorder, GUILayout.Height(4));
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Apply", GUILayout.Height(23), GUILayout.Width(80)))
                {
                    ApplySettings();
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(1);
            GUILayout.Box(UIMain.tHorizontalSep.texture, UIMain.BoxNoBorder, GUILayout.Height(4));
            GUILayout.BeginHorizontal();
            {
                if (GUILayout.Button("Cancel", GUILayout.Height(23)))
                {
                    this.Close();
                }
                GUILayout.FlexibleSpace();
                if (GUILayout.Button("Apply & Close", GUILayout.Height(23)))
                {
                    ApplySettings();
                    this.Close();
                }
            }
            GUILayout.EndHorizontal();

            GUI.DragWindow(new Rect(0, 0, 10000, 10000));
        }
Пример #13
0
    void OnSceneGUI()
    {
        Map map = (Map)target;

        bool canOperate = !(map.currentLevel < 0 || map.currentLevel >= map.levels.Count() || map.levels[map.currentLevel] == null);

        if (canOperate)
        {
            drawRect(map.levels[map.currentLevel], Color.yellow);
            List <int> toRect = map.levels[map.currentLevel].GetComponent <Transition>().link;
            foreach (int i in toRect)
            {
                drawRect(map.levels[i], Color.blue);
            }
        }

        GUILayout.BeginArea(new Rect(10, 10, 400, 200));

        index = EditorGUILayout.Popup(index, dropdown);
        if (prefabs != null && index > 0)
        {
            selectedPrefab = prefabs[index - 1];
        }
        else
        {
            selectedPrefab = null;
        }

        GUILayout.BeginHorizontal();
        GUILayout.Box("Map Edit Mode");

        if (selectedPrefab != null && selectedPrefab.GetComponent <Interactable>() != null)
        {
            selectedPrefab.GetComponent <Interactable>().level = map.currentLevel;
            GUILayout.Box("Level Index : " + map.currentLevel.ToString());
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        if (selectedPrefab != null && selectedPrefab.GetComponent <Rotatable>() != null)
        {
            GUILayout.Box("Degree: " + rotationDegree);
        }
        else
        {
            rotationDegree = 0;
        }
        GUILayout.EndHorizontal();

        GUILayout.EndArea();

        Vector3 spawnPosition = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition).origin;
        Vector2 gridPosition  = new Vector2(Mathf.Floor(spawnPosition.x) + 0.5f, Mathf.Floor(spawnPosition.y) + 0.5f);

        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.Z)
        {
            rotationDegree = (rotationDegree + 270) % 360;
        }

        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.C)
        {
            rotationDegree = (rotationDegree + 90) % 360;
        }

        //if LMB pressed, spawn the selected prefab
        if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && selectedPrefab != null)
        {
            RaycastHit2D hitInfo = Physics2D.Raycast(gridPosition, Vector2.zero);
            RaycastHit2D within  = Physics2D.Raycast(gridPosition, Vector2.zero, 100, (1 << 2));
            if (canOperate == false)
            {
                EditorUtility.DisplayDialog("Anomaly detected", "Invalid level index.", "Ok");
            }
            else if ((hitInfo.collider == null || (hitInfo.collider.GetComponent <Ground>() == null && hitInfo.collider.name != selectedPrefab.name)) && within.collider.gameObject == map.levels[map.currentLevel])
            {
                Spawn(gridPosition, map);
                if (selectedPrefab.GetComponent <Multisprites>() != null)
                {
                    for (int y = 1; y >= -1; y--)
                    {
                        for (int x = -1; x <= 1; x++)
                        {
                            Vector2        newpos = new Vector2(gridPosition.x + x, gridPosition.y + y);
                            RaycastHit2D[] hits   = Physics2D.RaycastAll(newpos, Vector2.zero);
                            foreach (RaycastHit2D hit in hits)
                            {
                                if (hit.collider != null && hit.collider.gameObject.GetComponent <Multisprites>() != null)
                                {
                                    string tileName = hit.collider.gameObject.name;
                                    hit.collider.GetComponent <SpritePicker>().PickSprite(tileName);
                                }
                            }
                        }
                    }
                }
            }
        }

        if (Event.current.type == EventType.MouseDown && Event.current.button == 1)
        {
            index          = 0;
            selectedPrefab = null;
        }

        //if X pressed, delete the gameobject on the choosen coordinate (if such object exist)
        if (Event.current.type == EventType.KeyDown && Event.current.keyCode == KeyCode.X)
        {
            RaycastHit2D hitInfo = Physics2D.Raycast(gridPosition, Vector2.zero);
            RaycastHit2D within  = Physics2D.Raycast(gridPosition, Vector2.zero, 100, (1 << 2));
            if (canOperate == false)
            {
                EditorUtility.DisplayDialog("Anomaly detected", "Invalid level index.", "Ok");
            }
            else if (hitInfo.collider != null && within.collider.gameObject == map.levels[map.currentLevel])
            {
                string temptag = hitInfo.collider.gameObject.tag;
                DestroyImmediate(hitInfo.collider.gameObject);
                if (temptag == "Multisprites")
                {
                    for (int y = 1; y >= -1; y--)
                    {
                        for (int x = -1; x <= 1; x++)
                        {
                            Vector2        newpos = new Vector2(gridPosition.x + x, gridPosition.y + y);
                            RaycastHit2D[] hits   = Physics2D.RaycastAll(newpos, Vector2.zero);
                            foreach (RaycastHit2D hit in hits)
                            {
                                if (hit.collider != null && hit.collider.gameObject.GetComponent <Multisprites>() != null)
                                {
                                    string tileName = hit.collider.gameObject.name;
                                    hit.collider.GetComponent <SpritePicker>().PickSprite(tileName);
                                }
                            }
                        }
                    }
                }
            }
        }

        if (followCursor != null)
        {
            if (selectedPrefab != null)
            {
                CursorSprite.sprite = selectedPrefab.GetComponent <SpriteRenderer>().sprite;
            }
            else
            {
                CursorSprite.sprite = null;
            }

            followCursor.transform.position = gridPosition;
            followCursor.transform.rotation = Quaternion.Euler(0, 0, rotationDegree);
        }

        SceneView.RepaintAll();
    }
Пример #14
0
        protected override void OnGUIWindow()
        {
            base.OnGUIWindow();

            RootScrollView.BeginScrollView();
            {
                GUILayout.Label("Product Requests", kSubTitleStyle);

                if (GUILayout.Button("RequestForBillingProducts"))
                {
                    RequestBillingProducts(m_products);
                }

                if (GUILayout.Button("RestorePurchases"))
                {
                    RestoreCompletedTransactions();
                }

                if (m_products.Count == 0)
                {
                    GUILayout.Box("There are no billing products. Add products in NPSettings");
                }
                else
                {
                    GUILayout.Label("Product Purchases", kSubTitleStyle);
                    GUILayout.Box("Current Product = " + GetCurrentProduct().Name + " " + "[Products Available = " + GetProductsCount() + "]");

                    GUILayout.BeginHorizontal();
                    {
                        if (GUILayout.Button("Next Product"))
                        {
                            GotoNextProduct();
                        }

                        if (GUILayout.Button("Previous Product"))
                        {
                            GotoPreviousProduct();
                        }
                    }
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button("Buy"))
                    {
                        AddNewResult("Requesting to buy product = " + GetCurrentProduct().Name);
                        BuyProduct(GetCurrentProduct().ProductIdentifier);
                    }

                    if (GUILayout.Button("IsProductPurchased"))
                    {
                        bool _isPurchased = IsProductPurchased(GetCurrentProduct().ProductIdentifier);

                        AddNewResult("Is " + GetCurrentProduct().Name + "Purchased ? " + _isPurchased);
                    }

                    if (GUILayout.Button("IsConsumableProduct"))
                    {
                        bool _isConsumable = GetCurrentProduct().IsConsumable;

                        AddNewResult("Is " + GetCurrentProduct().Name + "Consumable ? " + _isConsumable);
                    }
                }
            }
            RootScrollView.EndScrollView();

            DrawResults();
            DrawPopButton();
        }
Пример #15
0
 protected override void OnGUIWindow()
 {
     base.OnGUIWindow();
     GUILayout.Box(name);
 }
Пример #16
0
        void DrawFlowGUI()
        {
            GUILayout.Box("Brush Settings", new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(20) });
            var oldV = flowVisualization;

            flowVisualization = (FlowVisualization)EditorGUILayout.EnumPopup("Visualize", flowVisualization);
            if (flowVisualization != oldV)
            {
                UpdateDisplayMode();
            }
            var ft = flowTarget;

            flowTarget = (FlowTarget)EditorGUILayout.EnumPopup("Target", flowTarget);
            if (flowTarget != ft)
            {
                UpdateDisplayMode();
            }
            flowBrushType = (FlowBrushType)EditorGUILayout.EnumPopup("Mode", flowBrushType);

            DrawBrushSettingsGUI();
            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();



            if (GUILayout.Button("Reset"))
            {
                Vector2 norm = new Vector2(0.5f, 0.5f);

                foreach (PaintJob job in jobs)
                {
                    PrepBrushMode(job);
                    switch (flowTarget)
                    {
                    case FlowTarget.ColorRG:
                        job.stream.SetColorRG(norm, job.verts.Length); break;

                    case FlowTarget.ColorBA:
                        job.stream.SetColorBA(norm, job.verts.Length); break;

                    case FlowTarget.UV0_XY:
                        job.stream.SetUV0_XY(norm, job.verts.Length); break;

                    case FlowTarget.UV0_ZW:
                        job.stream.SetUV0_ZW(norm, job.verts.Length); break;

                    case FlowTarget.UV1_XY:
                        job.stream.SetUV1_XY(norm, job.verts.Length); break;

                    case FlowTarget.UV1_ZW:
                        job.stream.SetUV1_ZW(norm, job.verts.Length); break;

                    case FlowTarget.UV2_XY:
                        job.stream.SetUV2_XY(norm, job.verts.Length); break;

                    case FlowTarget.UV2_ZW:
                        job.stream.SetUV2_ZW(norm, job.verts.Length); break;

                    case FlowTarget.UV3_XY:
                        job.stream.SetUV3_XY(norm, job.verts.Length); break;

                    case FlowTarget.UV3_ZW:
                        job.stream.SetUV3_ZW(norm, job.verts.Length); break;
                    }
                }
            }
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();
        }
Пример #17
0
        public override void OnInspectorGUI()
        {
            var oldSkin = GUI.skin;

            serializedObject.Update();
            if (skin)
            {
                GUI.skin = skin;
            }
            GUILayout.BeginVertical("Item Collection", "window");
            GUILayout.Label(m_Logo, GUILayout.MaxHeight(25));
            GUILayout.Space(10);

            GUI.skin = oldSkin;
            base.OnInspectorGUI();
            if (skin)
            {
                GUI.skin = skin;
            }

            if (manager.itemListData)
            {
                GUILayout.BeginVertical("box");
                if (itemReferenceList.arraySize > manager.itemListData.items.Count)
                {
                    manager.items.Resize(manager.itemListData.items.Count);
                }
                GUILayout.Box("Item Collection " + manager.items.Count);
                filteredItems = manager.itemsFilter.Count > 0 ? GetItemByFilter(manager.itemListData.items, manager.itemsFilter) : manager.itemListData.items;

                if (!inAddItem && filteredItems.Count > 0 && GUILayout.Button("Add Item", EditorStyles.miniButton))
                {
                    inAddItem = true;
                }
                if (inAddItem && filteredItems.Count > 0)
                {
                    GUILayout.BeginVertical("box");
                    selectedItem = EditorGUILayout.Popup(new GUIContent("SelectItem"), selectedItem, GetItemContents(filteredItems));
                    bool isValid       = true;
                    var  indexSelected = manager.itemListData.items.IndexOf(filteredItems[selectedItem]);
                    if (manager.items.Find(i => i.id == manager.itemListData.items[indexSelected].id) != null)
                    {
                        isValid = false;
                        EditorGUILayout.HelpBox("This item already exist", MessageType.Error);
                    }
                    GUILayout.BeginHorizontal();

                    if (isValid && GUILayout.Button("Add", EditorStyles.miniButton))
                    {
                        itemReferenceList.arraySize++;
                        itemReferenceList.GetArrayElementAtIndex(itemReferenceList.arraySize - 1).FindPropertyRelative("id").intValue     = manager.itemListData.items[indexSelected].id;
                        itemReferenceList.GetArrayElementAtIndex(itemReferenceList.arraySize - 1).FindPropertyRelative("amount").intValue = 1;
                        EditorUtility.SetDirty(manager);
                        serializedObject.ApplyModifiedProperties();
                        inAddItem = false;
                    }
                    if (GUILayout.Button("Cancel", EditorStyles.miniButton))
                    {
                        inAddItem = false;
                    }
                    GUILayout.EndHorizontal();
                    GUILayout.EndVertical();
                }

                GUIStyle boxStyle = new GUIStyle(GUI.skin.box);
                scroll = GUILayout.BeginScrollView(scroll, GUILayout.MinHeight(200), GUILayout.ExpandHeight(false), GUILayout.ExpandWidth(false));
                for (int i = 0; i < manager.items.Count; i++)
                {
                    var item = manager.itemListData.items.Find(t => t.id.Equals(manager.items[i].id));
                    if (item)
                    {
                        GUILayout.BeginVertical("box");
                        GUILayout.BeginHorizontal();
                        GUILayout.BeginHorizontal();

                        var rect = GUILayoutUtility.GetRect(50, 50);

                        if (item.icon != null)
                        {
                            DrawTextureGUI(rect, item.icon, new Vector2(50, 50));
                        }

                        var name    = " ID " + item.id.ToString("00") + "\n - " + item.name + "\n - " + item.type.ToString();
                        var content = new GUIContent(name, null, "Click to Open");
                        GUILayout.Label(content, EditorStyles.miniLabel);
                        GUILayout.BeginVertical("box");
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Auto Equip", EditorStyles.miniLabel);
                        manager.items[i].autoEquip = EditorGUILayout.Toggle("", manager.items[i].autoEquip, GUILayout.Width(30));
                        if (manager.items[i].autoEquip)
                        {
                            GUILayout.Label("IndexArea", EditorStyles.miniLabel);
                            manager.items[i].indexArea = EditorGUILayout.IntField("", manager.items[i].indexArea, GUILayout.Width(30));
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Amount", EditorStyles.miniLabel);
                        manager.items[i].amount = EditorGUILayout.IntField(manager.items[i].amount, GUILayout.Width(30));

                        if (manager.items[i].amount < 1)
                        {
                            manager.items[i].amount = 1;
                        }

                        GUILayout.EndHorizontal();
                        if (item.attributes.Count > 0)
                        {
                            manager.items[i].changeAttributes = GUILayout.Toggle(manager.items[i].changeAttributes, new GUIContent("Change Attributes", "This is a override of the original item attributes"), EditorStyles.miniButton, GUILayout.ExpandWidth(true));
                        }
                        GUILayout.EndVertical();

                        GUILayout.EndHorizontal();

                        if (GUILayout.Button("x", GUILayout.Width(25), GUILayout.Height(25)))
                        {
                            itemReferenceList.DeleteArrayElementAtIndex(i);
                            EditorUtility.SetDirty(target);
                            serializedObject.ApplyModifiedProperties();
                            break;
                        }

                        GUILayout.EndHorizontal();

                        Color backgroundColor = GUI.backgroundColor;
                        GUI.backgroundColor = Color.clear;
                        var _rec = GUILayoutUtility.GetLastRect();
                        _rec.width -= 100;

                        EditorGUIUtility.AddCursorRect(_rec, MouseCursor.Link);

                        if (GUI.Button(_rec, ""))
                        {
                            if (manager.itemListData.inEdition)
                            {
                                if (ItemListWindow.Instance != null)
                                {
                                    ItemListWindow.SetCurrentSelectedItem(manager.itemListData.items.IndexOf(item));
                                }
                                else
                                {
                                    ItemListWindow.CreateWindow(manager.itemListData, manager.itemListData.items.IndexOf(item));
                                }
                            }
                            else
                            {
                                ItemListWindow.CreateWindow(manager.itemListData, manager.itemListData.items.IndexOf(item));
                            }
                        }
                        GUILayout.Space(7);
                        GUI.backgroundColor = backgroundColor;
                        if (item.attributes != null && item.attributes.Count > 0)
                        {
                            if (manager.items[i].changeAttributes)
                            {
                                if (GUILayout.Button("Reset", EditorStyles.miniButton))
                                {
                                    manager.items[i].attributes = null;
                                }
                                if (manager.items[i].attributes == null)
                                {
                                    manager.items[i].attributes = item.attributes.CopyAsNew();
                                }
                                else if (manager.items[i].attributes.Count != item.attributes.Count)
                                {
                                    manager.items[i].attributes = item.attributes.CopyAsNew();
                                }
                                else
                                {
                                    for (int a = 0; a < manager.items[i].attributes.Count; a++)
                                    {
                                        GUILayout.BeginHorizontal();
                                        GUILayout.Label(manager.items[i].attributes[a].name.ToString());
                                        manager.items[i].attributes[a].value = EditorGUILayout.IntField(manager.items[i].attributes[a].value, GUILayout.MaxWidth(60));
                                        GUILayout.EndHorizontal();
                                    }
                                }
                            }
                        }

                        GUILayout.EndVertical();
                    }
                    else
                    {
                        itemReferenceList.DeleteArrayElementAtIndex(i);
                        EditorUtility.SetDirty(manager);
                        serializedObject.ApplyModifiedProperties();
                        break;
                    }
                }
                GUILayout.EndScrollView();
                GUI.skin.box = boxStyle;

                GUILayout.EndVertical();
                if (GUI.changed)
                {
                    EditorUtility.SetDirty(manager);
                    serializedObject.ApplyModifiedProperties();
                }
            }
            GUILayout.EndVertical();
            if (GUI.changed)
            {
                EditorUtility.SetDirty(target);
            }
            serializedObject.ApplyModifiedProperties();
            GUI.skin = oldSkin;
        }
Пример #18
0
 void DoToolTip(int windowID)
 {
     GUILayout.Box(new GUIContent(tooltip), GUILayout.MaxWidth(width + MAX_SIZE), GUILayout.MaxHeight(height));
 }
Пример #19
0
    void DrawConsoleWindow(int id)
    {
        Color defaultContentColor = GUI.contentColor;

        GUIStyle buttonStyle = new GUIStyle("button");

        buttonStyle.alignment   = TextAnchor.MiddleLeft;
        buttonStyle.fixedHeight = 30;
        buttonStyle.margin      = new RectOffset(0, 0, 0, 0);

        GUI.contentColor = Color.white;

        GUILayout.BeginVertical();

        GUILayout.BeginHorizontal();
        GUILayout.Label("Logs");

        GUILayout.Space(20);

        _filter = (LogFilter)GUILayout.SelectionGrid((int)_filter, Enum.GetNames(typeof(LogFilter)), Enum.GetValues(typeof(LogFilter)).Length);

        GUILayout.EndHorizontal();

        List <LogData> dataList = new List <LogData>(_logQueue.ToArray()).FindAll(m => _filter == LogFilter.All || m.type.GetFilter() == _filter);

        int listItemHeight      = (int)buttonStyle.fixedHeight;         // TODO Use Margin.
        int listScrollBottomPos = (listItemHeight * dataList.Count) - (int)_listScrollRect.height;

        Vector2 scrollPos = new Vector2(_listScrollPosition.x, _autoListScroll ? listScrollBottomPos :_listScrollPosition.y);

        _listScrollPosition = GUILayout.BeginScrollView(scrollPos, false, true, GUILayout.MaxHeight(_scrollHeight));

        if (listScrollBottomPos <= _listScrollPosition.y)
        {
            _autoListScroll = true;
        }

        GUILayout.Box(GUIContent.none, GUIStyle.none, GUILayout.ExpandWidth(true), GUILayout.Height(0));
        Rect listRect = GUILayoutUtility.GetLastRect();

        GUI.contentColor = defaultContentColor;

        foreach (LogData data in dataList)
        {
            GUI.contentColor = data.type.GetFilter().GetContentColor();

            if (GUILayout.Button(data.condition, buttonStyle, GUILayout.Width(listRect.width), GUILayout.ExpandWidth(true)))
            {
                _selectedLogData = data;
            }

            GUI.contentColor = defaultContentColor;
        }

        GUILayout.EndScrollView();

        Rect listLastRect = GUILayoutUtility.GetLastRect();

        if (!(listLastRect.x == 0 && listLastRect.y == 0 && listLastRect.width == 1 && listLastRect.height == 1))
        {
            _listScrollRect = GUILayoutUtility.GetLastRect();
        }

        GUILayout.Space(10);
        GUILayout.Label("Detail");
        _detailScrollPosition = GUILayout.BeginScrollView(_detailScrollPosition, false, true, GUILayout.MaxHeight(_scrollHeight));
        if (_selectedLogData != null)
        {
            GUI.contentColor = _selectedLogData.type.GetFilter().GetContentColor();

            GUILayout.Label(_selectedLogData.condition + "\n" + _selectedLogData.stackTrace);

            GUI.contentColor = defaultContentColor;
        }

        GUILayout.EndScrollView();

        _detailScrollRect = GUILayoutUtility.GetLastRect();


        GUILayout.Space(10);

        // Export Menu
        GUILayout.BeginHorizontal();

        GUI.contentColor = defaultContentColor;

        if (_selectedLogData == null)
        {
            GUI.contentColor = Color.gray;
            GUILayout.Button("Log Export (Select a Log!)");
        }
        else
        {
            if (GUILayout.Button("Log Export"))
            {
                ExportLog(_selectedLogData);
            }
        }

        GUI.contentColor = defaultContentColor;

        GUILayout.EndHorizontal();

        // Clear & Close
        GUILayout.BeginHorizontal();
        if (GUILayout.Button("Clear"))
        {
            _selectedLogData = null;
            _logQueue        = new Queue <LogData>();
        }

        if (GUILayout.Button("Close"))
        {
            isShow = false;
        }
        GUILayout.EndHorizontal();

        GUILayout.EndVertical();
        GUI.DragWindow(new Rect(0, 0, _consoleRect.width, 30));

        GUI.contentColor = defaultContentColor;
    }
        public void OnGUI()
        {
            GUILayout.Box("", style: _chillHeader);
            GUILayout.Space(4);
            GUI.backgroundColor = new Color(
                UnityEditor.EditorPrefs.GetFloat("SDKColor_R"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_G"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_B"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_A")
                );
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Check for Updates"))
            {
                theblackarmsSDX_AutomaticUpdateAndInstall.AutomaticSDKInstaller();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("importer made by zombie2312"))
            {
                Application.OpenURL(Url);
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("theblackarmsSDX Discord"))
            {
                Application.OpenURL(Url1 + Link);
            }
            if (GUILayout.Button("theblackarmsSDX Website"))
            {
                Application.OpenURL(Url1);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(4);
            //Update assets
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Update assets (config)"))
            {
                theblackarmsSDX_ImportManager.updateConfig();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("login"))
            {
                Application.OpenURL(Url1 + Link1);
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(4);



            //Imports V!V
            GUI.backgroundColor = new Color(
                UnityEditor.EditorPrefs.GetFloat("SDKColor_R"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_G"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_B"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_A")
                );
            _changeLogScroll    = GUILayout.BeginScrollView(_changeLogScroll, GUILayout.Width(_sizeX));
            GUI.backgroundColor = new Color(
                UnityEditor.EditorPrefs.GetFloat("SDKColor_R"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_G"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_B"),
                UnityEditor.EditorPrefs.GetFloat("SDKColor_A")
                );
            foreach (var asset in assets)
            {
                GUILayout.BeginHorizontal();
                if (asset.Value == "")
                {
                    GUILayout.FlexibleSpace();
                    GUILayout.Label(asset.Key);
                    GUILayout.FlexibleSpace();
                }
                else
                {
                    if (GUILayout.Button(
                            (File.Exists(theblackarmsSDX_Settings.getAssetPath() + asset.Value) ? "Import" : "Download") +
                            " " + asset.Key))
                    {
                        theblackarmsSDX_ImportManager.downloadAndImportAssetFromServer(asset.Value);
                    }

                    if (GUILayout.Button("Del", GUILayout.Width(40)))
                    {
                        theblackarmsSDX_ImportManager.deleteAsset(asset.Value);
                    }
                }
                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();
            GUILayout.BeginHorizontal();
            EditorPrefs.SetBool("theblackarmsSDX_ShowInfoPanel", GUILayout.Toggle(EditorPrefs.GetBool("theblackarmsSDX_ShowInfoPanel"), "Show at startup"));
            GUILayout.EndHorizontal();
        }
Пример #21
0
        public override void PublishSectionGUI(float h, float kLabelMinWidth, float kLabelMaxWidth)
        {
            GUIContent content;
            float      minHeight = h;
            float      maxHeight = h;

            GUILayout.Label(EditorGUIUtility.TextContent("Packaging"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_MetroPackageName, EditorGUIUtility.TextContent("Package name|Specifies the unique name that identifies the package on the system."), new GUILayoutOption[0]);
            this.m_MetroPackageName.stringValue = Utility.TryValidatePackageName(this.m_MetroPackageName.stringValue);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Package display name|Specifies the app name that appears in the Store. Same as Product Name."), new GUIContent(this.m_ProductName.stringValue), new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_MetroPackageVersion, EditorGUIUtility.TextContent("Version|The version number of the package. A version string in quad notation \"Major.Minor.Build.Revision\"."), new GUILayoutOption[0]);
            this.m_MetroPackageVersion.stringValue = PlayerSettings.WSA.ValidatePackageVersion(this.m_MetroPackageVersion.stringValue);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Publisher display name|A friendly name for the publisher that can be displayed to users. Same as Company Name."), new GUIContent(this.m_CompanyName.stringValue), new GUILayoutOption[0]);
            EditorGUILayout.Space();
            GUILayout.Label(EditorGUIUtility.TextContent("Certificate"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Publisher"), new GUIContent(PlayerSettings.WSA.certificateSubject), new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Issued by"), new GUIContent(PlayerSettings.WSA.certificateIssuer), new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Expiration date"), new GUIContent(!PlayerSettings.WSA.certificateNotAfter.HasValue ? null : PlayerSettings.WSA.certificateNotAfter.Value.ToShortDateString()), new GUILayoutOption[0]);
            Rect   rect            = GUILayoutUtility.GetRect(kLabelMinWidth, kLabelMaxWidth, minHeight, maxHeight, EditorStyles.layerMaskField);
            Rect   position        = new Rect(rect.x + EditorGUIUtility.labelWidth, rect.y, rect.width - EditorGUIUtility.labelWidth, rect.height);
            string certificatePath = PlayerSettings.WSA.certificatePath;

            if (string.IsNullOrEmpty(certificatePath))
            {
                content = EditorGUIUtility.TextContent("Select...|Browse for certificate.");
            }
            else
            {
                content = new GUIContent(FileUtil.GetLastPathNameComponent(certificatePath), certificatePath);
            }
            if (GUI.Button(position, content))
            {
                certificatePath = EditorUtility.OpenFilePanel(null, Application.dataPath, "pfx").Replace('\\', '/');
                string projectRelativePath = FileUtil.GetProjectRelativePath(certificatePath);
                if (string.IsNullOrEmpty(projectRelativePath) && !string.IsNullOrEmpty(certificatePath))
                {
                    Debug.LogError("Certificate path '" + Path.GetFullPath(certificatePath) + "' has to be relative to " + Path.GetFullPath(Application.dataPath + @"\.."));
                }
                else
                {
                    try
                    {
                        if (!PlayerSettings.WSA.SetCertificate(projectRelativePath, null))
                        {
                            MetroCertificatePasswordWindow.Show(projectRelativePath);
                        }
                    }
                    catch (UnityException exception)
                    {
                        Debug.LogError(exception.Message);
                    }
                }
            }
            rect     = GUILayoutUtility.GetRect(kLabelMinWidth, kLabelMaxWidth, minHeight, maxHeight, EditorStyles.layerMaskField);
            position = new Rect(rect.x + EditorGUIUtility.labelWidth, rect.y, rect.width - EditorGUIUtility.labelWidth, rect.height);
            if (GUI.Button(position, EditorGUIUtility.TextContent("Create...|Create test certificate.")))
            {
                MetroCreateTestCertificateWindow.Show(this.m_CompanyName.stringValue);
            }
            EditorGUILayout.Space();
            GUILayout.Label(EditorGUIUtility.TextContent("Application UI"), EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.LabelField(EditorGUIUtility.TextContent("Display name|Specifies the full name of the app."), new GUIContent(this.m_ProductName.stringValue), new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_MetroApplicationDescription, EditorGUIUtility.TextContent("Description|Specifies the text that describes the app on its tile in Windows."), new GUILayoutOption[0]);
            this.m_MetroApplicationDescription.stringValue = this.ValidateMetroApplicationDescription(this.m_MetroApplicationDescription.stringValue);
            EditorGUILayout.Space();
            GUILayout.Label("File Type Associations", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("Name:", new GUILayoutOption[0]);
            GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
            this.m_MetroFTAName.stringValue = GUILayout.TextField(this.m_MetroFTAName.stringValue, options);
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label("File Types", EditorStyles.boldLabel, new GUILayoutOption[0]);
            bool flag = !string.IsNullOrEmpty(this.m_MetroFTAName.stringValue);

            if (flag)
            {
                GUILayoutOption[] optionArray2 = new GUILayoutOption[] { GUILayout.MinHeight(100f) };
                this.metroFTAFileTypesScrollViewPosition = GUILayout.BeginScrollView(this.metroFTAFileTypesScrollViewPosition, EditorStyles.helpBox, optionArray2);
                int         index      = -1;
                int         num4       = 0;
                IEnumerator enumerator = this.m_MetroFTAFileTypes.GetEnumerator();
                try
                {
                    while (enumerator.MoveNext())
                    {
                        SerializedProperty current = (SerializedProperty)enumerator.Current;
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.BeginVertical(new GUILayoutOption[0]);
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.Label("Content Type:", new GUILayoutOption[0]);
                        SerializedProperty property2 = current.FindPropertyRelative("contentType");
                        if (property2 != null)
                        {
                            GUILayoutOption[] optionArray3 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
                            property2.stringValue = GUILayout.TextField(property2.stringValue, optionArray3);
                        }
                        GUILayout.EndHorizontal();
                        GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                        GUILayout.Label("File Type:", new GUILayoutOption[0]);
                        SerializedProperty property3 = current.FindPropertyRelative("fileType");
                        if (property3 != null)
                        {
                            GUILayoutOption[] optionArray4 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
                            property3.stringValue = GUILayout.TextField(property3.stringValue, optionArray4).ToLower();
                        }
                        GUILayout.EndHorizontal();
                        GUILayoutOption[] optionArray5 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
                        if (GUILayout.Button("Remove", optionArray5))
                        {
                            index = num4;
                        }
                        GUILayout.EndVertical();
                        GUILayout.EndHorizontal();
                        num4++;
                        if (num4 < this.m_MetroFTAFileTypes.arraySize)
                        {
                            GUILayoutOption[] optionArray6 = new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(1f) };
                            GUILayout.Box(GUIContent.none, EditorStyles.helpBox, optionArray6);
                        }
                    }
                }
                finally
                {
                    IDisposable disposable = enumerator as IDisposable;
                    if (disposable != null)
                    {
                        disposable.Dispose();
                    }
                }
                if ((index >= 0) && (index < this.m_MetroFTAFileTypes.arraySize))
                {
                    this.m_MetroFTAFileTypes.DeleteArrayElementAtIndex(index);
                }
                GUILayout.EndScrollView();
            }
            else
            {
                GUILayout.Label("Please specify Name first.", new GUILayoutOption[0]);
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            using (new EditorGUI.DisabledScope(!flag))
            {
                if (GUILayout.Button("Add New", new GUILayoutOption[0]))
                {
                    this.m_MetroFTAFileTypes.InsertArrayElementAtIndex(this.m_MetroFTAFileTypes.arraySize);
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label("Protocol", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("Name:", new GUILayoutOption[0]);
            GUILayoutOption[] optionArray7 = new GUILayoutOption[] { GUILayout.MaxWidth(150f) };
            this.m_MetroProtocolName.stringValue = GUILayout.TextField(this.m_MetroProtocolName.stringValue, optionArray7).ToLower();
            GUILayout.EndHorizontal();
            GUILayout.Space(5f);
            GUILayout.Label("Compilation", EditorStyles.boldLabel, new GUILayoutOption[0]);
            PlayerSettings.WSA.compilationOverrides = (PlayerSettings.WSACompilationOverrides)EditorGUILayout.EnumPopup(EditorGUIUtility.TextContent("Compilation Overrides"), PlayerSettings.WSA.compilationOverrides, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            GUILayout.Label("Misc", EditorStyles.boldLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            PlayerSettings.WSA.inputSource = (PlayerSettings.WSAInputSource)EditorGUILayout.EnumPopup(EditorGUIUtility.TextContent("Input Source"), PlayerSettings.WSA.inputSource, new GUILayoutOption[0]);
            GUILayout.Label("Capabilities", EditorStyles.boldLabel, new GUILayoutOption[0]);
            GUILayoutOption[] optionArray8 = new GUILayoutOption[] { GUILayout.MinHeight(200f) };
            this.capScrollViewPosition = GUILayout.BeginScrollView(this.capScrollViewPosition, EditorStyles.helpBox, optionArray8);
            IEnumerator enumerator2 = Enum.GetValues(typeof(PlayerSettings.WSACapability)).GetEnumerator();

            try
            {
                while (enumerator2.MoveNext())
                {
                    PlayerSettings.WSACapability capability = (PlayerSettings.WSACapability)enumerator2.Current;
                    GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                    bool introduced33 = PlayerSettings.WSA.GetCapability(capability);
                    GUILayoutOption[] optionArray9 = new GUILayoutOption[] { GUILayout.MinWidth(150f) };
                    bool flag2 = GUILayout.Toggle(introduced33, capability.ToString(), optionArray9);
                    PlayerSettings.WSA.SetCapability(capability, flag2);
                    GUILayout.EndHorizontal();
                }
            }
            finally
            {
                IDisposable disposable2 = enumerator2 as IDisposable;
                if (disposable2 != null)
                {
                    disposable2.Dispose();
                }
            }
            GUILayout.EndScrollView();
        }
Пример #22
0
        private void OnGUI()
        {
            lineHeight = EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;

            GUILayoutHelper.Vertical(() =>
            {
                GUILayoutHelper.Area(new Rect(0, 0, 3 * position.width / 8, position.height), () =>
                {
                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        GUILayout.Box((Texture2D)EditorGUIUtility.Load("Assets/Resources/AppIcon1.png"), GUILayout.Width(50), GUILayout.Height(50));
                        var titleStyle      = new GUIStyle(EditorStyles.largeLabel);
                        titleStyle.font     = EditorGUIUtility.Load("Assets/Resources/Fonts/TESFonts/Kingthings Petrock.ttf") as Font;
                        titleStyle.fontSize = 50;
                        GUILayout.Label(modName, titleStyle);
                    });

                    EditorGUILayout.Space();

                    GUILayoutHelper.Horizontal(() =>
                    {
                        GUILayout.Label(localPath);

                        if (IconButton("d_editicon.sml", "Select target path"))
                        {
                            if (!string.IsNullOrEmpty(targetPath = EditorUtility.OpenFolderPanel("Select mod folder", rootPath, "Mod")))
                            {
                                Load();
                            }
                        }
                        if (IconButton("d_Refresh", "Reload and discharge unsaved changes"))
                        {
                            Load();
                        }
                        using (new EditorGUI.DisabledScope(modName == "None" || duplicateSections || duplicateKeys))
                            if (IconButton("d_P4_CheckOutLocal", "Save settings to disk"))
                            {
                                Save();
                            }
                    });

                    saveOnExit = EditorGUILayout.ToggleLeft(new GUIContent("Save on Exit", "Save automatically when window is closed."), saveOnExit);

                    if (data == null)
                    {
                        EditorGUILayout.HelpBox("Select a folder to store settings.", MessageType.Info);
                        return;
                    }

                    if (duplicateSections)
                    {
                        EditorGUILayout.HelpBox("Multiple sections with the same name detected!", MessageType.Error);
                    }
                    if (duplicateKeys)
                    {
                        EditorGUILayout.HelpBox("Multiple keys with the same name in a section detected!", MessageType.Error);
                    }

                    DrawHeader("Header");
                    EditorGUILayout.HelpBox("Version of settings checked against local values and presets.", MessageType.None);
                    data.Version = EditorGUILayout.TextField("Version", data.Version);

                    DrawHeader("Presets");
                    EditorGUILayout.HelpBox("Pre-defined values for all or a set of settings. Author is an optional field.", MessageType.None);
                    presetsScrollPosition = GUILayoutHelper.ScrollView(presetsScrollPosition, () => presets.DoLayoutList());
                    EditorGUILayout.Space();
                    if (presets.index != -1)
                    {
                        var preset    = data.Presets[presets.index];
                        preset.Author = EditorGUILayout.TextField("Author", preset.Author);
                        EditorGUILayout.PrefixLabel("Description");
                        preset.Description = EditorGUILayout.TextArea(preset.Description);
                    }

                    GUILayout.FlexibleSpace();

                    DrawHeader("Tools");
                    if (GUILayout.Button("Import Legacy INI"))
                    {
                        string iniPath;
                        if (!string.IsNullOrEmpty(iniPath = EditorUtility.OpenFilePanel("Select ini file", rootPath, "ini")))
                        {
                            data.ImportLegacyIni(new IniParser.FileIniDataParser().ReadFile(iniPath));
                        }
                    }
                    else if (GUILayout.Button("Merge presets"))
                    {
                        string path;
                        if (!string.IsNullOrEmpty(path = EditorUtility.OpenFilePanel("Select preset file", rootPath, "json")))
                        {
                            data.LoadPresets(path, true);
                        }
                    }
                    else if (GUILayout.Button("Export localization table"))
                    {
                        string path;
                        if (!string.IsNullOrEmpty(path = EditorUtility.OpenFolderPanel("Select a folder", textPath, "")))
                        {
                            MakeTextDatabase(Path.Combine(path, string.Format("mod_{0}.txt", modName)));
                        }
                    }

                    EditorGUILayout.Space();
                });

                if (data == null)
                {
                    return;
                }

                float areaWidth = 5 * position.width / 8;
                GUILayoutHelper.Area(new Rect(position.width - areaWidth, 0, areaWidth, position.height), () =>
                {
                    EditorGUILayout.Space();

                    if (data.Presets.Count > 0 && presets.index != -1)
                    {
                        if (GUILayout.SelectionGrid(IsPreset ? 1 : 0, new string[] { "Defaults", data.Presets[presets.index].Title }, 2) == 0)
                        {
                            if (IsPreset)
                            {
                                LoadPreset(-1);
                            }
                        }
                        else
                        {
                            if (currentPreset != presets.index)
                            {
                                LoadPreset(presets.index);
                            }
                        }
                    }

                    mainScrollPosition = GUILayoutHelper.ScrollView(mainScrollPosition, () =>
                    {
                        sections.DoLayoutList();

                        duplicateSections = duplicateKeys = false;
                        var sectionNames  = new List <string>();
                        foreach (var section in data.Sections)
                        {
                            section.Name = !string.IsNullOrEmpty(section.Name) ? section.Name.Replace(" ", string.Empty) : GetUniqueName(sectionNames, "Section");
                            sectionNames.Add(section.Name);

                            var keyNames = new List <string>();
                            foreach (var key in section.Keys)
                            {
                                key.Name = !string.IsNullOrEmpty(key.Name) ? key.Name.Replace(" ", string.Empty) : GetUniqueName(keyNames, "Key");
                                keyNames.Add(key.Name);
                            }

                            duplicateKeys |= DuplicatesDetected(keyNames);
                            this.keyNames.Add(keyNames);
                        }
                        this.sectionNames  = sectionNames;
                        duplicateSections |= DuplicatesDetected(sectionNames);
                    });

                    GUILayout.FlexibleSpace();
                    EditorGUILayout.Space();
                });
            });
        }
Пример #23
0
    private void DrawAboutWindow()
    {
        string version = (AssetDatabase.FindAssets("VERSION", new string[] { manager.relativePath }).Length > 0) ? " " + File.ReadAllText(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("VERSION", new string[] { manager.relativePath })[0])) : "";

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("<b><size=18>Avatar Scaling" + version + "</size></b>", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true
        }, GUILayout.Width(300f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("<size=13>Author: Joshuarox100</size>", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true, normal = new GUIStyleState()
            {
                background = null
            }
        });
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        DrawLine();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("<b><size=15>Summary</size></b>", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true
        }, GUILayout.Width(200f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("With Avatars 3.0, you can now change the scale of your Avatar and viewpoint in realtime! This tool exists to set everything up needed for scaling to work on any given 3.0 Avatar with minimal user effort.", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true, normal = new GUIStyleState()
            {
                background = null
            }
        }, GUILayout.Width(350f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        DrawLine();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("<b><size=15>Special Thanks</size></b>", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true
        }, GUILayout.Width(200f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("<i><size=12>Ambiguous</size></i>\nFor helping me test things throughout the entirety of development.\n\n" +
                      "<i><size=12>PhaxeNor</size></i>\nFor inspiring me to make this setup script for the tool.\n\n" +
                      "<i><size=12>Mr. Doon</size></i>\nFor suggesting significant improvements to the Animators.", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true, normal = new GUIStyleState()
            {
                background = null
            }
        }, GUILayout.Width(350f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        DrawLine();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("<b><size=15>Troubleshooting</size></b>", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true
        }, GUILayout.Width(200f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        GUILayout.Box("If you're having issues or want to contact me, you can find more information at the Github page linked below!", new GUIStyle(GUI.skin.GetStyle("Box"))
        {
            richText = true, normal = new GUIStyleState()
            {
                background = null
            }
        }, GUILayout.Width(350f));
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        EditorGUILayout.Space();
        DrawLine();
        GUILayout.Label("Github Repository", new GUIStyle(EditorStyles.boldLabel)
        {
            alignment = TextAnchor.UpperCenter
        });
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Open in Browser", GUILayout.Width(250)))
        {
            Application.OpenURL("https://github.com/Joshuarox100/VRC-Avatar-Scaling");
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
    }
Пример #24
0
    void OnGUI()
    {
        //TestGUI();

        if (stage == 0)         //Stage 0 is the login screen
        {
            LoginScreen();
        }         //end of stage 0


        if (stage == 1)        //stage 1 is the character selection screen
        {
            if (generator == null)
            {
                return;
            }
            GUI.enabled = usingLatestConfig && !character.animation.IsPlaying("walkin");
            GUILayout.BeginArea(new Rect(10, 10, typeWidth + 2 * buttonWidth + 8, 500));

            // Buttons for changing the active character.
            GUILayout.BeginHorizontal();

            if (GUILayout.Button("<", GUILayout.Width(buttonWidth)))
            {
                ChangeCharacter(false);
            }

            GUILayout.Box("Character", GUILayout.Width(typeWidth));

            if (GUILayout.Button(">", GUILayout.Width(buttonWidth)))
            {
                ChangeCharacter(true);
            }

            GUILayout.EndHorizontal();

            // Buttons for changing character elements.
            AddCategory("face", "Head", null);
            AddCategory("eyes", "Eyes", null);
            AddCategory("hair", "Hair", null);
            AddCategory("top", "Body", "item_shirt");
            AddCategory("pants", "Legs", "item_pants");
            AddCategory("shoes", "Feet", "item_boots");


            // Buttons for saving and deleting configurations.
            // In a real world application you probably want store these
            // preferences on a server, but for this demo configurations
            // are saved locally using PlayerPrefs.
            if (GUILayout.Button("Save Configuration"))
            {
                PlayerPrefs.SetString(prefName, generator.GetConfig());
            }

            if (GUILayout.Button("Delete Configuration"))
            {
                PlayerPrefs.DeleteKey(prefName);
            }

            // Show download progress or indicate assets are being loaded.
            GUI.enabled = true;
            if (!usingLatestConfig)
            {
                float  progress = generator.CurrentConfigProgress;
                string status   = "Loading";
                if (progress != 1)
                {
                    status = "Downloading " + (int)(progress * 100) + "%";
                }
                GUILayout.Box(status);
            }

            GUILayout.EndArea();

            /*
             *      if(GUI.Button(new Rect(Screen.width-190,Screen.height-140,180,60), "Unlock Customizations"))
             *
             *      {
             *              Unlock uk = GameObject.Find("Unlock").GetComponent<Unlock>();
             *              uk.UnlockEnabled = true;
             *              stage = 2;
             *      }
             */

            if (GUI.Button(new Rect(Screen.width - 190, Screen.height - 70, 180, 60), "Purchase Current Selections"))

            {
                StoreFront sf = GameObject.Find("StoreFront").GetComponent <StoreFront>();
                sf.SetStoreFrontProductPrice();
                sf.StoreFrontEnabled = true;
                stage = 2;
            }
        }    //end of stage 1

        if (stage == 5)
        {
            int confirmButtonX = Screen.width / 2 - 65;
            int confirmButtonY = Screen.height / 2;
            GUI.Box(new Rect(confirmButtonX - 25, confirmButtonY - 20, 280, 100), "Your purchase has been proccessed. \n Thank you for shopping with Co-Op and Co!");

            if (GUI.Button(new Rect(confirmButtonX + 75, confirmButtonY + 20, 80, 40), "Contiune"))
            {
                stage = 1;
            }
        }
    }
	public static void Separator()
	{
		GUI.color = new Color(1, 1, 1, 0.25f);
		GUILayout.Box("", "HorizontalSlider", GUILayout.Height(16));
		GUI.color = Color.white;
	}
        private void IconsGUI()
        {
            // Make sure unhandledCursorInteractions is the same length as cursorIcons
            while (unhandledCursorInteractions.Count < cursorIcons.Count)
            {
                unhandledCursorInteractions.Add(null);
            }
            while (unhandledCursorInteractions.Count > cursorIcons.Count)
            {
                unhandledCursorInteractions.RemoveAt(unhandledCursorInteractions.Count + 1);
            }

            // List icons
            foreach (CursorIcon _cursorIcon in cursorIcons)
            {
                int i = cursorIcons.IndexOf(_cursorIcon);
                GUILayout.Box("", GUILayout.ExpandWidth(true), GUILayout.Height(1));

                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField("Icon ID:", GUILayout.MaxWidth(145));
                EditorGUILayout.LabelField(_cursorIcon.id.ToString(), GUILayout.MaxWidth(120));

                GUILayout.FlexibleSpace();

                if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f)))
                {
                    SideMenu(i);
                }

                EditorGUILayout.EndHorizontal();

                _cursorIcon.label = CustomGUILayout.TextField("Label:", _cursorIcon.label, "AC.KickStarter.cursorManager.GetCursorIconFromID (" + i + ").label");
                if (KickStarter.settingsManager != null && KickStarter.settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                {
                    EditorGUILayout.LabelField("Input button:", _cursorIcon.GetButtonName());
                }
                _cursorIcon.ShowGUI(true, true, "Texture:", cursorRendering, "AC.KickStarter.cursorManager.GetCursorIconFromID (" + i + ")");

                if (AllowUnhandledIcons())
                {
                    string autoName = _cursorIcon.label + "_Unhandled_Interaction";
                    unhandledCursorInteractions[i] = ActionListAssetMenu.AssetGUI("Unhandled interaction:", unhandledCursorInteractions[i], "AC.KickStarter.cursorManager.unhandledCursorInteractions[" + i + "]", autoName);
                }

                if (settingsManager != null && settingsManager.interactionMethod == AC_InteractionMethod.ChooseInteractionThenHotspot)
                {
                    _cursorIcon.dontCycle = CustomGUILayout.Toggle("Leave out of Cursor cycle?", _cursorIcon.dontCycle, "AC.KickStarter.cursorManager.GetCursorIconFromID (" + i + ").dontCycle");
                }
            }

            if (GUILayout.Button("Create new icon"))
            {
                Undo.RecordObject(this, "Add icon");
                cursorIcons.Add(new CursorIcon(GetIDArray()));
            }

            passUnhandledHotspotAsParameter = CustomGUILayout.ToggleLeft("Pass Hotspot as GameObject parameter?", passUnhandledHotspotAsParameter, "AC.KickStarter.cursorManager.passUnhandledHotspotAsParameter");
            if (passUnhandledHotspotAsParameter)
            {
                EditorGUILayout.HelpBox("The Hotspot will be set as the Unhandled interaction's first parameter, which must be set to type 'GameObject'.", MessageType.Info);
            }
        }
Пример #27
0
    public void ShaderPropertiesGUI(Material material)
    {
        // Use default labelWidth
        EditorGUIUtility.labelWidth = 0f;

        // Detect any changes to the material
        EditorGUI.BeginChangeCheck();
        {
            //renderMode
            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.renderModeText, GUILayout.Width(120));
            var mode = (RenderMode)renderMode.floatValue;
            mode = (RenderMode)EditorGUILayout.Popup((int)mode, Styles.renderModeNames);
            GUILayout.EndHorizontal();

            //Primary properties
            GUILayout.Label(Styles.PrimaryText, EditorStyles.boldLabel);

            //Diffuse
            m_MaterialEditor.TexturePropertySingleLine(Styles.diffuseText, diffuseTexture, diffuseColor);

            //metallic
            bool hasGlossMap = false;
            hasGlossMap = metallicGlossTexture.textureValue != null;
            m_MaterialEditor.TexturePropertySingleLine(Styles.metallicText, metallicGlossTexture, hasGlossMap ? null : metallic);

            //smoothness
            //m_MaterialEditor.ShaderProperty(smoothness, Styles.smoothnessText, MaterialEditor.kMiniTextureFieldLabelIndentLevel);
            bool showSmoothnessScale = hasGlossMap;
            int  smoothnessChannel   = (int)smoothnessTextureChannel.floatValue;
            if (smoothnessChannel == (int)SmoothnessTextureChannelMode.Albedo_Alpha)
            {
                showSmoothnessScale = true;
            }
            int indentation = 2; // align with labels of texture properties
            m_MaterialEditor.ShaderProperty(showSmoothnessScale ? smoothnessScale : smoothness, showSmoothnessScale ? Styles.smoothnessScaleText : Styles.smoothnessText, indentation);

            //smoothnessTextureChannel
            GUILayout.BeginHorizontal();
            GUILayout.Label("", GUILayout.Width(26));
            GUILayout.Label(Styles.smoothnessTextureChannelText, GUILayout.Width(120));
            var smoothMode = (SmoothnessTextureChannelMode)smoothnessTextureChannel.floatValue;
            smoothMode = (SmoothnessTextureChannelMode)EditorGUILayout.Popup((int)smoothMode, Styles.smoothnessTextureChannelModeNames);
            GUILayout.EndHorizontal();

            //mormal
            bool hasNormalTexture = false;
            hasNormalTexture = normalTexture.textureValue != null;
            m_MaterialEditor.TexturePropertySingleLine(Styles.normalMapText, normalTexture, hasNormalTexture ? normalScale : null);

            //parallax
            bool hasparallaxTexture = false;
            hasparallaxTexture = parallaxTexture.textureValue != null;
            m_MaterialEditor.TexturePropertySingleLine(Styles.parallaxText, parallaxTexture, hasparallaxTexture ? parallaxScale : null);

            //occlusion
            bool hasOcclusion = false;
            hasOcclusion = occlusionTexture.textureValue != null;
            m_MaterialEditor.TexturePropertySingleLine(Styles.occlusionText, occlusionTexture, hasOcclusion ? occlusionStrength : null);

            //reflection
            m_MaterialEditor.ShaderProperty(reflection, Styles.reflectionText);

            //emission
            m_MaterialEditor.ShaderProperty(emission, Styles.emissionText);
            if (emission.floatValue == 1)
            {
                m_MaterialEditor.TexturePropertySingleLine(Styles.emissionMapText, emissionTexture, emissionColor);
            }

            //scaleAndOffset
            m_MaterialEditor.TextureScaleOffsetProperty(diffuseTexture);

            GUILayout.Box("", GUILayout.Height(1), GUILayout.ExpandWidth(true));

            //Advanced properties
            GUILayout.Label(Styles.AdvancedText, EditorStyles.boldLabel);
            //alphaTest
            m_MaterialEditor.ShaderProperty(alphaTest, Styles.alphaTest);
            if (alphaTest.floatValue == 1)
            {
                m_MaterialEditor.ShaderProperty(alphaCutoff, Styles.alphaCutoffText, MaterialEditor.kMiniTextureFieldLabelIndentLevel + 1);
            }

            //alphaBlend
            m_MaterialEditor.ShaderProperty(alphaBlend, Styles.alphaBlendText);
            var dstMode = (DstBlendMode)dstBlendMode.floatValue;
            var srcMode = (SrcBlendMode)srcBlendMode.floatValue;
            if (alphaBlend.floatValue == 1)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("", GUILayout.Width(20));
                srcMode = (SrcBlendMode)EditorGUILayout.Popup((int)srcMode, Styles.srcBlendNames);
                dstMode = (DstBlendMode)EditorGUILayout.Popup((int)dstMode, Styles.dstBlendNames);
                GUILayout.EndHorizontal();
            }

            //depthWrite
            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.depthWriteText, GUILayout.Width(120));
            var depthW = (DepthWrite)depthWrite.floatValue;
            depthW = (DepthWrite)EditorGUILayout.Popup((int)depthW, Styles.depthWriteNames);
            GUILayout.EndHorizontal();

            //depthTest
            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.depthTestText, GUILayout.Width(120));
            var depthT = (DepthTest)depthTest.floatValue;
            depthT = (DepthTest)EditorGUILayout.Popup((int)depthT, Styles.depthTestNames);
            GUILayout.EndHorizontal();

            //cullMode
            GUILayout.BeginHorizontal();
            GUILayout.Label(Styles.cullModeText, GUILayout.Width(120));
            var cull = (CullMode)cullMode.floatValue;
            cull = (CullMode)EditorGUILayout.Popup((int)cull, Styles.cullModeNames);
            GUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                m_MaterialEditor.RegisterPropertyChangeUndo("Rendering Mode");

                //renderMode
                renderMode.floatValue = (float)mode;
                onChangeRender(material, (RenderMode)material.GetFloat("_Mode"));

                //smoothnessTextureChannel
                smoothnessTextureChannel.floatValue = (float)smoothMode;
                material.SetInt("_SmoothnessTextureChannel", (int)smoothMode);
                if (smoothnessTextureChannel.floatValue == 1)
                {
                    material.EnableKeyword("Smoothness_DiffuseTexture_Alpha");
                }
                else
                {
                    material.DisableKeyword("Smoothness_DiffuseTexture_Alpha");
                }

                //cullMode
                cullMode.floatValue = (float)cull;
                material.SetInt("_Cull", (int)cull);

                if ((RenderMode)material.GetFloat("_Mode") == RenderMode.Custom)
                {
                    //alphaTest
                    if (alphaTest.floatValue == 1)
                    {
                        material.EnableKeyword("EnableAlphaCutoff");
                        material.EnableKeyword("_ALPHATEST_ON");
                    }
                    else
                    {
                        material.DisableKeyword("EnableAlphaCutoff");
                        material.DisableKeyword("_ALPHATEST_ON");
                    }

                    //alphaBlend
                    if (alphaBlend.floatValue == 1)
                    {
                        srcBlendMode.floatValue = (float)srcMode;
                        dstBlendMode.floatValue = (float)dstMode;
                        material.SetInt("_SrcBlend", (int)srcMode);
                        material.SetInt("_DstBlend", (int)dstMode);
                        material.EnableKeyword("_ALPHABLEND_ON");
                        material.SetInt("_AlphaBlend", 1);
                    }
                    else
                    {
                        material.DisableKeyword("_ALPHABLEND_ON");
                        material.SetInt("_AlphaBlend", 0);
                        material.SetInt("_SrcBlend", (int)1);
                        material.SetInt("_DstBlend", (int)0);
                    }

                    //depthWrite
                    depthWrite.floatValue = (float)depthW;
                    material.SetInt("_ZWrite", (int)depthW);

                    //depthTest
                    depthTest.floatValue = (float)depthT;
                    material.SetInt("_ZTest", (int)depthT);
                }

                if (parallaxTexture.textureValue != null)
                {
                    material.EnableKeyword("ParallaxTexture");
                }
                else
                {
                    material.DisableKeyword("ParallaxTexture");
                }

                if (metallicGlossTexture.textureValue != null)
                {
                    material.EnableKeyword("MetallicGlossTexture");
                }
                else
                {
                    material.DisableKeyword("MetallicGlossTexture");
                }

                if (reflection.floatValue == 1)
                {
                    material.EnableKeyword("EnableReflection");
                }
                else
                {
                    material.DisableKeyword("EnableReflection");
                }

                if (emission.floatValue == 1)
                {
                    material.EnableKeyword("EnableEmission");
                }
                else
                {
                    material.DisableKeyword("EnableEmission");
                }
            }
        }
        m_MaterialEditor.RenderQueueField();
    }
Пример #28
0
        internal bool SectionGroup(string title, Texture2D icon, bool expand, string listName = null, System.Type acceptedType = null)
        {
            bool resValue           = expand;
            SerializedProperty list = serializedObject.FindProperty(listName);
            bool displayList        = list != null && acceptedType != null;

            // Top spacing
            GUILayout.Space(8);

            // Container start
            GUILayout.BeginHorizontal();

            // Expand collapse icon
            GUILayout.BeginVertical();
            Color res = GUI.color;

            if (displayList)
            {
                GUILayout.Space(7);
            }
            else
            {
                GUILayout.Space(5);
            }
            Texture2D texture = resValue ? ExpandedIcon : CollapsedIcon;

            GUI.color = EditorColor;
            GUILayout.Label(texture, GUILayout.Width(12));
            GUILayout.EndVertical();

            // Icon
            if (icon != null)
            {
                GUILayout.BeginVertical();
                if (displayList)
                {
                    GUILayout.Space(4);
                }
                GUILayout.Label(icon, GUILayout.Width(18), GUILayout.Height(18));
                GUILayout.EndVertical();
            }
            GUI.color = res;

            // Title
            GUILayout.BeginVertical();
            if (icon != null)
            {
                if (displayList)
                {
                    GUILayout.Space(4);
                }
                else
                {
                    GUILayout.Space(2);
                }
            }

            GUILayout.Label(title, Skin.GetStyle("SectionHeader"));
            GUILayout.EndVertical();

            GUILayout.FlexibleSpace();

            // Drag and drop
            if (displayList)
            {
                GUI.skin.box.alignment        = TextAnchor.MiddleCenter;
                GUI.skin.box.normal.textColor = EditorColor;
                GUILayout.Box(DRAG_DROP, "box", GUILayout.ExpandWidth(true));
                if (ProcessDragDrop(list, acceptedType))
                {
                    resValue = true;
                }
            }

            // Container End
            GUILayout.EndHorizontal();

            // Toggle
            if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition) && Event.current.type == EventType.MouseDown)
            {
                resValue = !resValue;
                Repaint();
            }

            GUILayout.Space(4);

            return(resValue);
        }
Пример #29
0
        private void DisplayPrefab()
        {
            if (Tileset.SelectedBrushId != Tileset.k_BrushId_Default)
            {
                EditorGUILayout.LabelField("Brush tile editing not allowed", EditorStyles.boldLabel);
            }
            else
            {
                bool isMultiselection = Tileset.TileSelection != null;
                Tile selectedTile     = isMultiselection ? Tileset.Tiles[(int)(Tileset.TileSelection.selectionData[0] & Tileset.k_TileDataMask_TileId)] : Tileset.SelectedTile;
                GUILayoutUtility.GetRect(1, 1, GUILayout.Width(Tileset.VisualTileSize.x), GUILayout.Height(Tileset.VisualTileSize.y));
                Rect tileUV = selectedTile.uv;
                GUI.color = Tileset.BackgroundColor;
                GUI.DrawTextureWithTexCoords(GUILayoutUtility.GetLastRect(), EditorGUIUtility.whiteTexture, tileUV, true);
                GUI.color = Color.white;
                GUI.DrawTextureWithTexCoords(GUILayoutUtility.GetLastRect(), Tileset.AtlasTexture, tileUV, true);

                if (isMultiselection)
                {
                    EditorGUILayout.LabelField("* Multi-selection Edition", EditorStyles.boldLabel);
                }
                EditorGUI.BeginChangeCheck();
                TilePrefabData prefabData      = selectedTile.prefabData;
                float          savedLabelWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 80;
                prefabData.offset           = EditorGUILayout.Vector3Field("Offset", prefabData.offset);
                prefabData.offsetMode       = (TilePrefabData.eOffsetMode)EditorGUILayout.EnumPopup("Offset Mode", prefabData.offsetMode);
                prefabData.rotation         = EditorGUILayout.Vector3Field("Rotation", prefabData.rotation);
                EditorGUI.BeginChangeCheck();
                GameObject prevPrefab = prefabData.prefab;
                prefabData.prefab = (GameObject)EditorGUILayout.ObjectField("Prefab", prefabData.prefab, typeof(GameObject), false);
                bool isPrefabChanged = EditorGUI.EndChangeCheck();
                // Special case for 3D tiles where tilemap will be rotated over the plane XZ
                if (isPrefabChanged && !prevPrefab && prefabData.rotation == Vector3.zero && prefabData.prefab && prefabData.prefab.GetComponentInChildren <MeshRenderer>())
                {
                    prefabData.rotation = new Vector3(-90, 0, 0);
                    prefabData.showPrefabPreviewInTilePalette = true;
                }

                GUILayout.BeginHorizontal();
                Texture2D prefabPreview = AssetPreview.GetAssetPreview(selectedTile.prefabData.prefab);
                GUILayout.Box(prefabPreview, prefabPreview != null? (GUIStyle)"Box" : GUIStyle.none);
                GUILayout.EndHorizontal();

                if (prefabData.prefab)
                {
                    EditorGUIUtility.labelWidth = 260;
                    if (prefabPreview)
                    {
                        prefabData.showPrefabPreviewInTilePalette = EditorGUILayout.Toggle("Display the prefab preview in the tile palette", prefabData.showPrefabPreviewInTilePalette);
                    }
                    EditorGUIUtility.labelWidth   = savedLabelWidth;
                    prefabData.showTileWithPrefab = EditorGUILayout.Toggle("Show Tile With Prefab", prefabData.showTileWithPrefab);
                }

                if (EditorGUI.EndChangeCheck())
                {
                    Undo.RecordObject(Tileset, "Tile Prefab Data Changed");
                    if (isMultiselection)
                    {
                        for (int i = 0; i < Tileset.TileSelection.selectionData.Count; ++i)
                        {
                            Tile       tile        = Tileset.Tiles[(int)(Tileset.TileSelection.selectionData[i] & Tileset.k_TileDataMask_TileId)];
                            GameObject savedPrefab = tile.prefabData.prefab;
                            tile.prefabData = prefabData;
                            if (!isPrefabChanged)
                            {
                                tile.prefabData.prefab = savedPrefab;
                            }
                        }
                    }
                    else
                    {
                        selectedTile.prefabData = prefabData;
                    }
                    EditorUtility.SetDirty(Tileset);
                }
            }
        }
Пример #30
0
        private void DrawLeaderboardSection()
        {
            GUILayout.Label("Leaderboard", kSubTitleStyle);

            if (m_leaderboardGIDList.Length == 0)
            {
                GUILayout.Box("Could not find Leaderboard configuration in GameServices. If you want to access Leaderboard feature, then please configure it.");
            }
            else
            {
                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Previous Leaderboard"))
                    {
                        ChangeLeaderboardGID(false);
                    }

                    if (GUILayout.Button("Next Leaderboard"))
                    {
                        ChangeLeaderboardGID(true);
                    }
                }
                GUILayout.EndHorizontal();

                GUILayout.Box(string.Format("Current Leaderboard GID= {0}.", m_curLeaderboardGID));

                if (GUILayout.Button("Create Leaderboard"))
                {
                    Leaderboard _leaderboard = CreateLeaderboardWithGlobalID(m_curLeaderboardGID);
                    AddNewResult(string.Format("Leaderboard with global identifier {0} is created.", _leaderboard.GlobalIdentifier));
                }

                if (GUILayout.Button("Report Score"))
                {
                    ReportScoreWithGlobalID(m_curLeaderboardGID);
                }

                if (GUILayout.Button("Load Top Scores"))
                {
                    LoadTopScores();
                }

                if (GUILayout.Button("Load Player Centered Scores"))
                {
                    LoadPlayerCenteredScores();
                }

                GUILayout.BeginHorizontal();
                {
                    if (GUILayout.Button("Load Previous Scores"))
                    {
                        LoadMoreScores(eLeaderboardPageDirection.PREVIOUS);
                    }

                    if (GUILayout.Button("Load Next Scores"))
                    {
                        LoadMoreScores(eLeaderboardPageDirection.NEXT);
                    }
                }
                GUILayout.EndHorizontal();
            }
        }