コード例 #1
0
        //Called only once upon creating the object
        void Start()
        {
            if (IndicatorDisplaySettings.Load())
            {
                IndicatorDisplaySettings.instance = new IndicatorDisplaySettings();
            }
            Invoke("LateStart", 4);


            CustomizationOpen = false;
        }
コード例 #2
0
 public static bool Load()
 {
     if (File.Exists(Path))
     {
         string json = File.ReadAllText(Path);
         if (!string.IsNullOrEmpty(json))
         {
             instance = JsonUtility.FromJson <IndicatorDisplaySettings>(json);
             return(false);
         }
     }
     return(true);
 }
コード例 #3
0
        // Drawing all the ui elements
        void OnGUI()
        {
            if (CustomizationOpen)
            {
                GUI.Label(new Rect(200, 0, 200, 20), "Offset X = " + IndicatorDisplaySettings.instance.offsetX);
                IndicatorDisplaySettings.instance.offsetX = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 0, 200, 20), IndicatorDisplaySettings.instance.offsetX, 0, Screen.width));
                GUI.Label(new Rect(200, 30, 200, 20), "Offset Y = " + IndicatorDisplaySettings.instance.offsetY);
                IndicatorDisplaySettings.instance.offsetY = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 30, 200, 20), IndicatorDisplaySettings.instance.offsetY, 0, Screen.height));
                GUI.Label(new Rect(200, 60, 200, 20), "Width = " + IndicatorDisplaySettings.instance.Width);
                IndicatorDisplaySettings.instance.Width = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 60, 200, 20), IndicatorDisplaySettings.instance.Width, 0, Screen.width));
                GUI.Label(new Rect(200, 90, 200, 20), "Height = " + IndicatorDisplaySettings.instance.Height);
                IndicatorDisplaySettings.instance.Height = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(0, 90, 200, 20), IndicatorDisplaySettings.instance.Height, 0, Screen.height));

                GUI.Label(new Rect(200, 140, 200, 20), "Healthbar To Name Ratio = " + IndicatorDisplaySettings.instance.HealthToNameRatio);
                IndicatorDisplaySettings.instance.HealthToNameRatio = GUI.HorizontalSlider(new Rect(0, 140, 200, 20), IndicatorDisplaySettings.instance.HealthToNameRatio, 0, 1);

                GUI.Label(new Rect(0, 190, 200, 20), "Anchor = " + IndicatorDisplaySettings.instance.displayMode.ToString());
                if (GUI.Button(new Rect(0, 210, 30, 30), "TOP L"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.TopLeft;
                }
                if (GUI.Button(new Rect(30, 210, 30, 30), "TOP M"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.TopCenter;
                }
                if (GUI.Button(new Rect(60, 210, 30, 30), "TOP R"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.TopRight;
                }
                if (GUI.Button(new Rect(0, 240, 30, 30), "MID L"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.MiddleLeft;
                }
                if (GUI.Button(new Rect(30, 240, 30, 30), "MID M"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.MiddleCenter;
                }
                if (GUI.Button(new Rect(60, 240, 30, 30), "MID R"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.MiddleRight;
                }
                if (GUI.Button(new Rect(0, 270, 30, 30), "BOT L"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.BottomLeft;
                }
                if (GUI.Button(new Rect(30, 270, 30, 30), "BOT M"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.BottomCenter;
                }
                if (GUI.Button(new Rect(60, 270, 30, 30), "BOT R"))
                {
                    IndicatorDisplaySettings.instance.displayMode = IndicatorDisplaySettings.DisplayMode.BottomRight;
                }
                GUI.Label(new Rect(200, 300, 200, 30), "Custom font name");
                IndicatorDisplaySettings.instance.FontName = GUI.TextField(new Rect(0, 300, 200, 30), IndicatorDisplaySettings.instance.FontName);
                GUIStyle samplestyle = new GUIStyle(GUI.skin.label);
                samplestyle.font     = customFont;
                samplestyle.fontSize = IndicatorDisplaySettings.instance.FontSize;
                GUI.Label(new Rect(400, 300, 200, 100), "AaBbCcDdEeFfGgHh 1234567890", samplestyle);
                IndicatorDisplaySettings.instance.FontSize = Mathf.RoundToInt(GUI.HorizontalSlider(new Rect(200, 330, 200, 30), IndicatorDisplaySettings.instance.FontSize, 4, 40));

                int i = 370;
                IndicatorDisplaySettings.instance.HealthBarBackgroundR = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarBackgroundR, 0, 1);
                GUI.Label(new Rect(200, i, 200, 30), "Background Red ");
                i += 30;
                IndicatorDisplaySettings.instance.HealthBarBackgroundG = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarBackgroundG, 0, 1);
                GUI.Label(new Rect(200, i, 200, 30), "Background Green ");
                i += 30;
                IndicatorDisplaySettings.instance.HealthBarBackgroundB = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarBackgroundB, 0, 1);
                GUI.Label(new Rect(200, i, 200, 30), "Background Blue ");
                i += 60;
                IndicatorDisplaySettings.instance.HealthBarR = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarR, 0, 1);
                GUI.Label(new Rect(200, i, 200, 30), "Foreground Red ");
                i += 30;
                IndicatorDisplaySettings.instance.HealthBarG = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarG, 0, 1);
                GUI.Label(new Rect(200, i, 200, 30), "Foreground Green ");
                i += 30;
                IndicatorDisplaySettings.instance.HealthBarB = GUI.HorizontalSlider(new Rect(0, i, 200, 30), IndicatorDisplaySettings.instance.HealthBarB, 0, 1);
                GUI.Label(new Rect(200, i, 200, 30), "Foreground Blue ");
                i += 50;
                if (GUI.Button(new Rect(20, i, 250, 40), "SAVE AND UPDATE CHANGES"))
                {
                    IndicatorDisplaySettings.Save();
                    ChangeFont(IndicatorDisplaySettings.instance.FontName);
                    SetDesign();
                }

                i += 50;

                //if (GUI.Button(new Rect(20, i, 250, 40), "Mario?")){
                //    MoritzIsFunny();
                //}
            }
            else
            {
                // if there isnt a target to display return out of this method to save processing power
                // otherwise continue

                if (info == null)
                {
                    return;
                }

                // drawing a simple background with predefined texture
                GUI.Box(rect, "");
                // following calls from GUI class will be displayed on top of previous one


                float f = (float)info.CurrentHealth / info.MaxHealth;
                f = Mathf.Clamp(f, 0, 1);

                Rect HealthCurrentRect = new Rect(HealthTotalRect);

                HealthCurrentRect.width *= f;



                Rect BGrect = new Rect(HealthTotalRect.x + HealthCurrentRect.width, HealthTotalRect.y, HealthTotalRect.width * (1 - f), HealthTotalRect.height);

                string currhealthtext = info.CurrentHealth + "  /  " + info.MaxHealth;


                GUI.Label(NameRect, info.PersonName, nameStyle);

                GUI.DrawTexture(BGrect, HPBG);

                GUI.DrawTexture(HealthCurrentRect, HPF);
                GUI.Label(NameRect, info.PersonName, nameStyle);

                GUI.Label(HealthTotalRect, currhealthtext, nameStyle);
            }
        }
コード例 #4
0
 void LateStart()
 {
     ChangeFont(IndicatorDisplaySettings.instance.FontName);
     SetDesign();
     IndicatorDisplaySettings.Save();
 }