Пример #1
0
    private void DrawHeader()
    {
        GUILayout.Label("Enemy Maker", skin.GetStyle("Header1"));

        GUILayout.BeginArea(header);
        GUILayout.EndArea();
    }
Пример #2
0
    void OnGUI()
    {
        //if(GUI.Button(new Rect(40, 400, 100, 40), "Save"))
        if (Input.GetKeyDown(KeyCode.F5))
        {
            SaveInventory();
        }
        //if(GUI.Button(new Rect(40, 450, 100, 40), "Load"))
        if (Input.GetKeyDown(KeyCode.F7))
        {
            LoadInventory();
            //GUI.Label(new Rect(1350, 240, 200, 50), "Inventory Loaded");
        }

        tooltip  = "";
        GUI.skin = skin;
        if (showInventory)
        {
            DrawInventory();
            if (showTooltip)
            {
                GUI.Box(new Rect(Event.current.mousePosition.x + 15f, Event.current.mousePosition.y, 200, 200), tooltip, skin.GetStyle("Tooltip"));
            }
        }
        if (draggingItem)
        {
            GUI.DrawTexture(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 50, 50), draggedItem.itemIcon);
        }
    }
        private void DrawImage(GUISkin skin)
        {
            var     imgPath = Path.Combine(pagePath, m_url);
            Texture img     = null;

            if (m_imgDownload == null)
            {
                img = AssetDatabase.LoadAssetAtPath <Texture>(imgPath);
            }
            else
            {
                var handler = m_imgDownload.downloadHandler as DownloadHandlerTexture;
                if (m_imgDownload.isHttpError || m_imgDownload.isNetworkError)
                {
                    EditorGUILayout.LabelField($"Error loading image: {m_imgDownload.error} @ {m_imgDownload.url}");
                }
                else if (!m_imgDownload.isDone)
                {
                    EditorGUILayout.LabelField($"Loading: {m_imgOp.progress * 100}%");
                }
                else
                {
                    img = handler.texture;
                }
            }

            if (img != null)
            {
                float aspect = (float)img.width / (float)img.height;
                var   pos    = GUILayoutUtility.GetAspectRect(aspect, skin.GetStyle("image"), GUILayout.ExpandWidth(true));
                GUI.DrawTexture(pos, img, ScaleMode.ScaleAndCrop);
            }
        }
Пример #4
0
    public static void DrawText(GUISkin guiSkin, string text, Vector3 position, Color? color = null, int fontSize = 0, float yOffset = 0) {
#if UNITY_EDITOR
        var prevSkin = GUI.skin;
        if (guiSkin == null)
            Debug.LogWarning("editor warning: guiSkin parameter is null");
        else
            GUI.skin = guiSkin;

        GUIContent textContent = new GUIContent(text);

        GUIStyle style = (guiSkin != null) ? new GUIStyle(guiSkin.GetStyle("Label")) : new GUIStyle();
        if (color != null)
            style.normal.textColor = (Color)color;
        if (fontSize > 0)
            style.fontSize = fontSize;

        Vector2 textSize = style.CalcSize(textContent);
        Vector3 screenPoint = Camera.current.WorldToScreenPoint(position);

        if (screenPoint.z > 0) // checks necessary to the text is not visible when the camera is pointed in the opposite direction relative to the object
        {
            var worldPosition = Camera.current.ScreenToWorldPoint(new Vector3(screenPoint.x - textSize.x * 0.5f, screenPoint.y + textSize.y * 0.5f + yOffset, screenPoint.z));
            UnityEditor.Handles.Label(worldPosition, textContent, style);
        }
        GUI.skin = prevSkin;
#endif
    }
Пример #5
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(40, 400, 100, 40), "Save"))
     {
         SaveInventory();
     }
     if (GUI.Button(new Rect(40, 450, 100, 40), "Load"))
     {
         LoadInventory();
     }
     tooltip  = "";
     GUI.skin = skin;
     if (showInventory)
     {
         DrawInventory();
         if (showTooltip)
         {
             GUI.Box(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 200, 200), tooltip, skin.GetStyle("Tooltip"));
         }
     }
     if (draggingItem)
     {
         GUI.DrawTexture(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 50, 50), draggedItem.itemIcon);
     }
 }
Пример #6
0
        public override void UpdateView(Rect editorRect, Rect percentageRect, Event e, EncounterNodeGraph curGraph, GUISkin viewSkin)
        {
            base.UpdateView(editorRect, percentageRect, e, curGraph, viewSkin);
            GUI.Box(viewRect, viewTitle, viewSkin.GetStyle("ViewBg"));

            GUILayout.BeginArea(viewRect);
            GUILayout.Space(60);
            GUILayout.BeginHorizontal();
            GUILayout.Space(30);

            /*if (curGraph != null) {
             * if (!curGraph.showProperties) {
             *      EditorGUILayout.LabelField ("None");
             * } else {
             *      curGraph.selectedNode.DrawNodeProperties ();
             * }
             * }*/


            GUILayout.EndHorizontal();
            if (curGraph != null)
            {
                if (/*curGraph*/ EncounterNodeGraph.showProperties == true && _loaded == true)
                {
                    EncounterNodeGraph.selectedNode.DrawNodeProperties(viewSkin);
                }
            }
            if (Event.current.type == EventType.Repaint)
            {
                _loaded = true;
            }
            GUILayout.EndArea();

            ProcessEvents(e);
        }
Пример #7
0
 void OnGUI()
 {
     tooltip  = "";
     GUI.skin = skin;
     DrawHotbar();
     DrawSelector();
     if (showTooltip) // draw tooltip
     {
         GUI.Box(new Rect(Event.current.mousePosition.x + 15f, Event.current.mousePosition.y, 200, 200), tooltip, skin.GetStyle("Tooltip"));
     }
     if (draggingItem) //draw item icons if dragging
     {
         showTooltip = false;
         GUI.DrawTexture(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 50, 50), draggedItem.itemIcon);
     }
 }
Пример #8
0
        /// <summary>
        /// Used to show text
        /// </summary>
        public void OnGUI()
        {
            if (CurrentSkin)
            {
                GUI.skin = CurrentSkin;
            }

            GUIStyle style = CurrentSkin.GetStyle("label");

            GUIStyle backupStyle = style;

            style.normal.textColor = Color.black;

            Rect position = new Rect(6, Screen.height - 200, Screen.width - 12, 194);

            int border = 1;

            position.x -= border;
            position.y += border;
            GUI.Label(position, currentText, style);
            position.x += border * 2;
            GUI.Label(position, currentText, style);
            position.y -= border;
            GUI.Label(position, currentText, style);
            position.x -= border * 2;
            GUI.Label(position, currentText, style);
            position.x += border;

            style.normal.textColor = Color.white;
            GUI.Label(position, currentText, style);

            style = backupStyle;
        }
    public static void drawCenterBoxHeader(GUISkin CustomGuiSkin, string menuHeading, float width, float height)
    {
        //Debug.Log ("width:" + _mainMenuWidth);
        //Debug.Log ("height: " + _mainMenuHeight);

        GUILayout.BeginArea(
            new Rect(
                (Screen.width * 0.50f) - (width * 0.50f),
                (Screen.height * 0.50f) - (height * 0.50f),
                width,
                height)
            );
        GUILayout.BeginVertical("", GUI.skin.box);

        if (menuHeading == "")
        {
            return;
        }

        GUIStyle LabelStyle       = CustomGuiSkin.GetStyle("Label");
        int      originalFontSize = LabelStyle.fontSize;

        LabelStyle.fontSize = 12;

        GUILayout.Space(20);

        GUILayout.Label(menuHeading);

        LabelStyle.fontSize = originalFontSize;

        GUILayout.FlexibleSpace();
    }
Пример #10
0
 private void OnGUI()
 {
     GUILayout.Label("Profile");
     if (RuleEditorSettings.Instance.ProfileFilters != null)
     {
         int labelToRemove = -1;
         for (int i = 0; i < RuleEditorSettings.Instance.ProfileFilters.Length; i++)
         {
             GUILayout.BeginHorizontal();
             var bgPrev = GUI.backgroundColor;
             GUI.backgroundColor = RuleEditorSettings.Instance.ProfileFilters[i].Color;
             RuleEditorSettings.Instance.ProfileFilters[i].Name = GUILayout.TextField(RuleEditorSettings.Instance.ProfileFilters[i].Name, AdelicSkin.textField, GUILayout.Width(200));
             GUI.backgroundColor = bgPrev;
             RuleEditorSettings.Instance.ProfileFilters[i].Color = EditorGUILayout.ColorField(new GUIContent(), RuleEditorSettings.Instance.ProfileFilters[i].Color, false, true, false, GUILayout.Width(15));
             if (GUILayout.Button(new GUIContent("", "Remove Label"), AdelicSkin.GetStyle("RemoveBtn")))
             {
                 labelToRemove = i;
             }
             GUILayout.EndHorizontal();
         }
         if (labelToRemove > -1)
         {
             ArrayUtility.RemoveAt <Filter>(ref RuleEditorSettings.Instance.ProfileFilters, labelToRemove);
         }
     }
     if (GUILayout.Button("+"))
     {
         ArrayUtility.Add <Filter>(ref RuleEditorSettings.Instance.ProfileFilters, new Filter());
     }
     RuleEditorSettings.Instance.Save();
 }
Пример #11
0
    /*--------------------------------------------------------------------------------------------------------*/

    /** <summary>
     * Displays the default GUI components on the screen. This includes the name of the algorithm,
     * a button for stopping the algorithm, and a button for recording information about the current scene. </summary> */
    protected void DisplayGUI()
    {
        //create a label to show the name of the algorithm
        GUI.Label(new Rect(side_padding,
                           side_padding,
                           Screen.width - side_padding * 2,
                           button_height), subject.Name, custom_skin.GetStyle("Label"));

        //create a button for stopping the algorithm
        if (GUI.Button(new Rect(Screen.width - button_width - side_padding,
                                Screen.height - button_height - side_padding,
                                button_width,
                                button_height), "End Run"))
        {
            //stop the algorithm
            SceneController.Stop_algorithm();
        }

        //create a button for recording information about the current scene
        if (GUI.Button(new Rect(Screen.width - (button_width + side_padding) * 2,
                                Screen.height - button_height - side_padding,
                                button_width,
                                button_height), "Print"))
        {
            //record relevant information
            Print_information();
        }
    }
Пример #12
0
	// UI LOGIC ---------------------------------------------------------------------------------------------------

	private void OnEnable()
	{
	    _lineTexture = new Texture2D(1, 2);
	    _lineTexture.wrapMode = TextureWrapMode.Repeat;
	    _lineTexture.SetPixel(0, 0, new Color(1, 1, 1, 0));
	    _lineTexture.SetPixel(0, 1, new Color(1, 1, 0, 1));
	    _lineTexture.Apply();

	    _infoRect = new Rect(10, 10, 500, 220);

	    GUISkin heuSkin = HEU_EditorUI.LoadHEUSkin();
	    _toolsBGStyle = heuSkin.GetStyle("toolsbg");

	    _selectedCurvePoints.Clear();

	    HEU_Curve.Interaction setInteraction = HEU_Curve.PreferredNextInteractionMode;
	    HEU_Curve.PreferredNextInteractionMode = HEU_Curve.Interaction.VIEW;
	    SwitchToMode(setInteraction);

	    // Moves focus to the Scene window, which we need for keyboard input at start
	    if (SceneView.currentDrawingSceneView != null)
	    {
		SceneView.currentDrawingSceneView.Focus();
	    }

	    // Callback will be used to disable this tool and reset state
	    Selection.selectionChanged += SelectionChangedCallback;

	    _showInfo = false;
	    _showInfoRepaint = false;
	}
Пример #13
0
        public override void Start()
        {
            m_ConsoleStyle   = m_Skin.GetStyle("console");
            m_TextfieldStyle = m_Skin.GetStyle("textfield");

            //engine.GetService<IDebugCommandService>().Add("createmapcharacter", new CreateMapCharacterCommand("createmapcharacter"));
            Add("exitroomview", new ExitRoomViewCommand("exitroomview"));
            Add("test", new TestCommand("test"));
            Add("journal", new JournalCommand("journal"));
            Add("show", new ShowCommand("show"));
            Add("clear", new ClearCommand("clear"));
            Add("add", new AddCommand("add"));
            Add("restart", new RestartCommand("restart"));
            Add("net", new NetCommand("net"));
            Add("log", new LogCommand("log"));
        }
Пример #14
0
        public bool DraEvent(SerializedProperty list, int index)
        {
            EditorGUILayout.BeginHorizontal(skin.box, GUILayout.ExpandWidth(true));
            {
                var eventName      = list.GetArrayElementAtIndex(index).FindPropertyRelative("eventName");
                var normalizedTime = list.GetArrayElementAtIndex(index).FindPropertyRelative("normalizedTime");
                EditorGUILayout.BeginVertical(GUILayout.ExpandWidth(true));
                {
                    eventName.stringValue = EditorGUILayout.TextField(GUIContent.none, eventName.stringValue, GUILayout.ExpandWidth(true));
                    Rect rect  = GUILayoutUtility.GetLastRect();
                    var  color = GUI.color;

                    rect.y += 20;
                    GUI.Box(rect, "", skin.GetStyle("AnimatorEventBar"));
                    int number = 0;
                    for (int i = 0; i < 101; i++)
                    {
                        timeLineStyle.alignment = TextAnchor.UpperCenter;
                        var rectAdjust = new Rect(rect.position.x + ((rect.width - 5) * (0.01f * i)), rect.position.y, 2.5f, 15);
                        var par        = i % 10f;
                        timeLineStyle.fontSize         = par == 0 ? 15 : par == 5 ? (rect.width * 0.01f > 3f) ? 10 : 5 : (rect.width * 0.01f > 4f) ? 5 : 1;
                        rectAdjust.y                  += par == 0 ? -2 : par == 5 ? (rect.width * 0.01f > 3f) ? -1 : 0 : 0;
                        timeLineStyle.normal.textColor = Color.grey;
                        GUI.Box(rectAdjust, "|", timeLineStyle);
                        rectAdjust.y = rect.position.y + 5;

                        if (par == 0)
                        {
                            timeLineStyle.normal.textColor = Color.black;
                            timeLineStyle.alignment        = TextAnchor.MiddleLeft;
                            timeLineStyle.fontSize         = Mathf.Clamp((int)(rect.width * 0.02f), 6, 10);
                            rectAdjust.width  = 25;
                            rectAdjust.height = 15;
                            rectAdjust.x     += number < 10 ? -1 : -7;
                            GUI.Label(rectAdjust, (number * 0.1f).ToString(), timeLineStyle);
                            number++;
                        }
                    }
                    GUI.color   = color;
                    rect.x     -= 5;
                    rect.width += 10;
                    normalizedTime.floatValue = GUI.HorizontalSlider(rect, normalizedTime.floatValue, 0f, 1f, GUIStyle.none, skin.GetStyle("AnimatorEventThumb"));
                }
                EditorGUILayout.EndVertical();
                var width = 30;
                EditorGUILayout.BeginVertical(GUILayout.Width(width));
                {
                    if (GUILayout.Button("X", EditorStyles.miniButton, GUILayout.Width(width)))
                    {
                        list.DeleteArrayElementAtIndex(index);

                        return(false);
                    }
                    normalizedTime.floatValue = EditorGUILayout.FloatField((float)System.Math.Round(normalizedTime.floatValue, 2), GUILayout.Width(width));
                }
                EditorGUILayout.EndVertical();
            }
            EditorGUILayout.EndHorizontal();
            return(true);
        }
Пример #15
0
 void OnGUI()
 {
     if (_alert != "")
     {
         GUI.Box(_alertBox, _alert, Skin.GetStyle("box"));
     }
 }
Пример #16
0
 public override void OnGUI(Rect rect)
 {
     GUILayout.BeginArea(rect);
     GUILayout.Box(weaponCategory.ToUpper() + " IK Adjust Selector", skin.GetStyle("WindowBG"), GUILayout.Width(rect.width), GUILayout.Height(30));
     scroll    = GUILayout.BeginScrollView(scroll, false, false, GUILayout.Width(rect.width));
     GUI.color = selected == null ? Color.green : Color.white;
     if (canSelectNull && GUILayout.Button("None", selectorStyle, GUILayout.Height(25), GUILayout.Width(rect.width)))
     {
         selected = null;
         editorWindow.Close();
     }
     for (int i = 0; i < weaponIKAdjusts.Count; i++)
     {
         GUI.color = selected == weaponIKAdjusts[i] ? Color.green : Color.white;
         if (GUILayout.Button(weaponIKAdjusts[i].name, selectorStyle, GUILayout.Height(25), GUILayout.Width(rect.width)))
         {
             selected = weaponIKAdjusts[i];
             EditorGUIUtility.PingObject(weaponIKAdjusts[i]);
             editorWindow.Close();
         }
     }
     GUI.color = Color.white;
     GUILayout.EndScrollView();
     GUILayout.EndArea();
 }
Пример #17
0
 private void OnGUI()
 {
     if (isDebugDisp)
     {
         GUI.Label(new Rect(30, 30, 1000, 50), $"Act={NowAction}", guiSkin.GetStyle("Label"));
     }
 }
Пример #18
0
    public void OnGUI()
    {
        //GUI.skin = Skin;

        GUILayout.BeginArea(new Rect(0, 0, Screen.width, Screen.height));         //also added padding for GameSkin on Inspector
        {
            GUILayout.BeginVertical(Skin.GetStyle("EnemyKillText2"));
            {
                if (Application.loadedLevel == 0)
                {
                    GUILayout.Label(string.Format("{0}", GameManager.Instance.Points), Skin.GetStyle("EnemyKillText2"));
                    GUILayout.Label(string.Format("{0}", PlayerPrefs.GetInt("HighScore")), Skin.GetStyle("EnemyKillText2"));
                }
            }
            GUILayout.EndVertical();

//			GUILayout.BeginVertical(SkinB.GetStyle("EnemyKillText3"));
//			{
//				if(Application.loadedLevel == 0){
//					GUILayout.Label(string.Format("{0}", GameManager.Instance.Points), SkinB.GetStyle("EnemyKillText2"));
//					GUILayout.Label(string.Format("{0}", PlayerPrefs.GetInt("HighScore")), SkinB.GetStyle("EnemyKillText2"));
//				}
//
//			}
//			GUILayout.EndVertical();
        }
        GUILayout.EndArea();
    }
Пример #19
0
    public void Draw()
    {
        if (TimeStart > 0f)
        {
            float num = Time.realtimeSinceStartup - TimeStart - TransferDelay;
            if (num > 0f && TransferStateNum < TransferTimer.Length)
            {
                if (TransferStateNum == -1 || TransferTimer[TransferStateNum] == 0f)
                {
                    TransferStateNum++;
                }
                if (TransferStateNum < TransferTimer.Length)
                {
                    TransferTimer[TransferStateNum] -= Time.deltaTime;
                    if (TransferTimer[TransferStateNum] <= 0f)
                    {
                        TransferTimer[TransferStateNum] = 0f;
                    }
                    TransferPercent = 1f - TransferTimer[TransferStateNum] / TransferTimes[TransferStateNum];
                }
            }
        }
        GUIUtil.OnDrawWindow();
        Rect myScreenRect = MyScreenRect;

        myScreenRect.x = QueueBattle.screenSpace.x + (QueueBattle.screenSpace.width - MyScreenRect.width) / 2f;
        myScreenRect.y = QueueBattle.screenSpace.y + (QueueBattle.screenSpace.height - MyScreenRect.height) / 2f;
        GUI.color      = new Color(1f, 1f, 1f, 0.85f);
        Rect position = new Rect(0f, 0f, QueueBattle.screenSpace.width, QueueBattle.screenSpace.height);

        GUI.Box(position, GUIContent.none, SharedSkin.GetStyle("blackbox"));
        GUI.color = Color.white;
        GUI.Window(123, myScreenRect, DrawScoreWindow, GUIContent.none, StatsSkin.window);
    }
Пример #20
0
    void DrawInventory()
    {
        int k = 0;

        for (int j = 0; j < slotY; j++)
        {
            for (int i = 0; i < slotX; i++)
            {
                Rect slotRect = new Rect(i * 52 + 100, j * 52 + 30, 50, 50);
                // 박스 분할하기
                GUI.Box(slotRect, "", skin.GetStyle("slot background"));
                // 각 박스의 생성 위치를 설정해주는 곳입니다. skin.GetStyle은 이전에 만들었던 skin을 불러오는 것임

                // 기능 추가하기
                slots[k] = inventory[k];
                if (slots[k].itemName != null)
                {
                    GUI.DrawTexture(slotRect, slots[k].itemIcon);
                    Debug.Log(slots[k].itemName);
                }

                k++;
                // 갯수 증가
            }
        }
    }
Пример #21
0
    void OnGUI()
    {
        toolTip  = "";
        GUI.skin = skin;

        if (showinventory)
        {
            DrawInventory();
            //if showing inventory show tooltip
            if (showToolTip)
            {
                GUI.Box(new Rect(Event.current.mousePosition.x + 15f, Event.current.mousePosition.y, 200, 200), toolTip, skin.GetStyle("Tooltip"));
            }
            if (draggingItem)
            {
                GUI.DrawTexture(new Rect(Event.current.mousePosition.x - 30f, Event.current.mousePosition.y, 50, 50), draggedItem.itemIcon);
            }

            #region save/loade

            /* if (GUI.Button(new Rect(40, 250, 100, 40), "Save"))
             *  SaveInventory();
             * if (GUI.Button(new Rect(40, 300, 100, 40), "Load"))
             * {
             *  LoadInventory();
             * }*/
            #endregion
        }
    }
Пример #22
0
        void GenerarUI()
        {
            estiloBotonAtras            = estilo.GetStyle("boton_atras");
            estiloPanel                 = new GUIStyle(estilo.box);
            estiloPanel.padding.top    += 20;
            estiloPanel.padding.left   += 20;
            estiloPanel.padding.right  += 20;
            estiloPanel.padding.bottom += 20;
            estiloPanelPuntaje          = estilo.GetStyle("panel_nombre_puntuacion");
            estiloNombrePuntaje         = estilo.GetStyle("label_nombre_puntuacion");
            estiloValorPuntaje          = estilo.GetStyle("label_valor_puntuacion");

            traductor = LanguageManager.Instance;
            CambioTamanoVentanaWindowsStore.cambioTamanoPantalla += RecalcularUI;
            RecalcularUI(Screen.width, Screen.height);
        }
    //private CT_EditPanel _viewPanel;
    #endregion

    /// <summary>
    /// Constructor
    /// </summary>
    /// <param name="skin">Theme skin</param>
    public CryptoItemsTab(GUISkin skin)
    {
        _skin       = skin;
        _controller = new CryptoItemsController
        {
            ClipBoard = skin.GetStyle("Images").normal.scaledBackgrounds[1] as Texture2D
        };

        // link local controller instance to NotificationMonitor
        EnjinEditor.NotificationMonitor.CIController = _controller;

        EditorUtility.DisplayProgressBar("Loading", "Building CryptoItems", 0.95f);

        _detailsPane  = new CT_DetailsPane();
        _mintCostPane = new CT_MintCostPane();
        _optionsPane  = new CT_OptionsPane();
        _searchPane   = new CT_SearchPane();
        _walletPane   = new CT_WalletPane();

        _createPanel = new CT_CreatePanel();
        _editPanel   = new CT_EditPanel();
        _mainPanel   = new CT_MainPanel();
        _meltPanel   = new CT_MeltPanel();
        _mintPanel   = new CT_MintPanel();
        //_viewPanel = new CT_EditPanel();
    }
Пример #24
0
    public static void DrawText(string text, Vector3 position, int fontSize = 0, float yOffset = 0)
    {
#if UNITY_EDITOR
        GUISkin guiSkin = GUI.skin;
        if (guiSkin == null)
        {
            Logger.LogWarning("editor warning: guiSkin parameter is null", Category.DebugConsole);
            return;
        }

        GUIContent textContent = new GUIContent(text);

        GUIStyle style = new GUIStyle(guiSkin.GetStyle("Label"))
        {
            normal = { textColor = Gizmos.color }
        };
        if (fontSize > 0)
        {
            style.fontSize  = fontSize;
            style.fontStyle = FontStyle.Bold;
        }

        Vector2 textSize    = style.CalcSize(textContent);
        Vector3 screenPoint = Camera.current.WorldToScreenPoint(position);

        Vector3 worldPosition = Camera.current.ScreenToWorldPoint(
            new Vector3(screenPoint.x - textSize.x * 0.5f, screenPoint.y + textSize.y * 0.5f + yOffset, screenPoint.z));
        UnityEditor.Handles.Label(worldPosition, textContent, style);
#endif
    }
Пример #25
0
        public void OnGUI()
        {
            if (showTooltip)
            {
                GUIStyle ttStyle       = skin.GetStyle("Tooltip");
                float    dynamicHeight = ttStyle.CalcHeight(new GUIContent(Tooltip), 200);

                Rect ttBox = new Rect(Event.current.mousePosition.x + 10f, Event.current.mousePosition.y, 200, dynamicHeight);

                //Find out if the box should be moved down or left
                if (ttBox.x < screenRect.x)
                {
                    ttBox.x = screenRect.x;
                }
                if (ttBox.y < screenRect.y)
                {
                    ttBox.y = screenRect.y;
                }

                //Find out if the box should be moved up or right
                float exceedingHeight = (ttBox.y + ttBox.height) - (screenRect.y + screenRect.height);
                if (exceedingHeight > 0)
                {
                    ttBox.y = ttBox.y - exceedingHeight;
                }
                float exceedingWidth = (ttBox.x + ttBox.width) - (screenRect.x + screenRect.width);
                if (exceedingWidth > 0)
                {
                    ttBox.x = ttBox.x - exceedingWidth;
                }

                GUI.Box(ttBox, Tooltip, ttStyle);
            }
        }
Пример #26
0
    public static void DrawText(GUISkin guiSkin, string text, Vector3 position, Color?color = null, int fontSize = 0)
    {
#if UNITY_EDITOR
        var prevSkin = GUI.skin;
        if (guiSkin == null)
        {
            Debug.LogWarning("editor warning: guiSkin==null");
        }

        GUI.skin = guiSkin;
        GUIContent nameContent = new GUIContent(text);

        GUIStyle style = (guiSkin != null) ? new GUIStyle(guiSkin.GetStyle("Label")) : new GUIStyle();
        if (color != null)
        {
            style.normal.textColor = (Color)color;
        }
        if (fontSize > 0)
        {
            style.fontSize = fontSize;
        }


        Vector2 size        = style.CalcSize(nameContent);
        Vector3 screenPoint = Camera.current.WorldToScreenPoint(position);
        position = Camera.current.ScreenToWorldPoint(new Vector3(screenPoint.x - size.x * 0.5f, screenPoint.y, -screenPoint.z));
        UnityEditor.Handles.Label(position, nameContent, style);
        GUI.skin = prevSkin;
#endif
    }
Пример #27
0
    void OnGUI()
    {
        tooltip  = "";
        GUI.skin = skin;
        if (showInventory)
        {
            DrawInventory();

            /*var colPreviousGUIColor = GUI.color;
             * GUI.color = new Color(colPreviousGUIColor.r, colPreviousGUIColor.g, colPreviousGUIColor.b, fAlpha);
             * GUI.DrawTexture(new Rect(0.0F, 0.0F, Screen.width, Screen.height), backgroundScreen);*/
            if (showTooltip)
            {
                GUI.Box(new Rect(Event.current.mousePosition.x /*+ 5f*/, Event.current.mousePosition.y, 150, 50), tooltip, skin.GetStyle("Tooltip"));
            }
            if (GUI.Button(new Rect(40, 400, 100, 40), "Save"))
            {
                SaveInventory();
            }
            if (GUI.Button(new Rect(40, 450, 100, 40), "Load"))
            {
                LoadInventory();
            }
            pause = true;
        }
        else
        {
            unPause = true;
            pause   = false;
        }
        if (draggingItem)
        {
            GUI.DrawTexture(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 50, 50), draggedItem.itemIcon);
        }
    }
Пример #28
0
    void OnGUI()
    {
        tooltip  = "";
        GUI.skin = skin;
        if (gameObject.CompareTag("Magnet"))
        {
            tooltip = "<color=#ffffff>" + "Magnet" + "</color>\n" + "A regular magnet that can attract metal objects.";
        }
        if (gameObject.CompareTag("Mop"))
        {
            tooltip = "<color=#ffffff>" + "Mop" + "</color>\n" + "An old mop that still seems like it can absorb water.";
        }
        if (gameObject.CompareTag("Beaker"))
        {
            tooltip = "<color=#ffffff>" + "Beaker of Chemicals" + "</color>\n" + "The label on it reads: \"CAUTION: Chemicals in this beaker have organic growing properties\".";
        }
        if (gameObject.CompareTag("BlowTorch"))
        {
            tooltip = "<color=#ffffff>" + "Blowtorch" + "</color>\n" + "What kind of school leaves a blowtorch lying around?";
        }

        if (showTooltip)
        {
            GUI.Box(new Rect(14, 130, 200, 150), tooltip, skin.GetStyle("Tooltip"));
        }
    }
Пример #29
0
 void OnGUI()
 {
     if (showmeldung)
     {
         GUI.Box(new Rect(300, 20, 300, 100), meldung, skin.GetStyle("Slot"));
     }
 }
Пример #30
0
    private void OnGUI()
    {
        //initialize tooltip

        tooltip = "";

        //initialize GUI Skin

        GUI.skin = skin;

        //Calls the inventory draw method when showInventory is true

        if (IsInventoryShowing)
        {
            DrawInventory();

            if (showTooltip)
            {
                GUI.Box(new Rect(Event.current.mousePosition.x + 15, Event.current.mousePosition.y, 200, 200), tooltip, skin.GetStyle("Tooltip"));
            }
        }

        //Places the item icon on the mouse cursor when an item is being dragged

        if (draggingItem)
        {
            GUI.DrawTexture(new Rect(Event.current.mousePosition.x, Event.current.mousePosition.y, 50, 50), draggedItem.ItemIcon);
        }
    }