Пример #1
0
        private void WindowGUI(int windowID)
        {
            GUIStyle mySty = new GUIStyle(GUI.skin.button);
            mySty.normal.textColor = mySty.focused.textColor = Color.white;
            mySty.padding = new RectOffset(8, 8, 8, 8);

            GUILayout.BeginHorizontal();
            int meterAlt = (int)Math.Truncate(altitude);
            String text;
            if (altitude > altitudeMax)
                text = "Radar Altitude: MAX";
            else
                text = "Radar Altitude: " + meterAlt;

            if (!this.isEnabled)
                text = "   Disabled   ";

            if (GUILayout.Button (text, mySty, GUILayout.ExpandWidth (true))) {
                this.isEnabled = !this.isEnabled;

                var generator = base.GetComponent<ModuleGenerator> ();

                if (!isEnabled)
                    generator.Shutdown ();
                else
                    generator.Activate ();
            }
            GUILayout.EndHorizontal();

            //DragWindow makes the window draggable. The Rect specifies which part of the window it can by dragged by, and is
            //clipped to the actual boundary of the window. You can also pass no argument at all and then the window can by
            //dragged by any part of it. Make sure the DragWindow command is AFTER all your other GUI input stuff, or else
            //it may "cover up" your controls and make them stop responding to the mouse.
            GUI.DragWindow(new Rect(0, 0, 10000, 20));
        }
Пример #2
0
		static GLGizmos()
		{
			DefaultLabelStyle = new GUIStyle
			{
				normal =
				{
					background = EditorGUIUtility.whiteTexture,
					textColor = Color.white
				},

				margin = new RectOffset(0, 0, 0, 0),
				padding = new RectOffset(0, 0, 0, 0),
				alignment = TextAnchor.MiddleCenter,
				border = new RectOffset(6, 6, 6, 6),
				fontSize = 12
			};

			AlternativeLabelStyle = new GUIStyle
			{
				normal =
				{
					background = EditorGUIUtility.whiteTexture,
					textColor = Color.black
				},

				margin = new RectOffset(0, 0, 0, 0),
				padding = new RectOffset(0, 0, 0, 0),
				alignment = TextAnchor.MiddleCenter,
				border = new RectOffset(6, 6, 6, 6),
				fontSize = 12
			};
		}
Пример #3
0
			public Styles() {
				
				this.skin = Resources.Load("UI.Windows/Flow/Styles/Skin" + (EditorGUIUtility.isProSkin == true ? "Dark" : "Light")) as GUISkin;
				if (this.skin != null) {
					
					this.backLock = this.skin.FindStyle("LayoutBackLock");
					this.content = this.skin.FindStyle("LayoutContent");
					this.contentScreen = this.skin.FindStyle("LayoutContentScreen");
					this.closeButton = new GUIStyle("TL SelectionBarCloseButton");
					this.listButton = this.skin.FindStyle("ListButton");
					this.listButtonSelected = this.skin.FindStyle("ListButtonSelected");
					
					this.listTag = new GUIStyle(this.skin.FindStyle("ListButton"));
					this.listTag.alignment = TextAnchor.MiddleRight;
					this.objectField = this.skin.FindStyle("ObjectField");
					this.layoutBack = this.skin.FindStyle("LayoutBack");
					this.dropShadow = this.skin.FindStyle("DropShadowOuter");
					
					this.tabButtonLeft = new GUIStyle("ButtonLeft");
					this.tabButtonLeft.margin = new RectOffset();
					this.tabButtonMid = new GUIStyle("ButtonMid");
					this.tabButtonMid.margin = new RectOffset();
					this.tabButtonRight = new GUIStyle("ButtonRight");
					this.tabButtonRight.margin = new RectOffset();
					
				}
				
			}
Пример #4
0
 public static int AspectSelectionGrid(int selected, Texture[] textures, int approxSize, GUIStyle style, string emptyString, out bool doubleClick)
 {
     GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinHeight(10f) };
     GUILayout.BeginVertical("box", options);
     int num = 0;
     doubleClick = false;
     if (textures.Length != 0)
     {
         float num2 = (EditorGUIUtility.currentViewWidth - 20f) / ((float) approxSize);
         int num3 = (int) Mathf.Ceil(((float) textures.Length) / num2);
         Rect aspectRect = GUILayoutUtility.GetAspectRect(num2 / ((float) num3));
         Event current = Event.current;
         if (((current.type == EventType.MouseDown) && (current.clickCount == 2)) && aspectRect.Contains(current.mousePosition))
         {
             doubleClick = true;
             current.Use();
         }
         num = GUI.SelectionGrid(aspectRect, selected, textures, Mathf.RoundToInt(EditorGUIUtility.currentViewWidth - 20f) / approxSize, style);
     }
     else
     {
         GUILayout.Label(emptyString, new GUILayoutOption[0]);
     }
     GUILayout.EndVertical();
     return num;
 }
		public override void OnPreviewGUI(Rect r, GUIStyle background) {
			
			//var color = new Color(0.8f, 0.8f, 1f, 1f);
			//color.a = 0.7f;
			this.OnPreviewGUI(Color.white, r, GUI.skin.box, true, false);

		}
Пример #6
0
        public static bool Foldout(bool open, GUIContent header, Action content)
        {
            if (foldoutStyle == null)
            {
                foldoutStyle = new GUIStyle(GUI.skin.FindStyle("ShurikenModuleBg"));
                foldoutStyle.padding = new RectOffset(10, 10, 10, 10);

                headerStyle = new GUIStyle(GUI.skin.FindStyle("ShurikenModuleTitle"));
                headerStyle.contentOffset = new Vector2(3, -2);
            }

            GUILayout.BeginVertical("ShurikenEffectBg", GUILayout.MinHeight(1f));

            open = GUI.Toggle(GUILayoutUtility.GetRect(0, 16), open, header, headerStyle);
            if (open)
            {
                GUILayout.BeginVertical(foldoutStyle);

                content();

                GUILayout.EndVertical();
            }
            GUILayout.EndVertical();

            return open;
        }
Пример #7
0
        public static void InitOnMainThread()
        {
            lock (s_mutex)
            {
                if (s_mainThread != null)
                {
                    return;
                }

                if (Runtime.IsEditor)
                {
                    try
                    {
                        GUIStyle style = new GUIStyle();
                        style.CalcHeight(GUIContent.none, 0);
                    }
                    catch (ArgumentException)
                    {
                        #if LUNAR_DEBUG
                        UnityEngine.Debug.Log("ThreadUtils.Init() is not called on the main thread");
                        #endif

                        return;
                    }
                }

                s_mainThread = Thread.CurrentThread;
            }
        }
Пример #8
0
        private void InitGUI()
        {
            //Setup GUI stuff
            windowRect = new Rect(Screen.width / 10, Screen.height / 2f - WINDOW_HEIGHT / 2f, WINDOW_WIDTH, WINDOW_HEIGHT);
            moveRect = new Rect(0, 0, 10000, 20);

            windowLayoutOptions = new GUILayoutOption[4];
            windowLayoutOptions[0] = GUILayout.MinWidth(WINDOW_WIDTH);
            windowLayoutOptions[1] = GUILayout.MaxWidth(WINDOW_WIDTH);
            windowLayoutOptions[2] = GUILayout.MinHeight(WINDOW_HEIGHT);
            windowLayoutOptions[3] = GUILayout.MaxHeight(WINDOW_HEIGHT);

            smallSizeOption = new GUILayoutOption[1];
            smallSizeOption[0] = GUILayout.Width(WINDOW_WIDTH * .25f);

            windowStyle = new GUIStyle(GUI.skin.window);
            scrollStyle = new GUIStyle(GUI.skin.scrollView);

            chatScrollPos = new Vector2(0, 0);
            labelStyle = new GUIStyle(GUI.skin.label);
            buttonStyle = new GUIStyle(GUI.skin.button);
            highlightStyle = new GUIStyle(GUI.skin.button);
            highlightStyle.normal.textColor = Color.red;
            highlightStyle.active.textColor = Color.red;
            highlightStyle.hover.textColor = Color.red;
            textAreaStyle = new GUIStyle(GUI.skin.textArea);
        }
		static UnityEditorUtility ()
		{
			// Create splitter style
			splitterStyle					= new GUIStyle();
			splitterStyle.normal.background	= Texture2D.whiteTexture;
			splitterStyle.stretchWidth		= true;
		}
        void WarnAboutCamerasIncludingControlsLayer( int controlsLayer )
        {
            GUIStyle style = new GUIStyle( GUI.skin.box );
            style.alignment = TextAnchor.UpperLeft;
            style.padding.left = 10;
            style.padding.right = 10;
            style.richText = true;
            bool showWarning = false;
            var text = "" +
                       "<b>Warning:</b>\n" +
                       "Some cameras are set to include the current touch controls layer (" +
                       LayerMask.LayerToName( controlsLayer ) +
                       ") in their culling mask. This may cause duplicates ghosting of controls or other " +
                       "unexpected visual results. You will almost certainly want to exclude the " +
                       "touch controls layer from being rendered in your main game camera.";

            foreach (var camera in Camera.allCameras)
            {
                if (camera != touchManager.touchCamera && (camera.cullingMask & (1 << controlsLayer)) > 0)
                {
                    text += "\n  • " + camera.gameObject.name;
                    showWarning = true;
                }
            }

            if (showWarning)
            {
                GUI.backgroundColor = new Color( 1.0f, 0.8f, 0.8f, 1.0f );
                GUILayout.Box( text, style, GUILayout.ExpandWidth( true ) );
                GUI.backgroundColor = Color.white;
            }
        }
Пример #11
0
		public void OnGUI()
		{
			m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition );

			GUILayout.BeginVertical();

			GUILayout.Space( 10 );

			GUILayout.BeginHorizontal();
			GUILayout.FlexibleSpace();
			GUILayout.Box( m_aboutImage, GUIStyle.none );

			if ( Event.current.type == EventType.MouseUp && GUILayoutUtility.GetLastRect().Contains( Event.current.mousePosition ) )
				Application.OpenURL( "http://www.amplify.pt" );

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

			GUIStyle labelStyle = new GUIStyle( EditorStyles.label );
			labelStyle.alignment = TextAnchor.MiddleCenter;
			labelStyle.wordWrap = true;

			GUILayout.Label( "\nAmplify Color " + VersionInfo.StaticToString(), labelStyle, GUILayout.ExpandWidth( true ) );

			GUILayout.Label( "\nCopyright (c) Amplify Creations, Lda. All rights reserved.\n", labelStyle, GUILayout.ExpandWidth( true ) );

			GUILayout.EndVertical();

			GUILayout.EndScrollView();
		}
Пример #12
0
        //    static string GetVariableName<T>(Expression<Func<T>> expr)
        //{
        //    var body = (MemberExpression)expr.Body;
        //
        //    return body.Member.Name;
        //}
        private void WindowGUI(int windowID)
        {
            GUIStyle mySty = new GUIStyle (GUI.skin.label);
            mySty.normal.textColor = mySty.focused.textColor = Color.white;
            mySty.hover.textColor = mySty.active.textColor = Color.yellow;
            mySty.onNormal.textColor = mySty.onFocused.textColor = mySty.onHover.textColor = mySty.onActive.textColor = Color.green;
            mySty.padding = new RectOffset (0, 0, 0, 0);

            GUILayout.BeginVertical ();
            _scrollPosition = GUILayout.BeginScrollView (_scrollPosition, GUILayout.Width (300), GUILayout.Height (300));

            toggle = GUILayout.Toggle (toggle,objectList.Name,mySty);
            if (toggle) {
                foreach (string str in objectList.Entries) {
                    GUILayout.Label (str, GUILayout.ExpandWidth(true));
                }
            }

            //		List<string> items = ObjectDumper.Dump (vessel);
            //		foreach (string line in items) {
            //			GUILayout.Label (line);
            //		}
            //objectlist.Clear ();

            //	GUILayout.Label("f.Name + type +value");

            GUILayout.EndScrollView();
            GUILayout.EndVertical();

                //DragWindow makes the window draggable. The Rect specifies which part of the window it can by dragged by, and is
                //clipped to the actual boundary of the window. You can also pass no argument at all and then the window can by
                //dragged by any part of it. Make sure the DragWindow command is AFTER all your other GUI input stuff, or else
                //it may "cover up" your controls and make them stop responding to the mouse.
                GUI.DragWindow(new Rect(0, 0, 10000, 20));
        }
Пример #13
0
        public const double G = 6.674E-11; //this seems to be the value the game uses

        #endregion Fields

        #region Methods

        public static GUIStyle buttonStyle(Color color)
        {
            GUIStyle style = new GUIStyle(GUI.skin.button);
            style.onNormal.textColor = style.onFocused.textColor = style.onHover.textColor = style.onActive.textColor = color;
            style.normal.textColor = color;
            return style;
        }
Пример #14
0
        internal static GUILayoutGroup BeginLayoutGroup(GUIStyle style, GUILayoutOption[] options, System.Type layoutType)
        {
            GUILayoutGroup next;
            switch (Event.current.type)
            {
                case EventType.Used:
                case EventType.Layout:
                    next = CreateGUILayoutGroupInstanceOfType(layoutType);
                    next.style = style;
                    if (options != null)
                    {
                        next.ApplyOptions(options);
                    }
                    current.topLevel.Add(next);
                    break;

                default:
                    next = current.topLevel.GetNext() as GUILayoutGroup;
                    if (next == null)
                    {
                        throw new ArgumentException("GUILayout: Mismatched LayoutGroup." + Event.current.type);
                    }
                    next.ResetCursor();
                    GUIDebugger.LogLayoutGroupEntry(next.rect, next.margin, next.style, next.isVertical);
                    break;
            }
            current.layoutGroups.Push(next);
            current.topLevel = next;
            return next;
        }
Пример #15
0
        public static void Initialize()
        {
            if (Initialized)
            {
                return;
            }

            GUI.skin = HighLogic.Skin;

            TABLE_HEAD_STYLE = new GUIStyle();
            TABLE_HEAD_STYLE.fontStyle = FontStyle.Bold;
            TABLE_HEAD_STYLE.normal.textColor = Color.white;

            TABLE_BODY_STYLE = new GUIStyle(GUI.skin.box);
            TABLE_BODY_STYLE.padding = new RectOffset(0, 0, 0, 0);

            TABLE_ROW_STYLE = new GUIStyle(GUI.skin.box);
            TABLE_ROW_STYLE.padding = new RectOffset(0, 12, 10, 4);

            ACTION_BUTTON_STYLE = new GUIStyle(GUI.skin.button);
            ACTION_BUTTON_STYLE.fixedHeight = 28;

            URL_STYLE = new GUIStyle(GUI.skin.label);
            URL_STYLE.normal.textColor = Color.yellow;

            TOGGLE_STYLE = new GUIStyle(GUI.skin.toggle);
            TOGGLE_STYLE.padding = new RectOffset(0, 0, 0, 0);
            TOGGLE_STYLE.normal.textColor = GUI.skin.label.normal.textColor;
        }
Пример #16
0
        public static void SetStyles()
        {
            WindowStyle = new GUIStyle(GUI.skin.window);
            IconStyle = new GUIStyle();

            ButtonToggledStyle = new GUIStyle(GUI.skin.button);
            ButtonToggledStyle.normal.textColor = Color.green;
            ButtonToggledStyle.normal.background = ButtonToggledStyle.onActive.background;

            ButtonToggledRedStyle = new GUIStyle(ButtonToggledStyle);
            ButtonToggledRedStyle.normal.textColor = Color.red;

            ButtonStyle = new GUIStyle(GUI.skin.button);
            ButtonStyle.normal.textColor = Color.white;

            ErrorLabelRedStyle = new GUIStyle(GUI.skin.label);
            ErrorLabelRedStyle.normal.textColor = Color.red;
            ErrorLabelRedStyle.fontSize = 10;

            LabelStyle = new GUIStyle(GUI.skin.label);

            LabelStyleRed = new GUIStyle(LabelStyle);
            LabelStyleRed.normal.textColor = Color.red;

            LabelStyleYellow = new GUIStyle(LabelStyle);
            LabelStyleYellow.normal.textColor = Color.yellow;
        }
Пример #17
0
 internal static void DrawBarScaled(Rect rectStart, GUIStyle Style, GUIStyle StyleNarrow, float Scale)
 {
     Rect rectTemp = new Rect(rectStart);
     rectTemp.width = (float)Math.Ceiling(rectTemp.width = rectTemp.width * Scale);
     if (rectTemp.width <= 2) Style = StyleNarrow;
     GUI.Label(rectTemp, "", Style);
 }
        public void drawKKSettingsGUI()
        {
            KKWindow = new GUIStyle(GUI.skin.window);
            KKWindow.padding = new RectOffset(3, 3, 5, 5);

            KKSettingsRect = GUI.Window(0xC10B3A8, KKSettingsRect, drawKKSettingsWindow, "", KKWindow);
        }
Пример #19
0
 public void SplitArea(GUIContent content, GUIStyle style)
 {
     GUIStyle borderStyle = new GUIStyle();
     GUILayout.EndArea();
     if(_horizontal)
     {
         borderStyle.normal.background = EditorGUIUtility.LoadRequired("AreaHBorder.png") as Texture2D;
         _auxRect.Set(_used, 0f, 4f, Screen.height);
         GUILayout.BeginArea(_auxRect, borderStyle);
         _auxRect.x = 0f;
         EditorGUIUtility.AddCursorRect(_auxRect, MouseCursor.SplitResizeLeftRight);
     }
     else
     {
         borderStyle.normal.background = EditorGUIUtility.LoadRequired("AreaVBorder.png") as Texture2D;
         _auxRect.Set(0f, _used, Screen.width, 4f);
         GUILayout.BeginArea(_auxRect, borderStyle);
         _auxRect.y = 0f;
         EditorGUIUtility.AddCursorRect(_auxRect, MouseCursor.SplitResizeUpDown);
     }
     _used += 4f;
     ProcessInputMouse();
     GUILayout.EndArea();
     GUILayout.BeginArea(NextRect, content, style);
 }
 public static void DrawBox(GUIStyle style)
 {
     if (Boxing) {
         Vector2 Size = BoxEnd - BoxStart;
         GUI.Box (new Rect (BoxStart.x, Screen.height - BoxStart.y, Size.x, -Size.y), "", style);
     }
 }
		public static void DrawLabel (string _text, GUIStyle _style, Alignment _alignment = Alignment.None)
		{
			GUILayout.BeginHorizontal();
			{
				switch (_alignment)
				{
				case Alignment.None:
					GUILayout.Label(_text, _style);
					break;
					
				case Alignment.Left:
					GUILayout.Label(_text, _style);
					GUILayout.FlexibleSpace();
					break;
					
				case Alignment.Center:
					GUILayout.FlexibleSpace();
					GUILayout.Label(_text, _style);
					GUILayout.FlexibleSpace();
					break;
					
				case Alignment.Right:
					GUILayout.FlexibleSpace();
					GUILayout.Label(_text, _style);
					break;
				}
			}
			GUILayout.EndHorizontal();
		}
Пример #22
0
		public override void Display (GUIStyle _style, int _slot, float zoom, bool isActive)
		{
			if (timerTexture)
			{
				if (Application.isPlaying)
				{
					if (GameObject.FindWithTag (Tags.gameEngine) && GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInput>())
					{
						PlayerInput playerInput = GameObject.FindWithTag (Tags.gameEngine).GetComponent <PlayerInput>();
					
						if (playerInput.activeConversation && playerInput.activeConversation.isTimed)
						{
							Rect timerRect = relativeRect;
							timerRect.width = slotSize.x / 100f * AdvGame.GetMainGameViewSize().x * playerInput.activeConversation.GetTimeRemaining ();
							GUI.DrawTexture (ZoomRect (timerRect, zoom), timerTexture, ScaleMode.StretchToFill, true, 0f);
						}
					}
				}
				else
				{
					GUI.DrawTexture (ZoomRect (relativeRect, zoom), timerTexture, ScaleMode.StretchToFill, true, 0f);
				}
			}
			
			base.Display (_style, _slot, zoom, isActive);
		}
        public void Display()
        {
            GUIStyle minorTitle = new GUIStyle(GUI.skin.label);
            minorTitle.alignment = TextAnchor.UpperCenter;
            minorTitle.padding = new RectOffset(0, 0, 0, 0);

            if (stallStyle == null)
                stallStyle = new GUIStyle(FlightGUI.boxStyle);

            GUILayout.Label("Flight Status", minorTitle, GUILayout.ExpandWidth(true));
            GUILayout.BeginHorizontal();
            if (statusBlinker)
            {
                stallStyle.normal.textColor = stallStyle.focused.textColor = stallStyle.hover.textColor = stallStyle.active.textColor = stallStyle.onActive.textColor = stallStyle.onNormal.textColor = stallStyle.onFocused.textColor = stallStyle.onHover.textColor = stallStyle.onActive.textColor = statusColor;
                if (statusBlinkerTimer < 0.5)
                    GUILayout.Box(statusString, stallStyle, GUILayout.ExpandWidth(true));
                else
                    GUILayout.Box("", stallStyle, GUILayout.ExpandWidth(true));

                if (statusBlinkerTimer < 1)
                    statusBlinkerTimer += TimeWarp.deltaTime;
                else
                    statusBlinkerTimer = 0;
            }
            else
            {
                stallStyle.normal.textColor = stallStyle.focused.textColor = stallStyle.hover.textColor = stallStyle.active.textColor = stallStyle.onActive.textColor = stallStyle.onNormal.textColor = stallStyle.onFocused.textColor = stallStyle.onHover.textColor = stallStyle.onActive.textColor = statusColor;
                GUILayout.Box(statusString, stallStyle, GUILayout.ExpandWidth(true));
            }
            GUILayout.EndHorizontal();
        }
 public override void OnInspectorGUI()
 {
   if (this.m_TextStyle == null)
     this.m_TextStyle = (GUIStyle) "ScriptText";
   bool enabled = GUI.enabled;
   GUI.enabled = true;
   TextAsset target = this.target as TextAsset;
   if ((UnityEngine.Object) target != (UnityEngine.Object) null)
   {
     string str;
     if (this.targets.Length > 1)
     {
       str = this.targetTitle;
     }
     else
     {
       str = target.ToString();
       if (str.Length > 7000)
         str = str.Substring(0, 7000) + "...\n\n<...etc...>";
     }
     Rect rect = GUILayoutUtility.GetRect(EditorGUIUtility.TempContent(str), this.m_TextStyle);
     rect.x = 0.0f;
     rect.y -= 3f;
     rect.width = GUIClip.visibleRect.width + 1f;
     GUI.Box(rect, str, this.m_TextStyle);
   }
   GUI.enabled = enabled;
 }
			public Styles() {

				#if UNITY_EDITOR
				this.skin = Resources.Load<GUISkin>("UI.Windows/Core/Styles/Boxes/" + (UnityEditor.EditorGUIUtility.isProSkin == true ? "SkinDark" : "SkinLight"));
				this.boxes = new GUIStyle[WindowLayoutStyles.MAX_DEPTH] {
					
					this.skin.FindStyle("flow node 0"),
					this.skin.FindStyle("flow node 1"),
					this.skin.FindStyle("flow node 2"),
					this.skin.FindStyle("flow node 3"),
					this.skin.FindStyle("flow node 4"),
					this.skin.FindStyle("flow node 5")
					
				};
				this.boxesSelected = new GUIStyle[WindowLayoutStyles.MAX_DEPTH] {
					
					this.skin.FindStyle("flow node 0"), // on
					this.skin.FindStyle("flow node 1"),
					this.skin.FindStyle("flow node 2"),
					this.skin.FindStyle("flow node 3"),
					this.skin.FindStyle("flow node 4"),
					this.skin.FindStyle("flow node 5")
					
				};
				
				this.boxSelected = this.skin.FindStyle("flow node 5");
				#endif

			}
        /// <summary>
        ///     Initialises all the styles required for this object.
        /// </summary>
        private void InitialiseStyles()
        {
            this.windowStyle = new GUIStyle(HighLogic.Skin.window)
            {
                margin = new RectOffset(),
                padding = new RectOffset(5, 5, 0, 5),
            };

            this.hudWindowStyle = new GUIStyle(this.windowStyle)
            {
                normal =
                {
                    background = null
                },
                onNormal =
                {
                    background = null
                },
                padding = new RectOffset(5, 5, 0, 8),
            };

            this.hudWindowBgStyle = new GUIStyle(this.hudWindowStyle)
            {
                normal =
                {
                    background = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.5f))
                },
                onNormal =
                {
                    background = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.5f))
                }
            };
        }
        public static void DrawRoomNames()
        {
            Handles.color = Color.white;
            Handles.BeginGUI();

            // Show labels for each room
            Room[] rooms = GameObject.FindObjectsOfType<Room>();

            foreach (Room room in rooms)
            {
                if (!room.renderer)
                {
                    continue;
                }

                Bounds bounds = room.renderer.bounds;
                Vector3 pos = new Vector3(bounds.min.x, bounds.max.y, 0);

                GUIStyle style = new GUIStyle(GUI.skin.label);
                style.normal.textColor = new Color(1,1,1);
                style.fontSize /= 2;
                Rect boxRect = HandleUtility.WorldPointToSizedRect(pos, new GUIContent(room.name), style);
                boxRect.y -= boxRect.height * 1.5f;
                GUI.Box(boxRect, room.name, style);
            }

            Handles.EndGUI();
        }
Пример #28
0
 internal Toggle()
 {
     Default = new GUIStyle()
       {
     normal = {
       background = Elements.LoadImage("toggle-normal.png"),
     },
     onNormal = {
       background = Elements.LoadImage("toggle-on-normal.png"),
     },
     hover = {
       background = Elements.LoadImage("toggle-hover.png"),
     },
     onHover = {
       background = Elements.LoadImage("toggle-on-hover.png"),
     },
     active = {
       background = Elements.LoadImage("toggle-active.png"),
     },
     onActive = {
       background = Elements.LoadImage("toggle-on-active.png"),
     },
     margin = { right = 10 }
       };
 }
Пример #29
0
 public static int AspectSelectionGridImageAndText(int selected, GUIContent[] textures, int approxSize, GUIStyle style, string emptyString, out bool doubleClick)
 {
     GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MinHeight(10f) };
     EditorGUILayout.BeginVertical(GUIContent.none, EditorStyles.helpBox, options);
     int num = 0;
     doubleClick = false;
     if (textures.Length != 0)
     {
         int xCount = 0;
         Rect position = GetBrushAspectRect(textures.Length, approxSize, 12, out xCount);
         Event current = Event.current;
         if (((current.type == EventType.MouseDown) && (current.clickCount == 2)) && position.Contains(current.mousePosition))
         {
             doubleClick = true;
             current.Use();
         }
         num = GUI.SelectionGrid(position, selected, textures, xCount, style);
     }
     else
     {
         GUILayout.Label(emptyString, new GUILayoutOption[0]);
     }
     GUILayout.EndVertical();
     return num;
 }
		private void DrawExtraFeatures() {
			if (icon == null) {
				string iconFilename = EditorGUIUtility.isProSkin ? DarkSkinIconFilename : LightSkinIconFilename;
				icon = AssetDatabase.LoadAssetAtPath(iconFilename, typeof(Texture2D)) as Texture2D;
			}
			if (dialogueSystemController == null || icon == null) return;
			if (iconButtonStyle == null) {
				iconButtonStyle = new GUIStyle(EditorStyles.label);
				iconButtonStyle.normal.background = icon;
				iconButtonStyle.active.background = icon;
			}
			if (iconButtonContent == null) {
				iconButtonContent = new GUIContent(string.Empty, "Click to open Dialogue Editor.");
			}
			GUILayout.BeginHorizontal();
			if (GUILayout.Button(iconButtonContent, iconButtonStyle, GUILayout.Width(icon.width), GUILayout.Height(icon.height))) {
				Selection.activeObject = dialogueSystemController.initialDatabase;
				PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow.OpenDialogueEditorWindow();
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Wizard...", GUILayout.Width(64))) {
				DialogueManagerWizard.Init();
			}
			GUILayout.EndHorizontal();
			EditorWindowTools.DrawHorizontalLine();
		}
Пример #31
0
 static void GUISkin_verticalSlider(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.GUISkin _this = (UnityEngine.GUISkin)vc.csObj;
         var result = _this.verticalSlider;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.GUIStyle arg0  = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.GUISkin  _this = (UnityEngine.GUISkin)vc.csObj;
         _this.verticalSlider = arg0;
     }
 }
Пример #32
0
    static bool GUILayoutUtility_GetRect__Single__Single__Single__Single__GUIStyle(JSVCall vc, int argc)
    {
        int len = argc;

        if (len == 5)
        {
            System.Single        arg0 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single        arg1 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single        arg2 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            System.Single        arg3 = (System.Single)JSApi.getSingle((int)JSApi.GetType.Arg);
            UnityEngine.GUIStyle arg4 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, UnityEngine.GUILayoutUtility.GetRect(arg0, arg1, arg2, arg3, arg4));
        }

        return(true);
    }
 static public int CalcHeight(IntPtr l)
 {
     try {
         UnityEngine.GUIStyle   self = (UnityEngine.GUIStyle)checkSelf(l);
         UnityEngine.GUIContent a1;
         checkType(l, 2, out a1);
         System.Single a2;
         checkType(l, 3, out a2);
         var ret = self.CalcHeight(a1, a2);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #34
0
    static bool GUIStyle_GUIStyle2(JSVCall vc, int argc)
    {
        int _this = JSApi.getObject((int)JSApi.GetType.Arg);

        JSApi.attachFinalizerObject(_this);
        --argc;

        int len = argc;

        if (len == 1)
        {
            UnityEngine.GUIStyle arg0 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.addJSCSRel(_this, new UnityEngine.GUIStyle(arg0));
        }

        return(true);
    }
Пример #35
0
        protected GUIStyle unityStyle(Style style, Style defaultStyle)
        {
            if (style == Style.Default)
            {
                style = defaultStyle;
            }

            UnityEngine.GUIStyle ustyle = AssetBase.unityStyle(style, skin);

            if (!font.isDefault)
            {
                ustyle = new UnityEngine.GUIStyle(ustyle);
                font.apply(ustyle);
            }

            return(ustyle);
        }
Пример #36
0
        /// <summary>
        /// Draws expand (foldout type) button and allows you to set custom button height
        /// [ref override recommended]
        /// </summary>
        public static bool ExpandButton(bool b, string label, int height, U.FontStyle fontStyle = U.FontStyle.Normal)
        {
            bool _b = b;

            Gl.BeginHorizontal();
            U.GUIStyle _style = new U.GUIStyle(G.skin.button);
            _style.fontStyle = fontStyle;
            _style.richText  = true;
            _style.alignment = U.TextAnchor.MiddleLeft;

            if (Gl.Button((b ? "▼ " : "► ") + label, _style, Gl.Height(height)))
            {
                _b = !b;
            }
            Gl.EndHorizontal();
            return(_b);
        }
 static public int CalcMinMaxWidth(IntPtr l)
 {
     try {
         UnityEngine.GUIStyle   self = (UnityEngine.GUIStyle)checkSelf(l);
         UnityEngine.GUIContent a1;
         checkType(l, 2, out a1);
         System.Single a2;
         System.Single a3;
         self.CalcMinMaxWidth(a1, out a2, out a3);
         pushValue(l, true);
         pushValue(l, a2);
         pushValue(l, a3);
         return(3);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #38
0
    static bool GroupScope_GroupScope5(JSVCall vc, int argc)
    {
        int _this = JSApi.getObject((int)JSApi.GetType.Arg);

        JSApi.attachFinalizerObject(_this);
        --argc;

        int len = argc;

        if (len == 2)
        {
            UnityEngine.Rect     arg0 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.GUIStyle arg1 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.addJSCSRel(_this, new UnityEngine.GUI.GroupScope(arg0, arg1));
        }

        return(true);
    }
Пример #39
0
    static bool AreaScope_AreaScope5(JSVCall vc, int argc)
    {
        int _this = JSApi.getObject((int)JSApi.GetType.Arg);

        JSApi.attachFinalizerObject(_this);
        --argc;

        int len = argc;

        if (len == 3)
        {
            UnityEngine.Rect     arg0 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            System.String        arg1 = (System.String)JSApi.getStringS((int)JSApi.GetType.Arg);
            UnityEngine.GUIStyle arg2 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.addJSCSRel(_this, new UnityEngine.GUILayout.AreaScope(arg0, arg1, arg2));
        }

        return(true);
    }
 static public int GetCursorStringIndex(IntPtr l)
 {
     try {
         UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
         UnityEngine.Rect     a1;
         checkValueType(l, 2, out a1);
         UnityEngine.GUIContent a2;
         checkType(l, 3, out a2);
         UnityEngine.Vector2 a3;
         checkType(l, 4, out a3);
         var ret = self.GetCursorStringIndex(a1, a2, a3);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #41
0
        private void PsiPanel(int id)
        {
            // Set box style based on skin
            if (panelSkin != null)
            {
                _boxStyle = panelSkin.box;
            }
            else
            {
                _boxStyle = new GUIStyle();
            }

            GUILayout.BeginVertical();

            this.ShowDemands();
            this.ShowFeelings();

            GUILayout.EndVertical();
        }
 static public int DrawCursor(IntPtr l)
 {
     try {
         UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
         UnityEngine.Rect     a1;
         checkValueType(l, 2, out a1);
         UnityEngine.GUIContent a2;
         checkType(l, 3, out a2);
         System.Int32 a3;
         checkType(l, 4, out a3);
         System.Int32 a4;
         checkType(l, 5, out a4);
         self.DrawCursor(a1, a2, a3, a4);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    static bool ScrollViewScope_ScrollViewScope3(JSVCall vc, int argc)
    {
        int _this = JSApi.getObject((int)JSApi.GetType.Arg);

        JSApi.attachFinalizerObject(_this);
        --argc;

        int len = argc;

        if (len == 5)
        {
            UnityEngine.Rect     arg0 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Vector2  arg1 = (UnityEngine.Vector2)JSApi.getVector2S((int)JSApi.GetType.Arg);
            UnityEngine.Rect     arg2 = (UnityEngine.Rect)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.GUIStyle arg3 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.GUIStyle arg4 = (UnityEngine.GUIStyle)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            JSMgr.addJSCSRel(_this, new UnityEngine.GUI.ScrollViewScope(arg0, arg1, arg2, arg3, arg4));
        }

        return(true);
    }
Пример #44
0
        bool IGUIEditorBase.OnDrawGUI()
        {
            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label);

            style.richText = true;

            var renderersCount = 0;
            var data           = this.target.GetData();

            if (data.arr != null)
            {
                for (int i = 0; i < data.Length; ++i)
                {
                    var views = data.arr[i];
                    renderersCount += views.Length;
                }
            }

            UnityEngine.GUILayout.Label("<b>Alive Views:</b> " + renderersCount.ToString(), style);

            return(false);
        }
Пример #45
0
            /// <summary>
            /// [0.20.0.17] 显示控件的文本提示
            /// </summary>
            public static void ShowTooltip()
            {
                if (string.IsNullOrEmpty(GUI.tooltip))
                {
                    return;
                }
                var tooltip      = new GC(GUI.tooltip);
                var styleRect    = GUI.skin.box;
                var tooltipSize  = styleRect.CalcSize(tooltip);
                var textHeight   = styleRect.CalcHeight(tooltip, tooltipSize.x);
                var styleTooltip = new GS()
                {
                    normal = { background = new Texture2D(1, 1) }
                };

                styleTooltip.normal.background.SetPixels32(new[] { new Color32(0, 0, 0, 220) });
                var x = (WindowSize.x - tooltipSize.x) / 2;
                var y = Screen.height + ScrollViewPosition.y - WindowPosition.y - Input.mousePosition.y - Scale(H1FontSize + GlobalFontSize * 2) - textHeight;

                GUI.Label(new Rect(x, y, tooltipSize.x, tooltipSize.y), GUI.tooltip, styleTooltip);
                //GUI.Label(new Rect(x, y, tooltipSize.x, tooltipSize.y), $"x={x},y={y},sx={ScrollViewPosition.x},sy={ScrollViewPosition.y},my={Input.mousePosition.y},th={textHeight},ry={WindowPosition.y}", styleTooltip);
            }
Пример #46
0
        public Vector2 GetSize(IGuiElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            if (!(element is ITextGuiElement))
            {
                throw new ArgumentException("ExpandText only works on ITextGuiElements", "element");
            }
            if (element.Style == null)
            {
                throw new Exception("ExpandText does not work with the built in unity style");
            }

            ITextGuiElement textElement = (ITextGuiElement)element;

            UnityEngine.GUIStyle unityStyle = textElement.Style.GenerateUnityGuiStyle();

            unityStyle.wordWrap = false;
            GUIContent textContent = new GUIContent(textElement.Text);

            Vector2 size = unityStyle.CalcSize(textContent);

            if (size.x > mLineWrapWidth)
            {
                size.x = mLineWrapWidth;
                unityStyle.wordWrap = true;
                size.y = unityStyle.CalcHeight(textContent, mLineWrapWidth);
            }

            size.x += textElement.Style.InternalMargins.Left + textElement.Style.InternalMargins.Right;
            size.y += textElement.Style.InternalMargins.Top + textElement.Style.InternalMargins.Bottom;

            return(size);
        }
 static public int Draw(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 4)
         {
             UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
             UnityEngine.Rect     a1;
             checkValueType(l, 2, out a1);
             UnityEngine.GUIContent a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             self.Draw(a1, a2, a3);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 5)
         {
             UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
             UnityEngine.Rect     a1;
             checkValueType(l, 2, out a1);
             UnityEngine.GUIContent a2;
             checkType(l, 3, out a2);
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Boolean a4;
             checkType(l, 5, out a4);
             self.Draw(a1, a2, a3, a4);
             pushValue(l, true);
             return(1);
         }
         else if (argc == 6)
         {
             UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
             UnityEngine.Rect     a1;
             checkValueType(l, 2, out a1);
             System.Boolean a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             System.Boolean a4;
             checkType(l, 5, out a4);
             System.Boolean a5;
             checkType(l, 6, out a5);
             self.Draw(a1, a2, a3, a4, a5);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(bool), typeof(bool), typeof(bool), typeof(bool)))
         {
             UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
             UnityEngine.Rect     a1;
             checkValueType(l, 2, out a1);
             UnityEngine.GUIContent a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             System.Boolean a4;
             checkType(l, 5, out a4);
             System.Boolean a5;
             checkType(l, 6, out a5);
             System.Boolean a6;
             checkType(l, 7, out a6);
             self.Draw(a1, a2, a3, a4, a5, a6);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Rect), typeof(string), typeof(bool), typeof(bool), typeof(bool), typeof(bool)))
         {
             UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
             UnityEngine.Rect     a1;
             checkValueType(l, 2, out a1);
             System.String a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             System.Boolean a4;
             checkType(l, 5, out a4);
             System.Boolean a5;
             checkType(l, 6, out a5);
             System.Boolean a6;
             checkType(l, 7, out a6);
             self.Draw(a1, a2, a3, a4, a5, a6);
             pushValue(l, true);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(UnityEngine.Rect), typeof(UnityEngine.Texture), typeof(bool), typeof(bool), typeof(bool), typeof(bool)))
         {
             UnityEngine.GUIStyle self = (UnityEngine.GUIStyle)checkSelf(l);
             UnityEngine.Rect     a1;
             checkValueType(l, 2, out a1);
             UnityEngine.Texture a2;
             checkType(l, 3, out a2);
             System.Boolean a3;
             checkType(l, 4, out a3);
             System.Boolean a4;
             checkType(l, 5, out a4);
             System.Boolean a5;
             checkType(l, 6, out a5);
             System.Boolean a6;
             checkType(l, 7, out a6);
             self.Draw(a1, a2, a3, a4, a5, a6);
             pushValue(l, true);
             return(1);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Пример #48
0
 public static System.Enum EnumFlagsField(UnityEngine.Rect position, UnityEngine.GUIContent label, System.Enum enumValue, UnityEngine.GUIStyle style)
 {
     if (__EnumFlagsField_5_4 == null)
     {
         __EnumFlagsField_5_4 = (Func <UnityEngine.Rect, UnityEngine.GUIContent, System.Enum, UnityEngine.GUIStyle, System.Enum>)Delegate.CreateDelegate(typeof(Func <UnityEngine.Rect, UnityEngine.GUIContent, System.Enum, UnityEngine.GUIStyle, System.Enum>), null, UnityTypes.UnityEditor_EditorGUI.GetMethod("EnumFlagsField", R.StaticMembers, null, new Type[] { typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(System.Enum), typeof(UnityEngine.GUIStyle) }, null));
     }
     return(__EnumFlagsField_5_4(position, label, enumValue, style));
 }
Пример #49
0
 public static System.Enum EnumFlagsField(UnityEngine.Rect position, UnityEngine.GUIContent label, System.Enum enumValue, System.Type enumType, bool includeObsolete, ref int changedFlags, ref bool changedToValue, UnityEngine.GUIStyle style)
 {
     if (__EnumFlagsField_8_8 == null)
     {
         __EnumFlagsField_8_8 = (Method_EnumFlagsField_8_8)Delegate.CreateDelegate(typeof(Method_EnumFlagsField_8_8), null, UnityTypes.UnityEditor_EditorGUI.GetMethod("EnumFlagsField", R.StaticMembers, null, new Type[] { typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(System.Enum), typeof(System.Type), typeof(bool), typeof(int).MakeByRefType(), typeof(bool).MakeByRefType(), typeof(UnityEngine.GUIStyle) }, null));
     }
     return(__EnumFlagsField_8_8(position, label, enumValue, enumType, includeObsolete, ref changedFlags, ref changedToValue, style));
 }
Пример #50
0
 public static int EnumFlagsField(UnityEngine.Rect position, UnityEngine.GUIContent label, int enumValue, System.Type enumType, bool includeObsolete, UnityEngine.GUIStyle style)
 {
     if (__EnumFlagsField_9_6 == null)
     {
         __EnumFlagsField_9_6 = (Func <UnityEngine.Rect, UnityEngine.GUIContent, int, System.Type, bool, UnityEngine.GUIStyle, int>)Delegate.CreateDelegate(typeof(Func <UnityEngine.Rect, UnityEngine.GUIContent, int, System.Type, bool, UnityEngine.GUIStyle, int>), null, UnityTypes.UnityEditor_EditorGUI.GetMethod("EnumFlagsField", R.StaticMembers, null, new Type[] { typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(int), typeof(System.Type), typeof(bool), typeof(UnityEngine.GUIStyle) }, null));
     }
     return(__EnumFlagsField_9_6(position, label, enumValue, enumType, includeObsolete, style));
 }
Пример #51
0
 public static UnityObject DoObjectField(UnityEngine.Rect position, UnityEngine.Rect dropRect, int id, UnityObject obj, UnityObject objBeingEdited, System.Type objType, UnityEditor.SerializedProperty property, object validator, bool allowSceneObjects, UnityEngine.GUIStyle style)
 {
     if (__DoObjectField_3_10 == null)
     {
         __DoObjectField_3_10 = UnityTypes.UnityEditor_EditorGUI.GetMethod("DoObjectField", R.StaticMembers, null, new Type[] { typeof(UnityEngine.Rect), typeof(UnityEngine.Rect), typeof(int), typeof(UnityObject), typeof(UnityObject), typeof(System.Type), typeof(UnityEditor.SerializedProperty), UnityTypes.UnityEditor_EditorGUI_ObjectFieldValidator, typeof(bool), typeof(UnityEngine.GUIStyle) }, null);
     }
     return((UnityObject)__DoObjectField_3_10.Invoke(null, new object[] { position, dropRect, id, obj, objBeingEdited, objType, property, validator, allowSceneObjects, style }));
 }
Пример #52
0
 public static int Popup(UnityEngine.Rect position, UnityEngine.GUIContent label, int selectedIndex, UnityEngine.GUIContent[] displayedOptions, UnityEngine.GUIStyle style)
 {
     if (__Popup_11_5 == null)
     {
         __Popup_11_5 = (Func <UnityEngine.Rect, UnityEngine.GUIContent, int, UnityEngine.GUIContent[], UnityEngine.GUIStyle, int>)Delegate.CreateDelegate(typeof(Func <UnityEngine.Rect, UnityEngine.GUIContent, int, UnityEngine.GUIContent[], UnityEngine.GUIStyle, int>), null, UnityTypes.UnityEditor_EditorGUI.GetMethod("Popup", R.StaticMembers, null, new Type[] { typeof(UnityEngine.Rect), typeof(UnityEngine.GUIContent), typeof(int), typeof(UnityEngine.GUIContent[]), typeof(UnityEngine.GUIStyle) }, null));
     }
     return(__Popup_11_5(position, label, selectedIndex, displayedOptions, style));
 }
Пример #53
0
    public override void OnInspectorGUI()
    {
        // var titleStyle : GUIStyle;
        UnityEngine.GUIStyle titleStyle = new UnityEngine.GUIStyle();
        titleStyle.fontSize = 16;
        UnityEngine.GUIStyle subtitleStyle = new UnityEngine.GUIStyle();
        subtitleStyle.fontSize = 12;

        /* Planet. */
        UnityEditor.EditorGUILayout.LabelField("Planet", titleStyle);
        PropertyField(atmosphereThickness);
        PropertyField(planetRadius);
        PropertyField(groundAlbedoTexture);
        PropertyField(groundTint);
        PropertyField(groundEmissionTexture);
        PropertyField(groundEmissionMultiplier);
        PropertyField(planetRotation);

        /* Night sky. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Night Sky", titleStyle);
        PropertyField(nightSkyTexture);
        PropertyField(nightSkyRotation);
        PropertyField(nightTint);
        PropertyField(nightIntensity);
        PropertyField(lightPollutionTint);
        PropertyField(lightPollutionIntensity);

        /* Aerosols. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Aerosol Layer", titleStyle);
        PropertyField(aerosolCoefficient);
        PropertyField(scaleHeightAerosols);
        PropertyField(aerosolAnisotropy);
        PropertyField(aerosolDensity);

        /* Air. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Air Layer", titleStyle);
        PropertyField(airCoefficients);
        PropertyField(scaleHeightAir);
        PropertyField(airDensity);

        /* Ozone. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Ozone Layer", titleStyle);
        PropertyField(ozoneCoefficients);
        PropertyField(ozoneThickness);
        PropertyField(ozoneHeight);
        PropertyField(ozoneDensity);

        /* Height fog. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Height Fog", titleStyle);
        PropertyField(heightFogCoefficients);
        PropertyField(scaleHeightHeightFog);
        PropertyField(heightFogAnisotropy);
        PropertyField(heightFogDensity);
        PropertyField(heightFogAttenuationDistance);
        PropertyField(heightFogAttenuationBias);
        PropertyField(heightFogTint);

        /* Artistic Overrides. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Artistic Overrides", titleStyle);
        PropertyField(skyTint);
        PropertyField(multipleScatteringMultiplier);

        /* Body 1. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Celestial Bodies", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Celestial Body 1", subtitleStyle);
        PropertyField(body1LimbDarkening);
        PropertyField(body1ReceivesLight);
        PropertyField(body1AlbedoTexture);
        PropertyField(body1Emissive);
        PropertyField(body1EmissionTexture);
        PropertyField(body1Rotation);
        /* Body 2. */
        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Celestial Body 2", subtitleStyle);
        PropertyField(body2LimbDarkening);
        PropertyField(body2ReceivesLight);
        PropertyField(body2AlbedoTexture);
        PropertyField(body2Emissive);
        PropertyField(body2EmissionTexture);
        PropertyField(body2Rotation);
        /* Body 3. */
        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Celestial Body 3", subtitleStyle);
        PropertyField(body3LimbDarkening);
        PropertyField(body3ReceivesLight);
        PropertyField(body3AlbedoTexture);
        PropertyField(body3Emissive);
        PropertyField(body3EmissionTexture);
        PropertyField(body3Rotation);
        /* Body 4. */
        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Celestial Body 4", subtitleStyle);
        PropertyField(body4LimbDarkening);
        PropertyField(body4ReceivesLight);
        PropertyField(body4AlbedoTexture);
        PropertyField(body4Emissive);
        PropertyField(body4EmissionTexture);
        PropertyField(body4Rotation);

        /* Sampling and Rendering. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Sampling and Rendering", titleStyle);
        PropertyField(numberOfTransmittanceSamples);
        PropertyField(numberOfLightPollutionSamples);
        PropertyField(numberOfScatteringSamples);
        PropertyField(numberOfGroundIrradianceSamples);
        PropertyField(numberOfMultipleScatteringSamples);
        PropertyField(numberOfMultipleScatteringAccumulationSamples);
        PropertyField(useImportanceSampling);
        PropertyField(useAntiAliasing);
        PropertyField(ditherAmount);

        /* Clouds. */
        UnityEditor.EditorGUILayout.LabelField("", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("Clouds (Experimental)", titleStyle);
        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Geometry", subtitleStyle);
        PropertyField(cloudVolumeLowerRadialBoundary);
        PropertyField(cloudVolumeUpperRadialBoundary);
        PropertyField(cloudTextureAngularRange);
        PropertyField(cloudUOffset);
        PropertyField(cloudVOffset);
        PropertyField(cloudWOffset);

        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Lighting", subtitleStyle);
        PropertyField(cloudDensity);
        PropertyField(cloudFalloffRadius);
        PropertyField(densityAttenuationThreshold);
        PropertyField(densityAttenuationMultiplier);
        PropertyField(cloudForwardScattering);
        PropertyField(cloudSilverSpread);
        PropertyField(silverIntensity);
        PropertyField(depthProbabilityOffset);
        PropertyField(depthProbabilityMin);
        PropertyField(depthProbabilityMax);
        PropertyField(atmosphericBlendDistance);
        PropertyField(atmosphericBlendBias);

        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Sampling", subtitleStyle);
        PropertyField(numCloudTransmittanceSamples);
        PropertyField(numCloudSSSamples);
        PropertyField(cloudCoarseMarchStepSize);
        PropertyField(cloudDetailMarchStepSize);
        PropertyField(numZeroStepsBeforeCoarseMarch);


        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Noise", subtitleStyle);
        PropertyField(basePerlinOctaves);
        PropertyField(basePerlinOffset);
        PropertyField(basePerlinScaleFactor);
        PropertyField(baseWorleyOctaves);
        PropertyField(baseWorleyScaleFactor);
        PropertyField(baseWorleyBlendFactor);
        PropertyField(structureOctaves);
        PropertyField(structureScaleFactor);
        PropertyField(structureNoiseBlendFactor);
        PropertyField(detailOctaves);
        PropertyField(detailScaleFactor);
        PropertyField(detailNoiseBlendFactor);
        PropertyField(detailNoiseTile);
        PropertyField(heightGradientLowStart);
        PropertyField(heightGradientLowEnd);
        PropertyField(heightGradientHighStart);
        PropertyField(heightGradientHighEnd);
        PropertyField(coverageOctaves);
        PropertyField(coverageOffset);
        PropertyField(coverageScaleFactor);
        PropertyField(coverageBlendFactor);

        UnityEditor.EditorGUILayout.LabelField("", subtitleStyle);
        UnityEditor.EditorGUILayout.LabelField("Debug", subtitleStyle);
        PropertyField(cloudsDebug);

        base.CommonSkySettingsGUI();
    }
		public static bool FoldoutTitlebar( bool foldout, UnityEngine.GUIContent label, bool skipIconSpacing, UnityEngine.GUIStyle baseStyle, UnityEngine.GUIStyle textStyle ) {
			if( __FoldoutTitlebar_1_5 == null ) {
				__FoldoutTitlebar_1_5 = (Func<bool,UnityEngine.GUIContent,bool,UnityEngine.GUIStyle,UnityEngine.GUIStyle, bool>) Delegate.CreateDelegate( typeof( Func<bool,UnityEngine.GUIContent,bool,UnityEngine.GUIStyle,UnityEngine.GUIStyle, bool> ), null, UnityTypes.UnityEditor_EditorGUILayout.GetMethod( "FoldoutTitlebar", R.StaticMembers, null, new Type[]{ typeof( bool ), typeof( UnityEngine.GUIContent ), typeof( bool ), typeof( UnityEngine.GUIStyle ), typeof( UnityEngine.GUIStyle ) }, null ) );
			}
			return __FoldoutTitlebar_1_5( foldout, label, skipIconSpacing, baseStyle, textStyle );
		}
Пример #55
0
        // Build-Compatible GUI Utilities:

        /// <summary>
        /// List GUI drawer utility (Will modify the source list)
        /// </summary>
        public static List <T> ArrayFieldGUI <T>(List <T> list, ArrayFieldOption option = ArrayFieldOption.Default)
        {
            var _listCopy = new List <T>(list);

            U.GUIStyle _style = new U.GUIStyle("Box");

            if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
            {
                Gl.BeginVertical(_style, Gl.ExpandWidth(true));
            }

            var _clearButtonContent  = new U.GUIContent("Clr", "Clear Field");
            var _removeButtonContent = new U.GUIContent("X", "Remove Element");

            for (int i = 0; i < _listCopy.Count; i++)
            {
                if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
                {
                    Gl.BeginHorizontal(_style, Gl.ExpandWidth(true));
                }

                if (!option.ContainsFlag(ArrayFieldOption.NoIndex))
                {
                    Gl.Label(i.ToString(), Gl.ExpandWidth(false));
                }

                Gl.BeginVertical();
                {
                    _listCopy[i] = DrawPropertyField(_listCopy[i]);
                }
                Gl.EndVertical();

                if (!option.ContainsFlag(ArrayFieldOption.NoClearButton))
                {
                    if (Gl.Button(_clearButtonContent, Gl.ExpandWidth(false)))
                    {
                        _listCopy[i] = default(T);
                    }
                }

                if (!option.ContainsFlag(ArrayFieldOption.FixedSize))
                {
                    if (Gl.Button(_removeButtonContent, Gl.ExpandWidth(false)))
                    {
                        _listCopy.Remove(_listCopy[i]);
                        i--;
                    }
                }

                if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
                {
                    Gl.EndHorizontal();
                }
            }

            if (!option.ContainsFlag(ArrayFieldOption.FixedSize))
            {
                if (Gl.Button("Add Element"))
                {
                    _listCopy.Add(default(T));
                }
            }

            if (!option.ContainsFlag(ArrayFieldOption.NoBoundries))
            {
                Gl.EndVertical();
            }

            return(_listCopy);
        }
        bool IGUIEditorBase.OnDrawGUI()
        {
            var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label);

            style.richText = true;

            var dataCount = 0;

            foreach (System.Collections.DictionaryEntry ren in this.target.GetData())
            {
                dataCount += ((ME.ECS.Collections.SortedList <long, HistoryEvent>)ren.Value).Count;
            }

            GUILayoutExt.Box(2f, 2f, () => {
                UnityEngine.GUILayout.Label("<b>Memory Usage:</b> " + ME.ECS.MathUtils.BytesCountToString(WorldEditor.current.stateSize * (this.target.GetCacheSize() / this.target.GetTicksPerState())), style);
                UnityEngine.GUILayout.Label("<b>Events:</b> " + dataCount.ToString(), style);
                UnityEngine.GUILayout.Label("<b>Events Added:</b> " + this.target.GetEventsAddedCount().ToString(), style);
                UnityEngine.GUILayout.Label("<b>Events Played:</b> " + this.target.GetEventsPlayedCount().ToString(), style);
            });

            GUILayoutExt.Separator();
            var val = this.syncTableFoldState;

            GUILayoutExt.FoldOut(ref val, "Sync Table", () => {
                const float padding    = 2f;
                const float margin     = 2f;
                const float col1       = 60f;
                const float col2       = 50f;
                const float col3       = 22f;
                const float cellHeight = 22f;
                var tableStyle         = (GUIStyle)"Box";

                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Tick", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col1),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Player", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col2),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Hash", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.ExpandWidth(true),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption(string.Empty, EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col3),
                                     GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();

                var syncHashTable = this.target.GetSyncHashTable();

                /*if (syncHashTable.ContainsKey(20) == false) syncHashTable.Add(20, new System.Collections.Generic.Dictionary<int, int>() {
                 *  { 100, 1234 }
                 * });
                 * if (syncHashTable.ContainsKey(100) == false) syncHashTable.Add(100, new System.Collections.Generic.Dictionary<int, int>() {
                 *  { 100, 1902832914 },
                 *  { 101, 1902832914 },
                 *  { 102, 1902832915 },
                 * });
                 * if (syncHashTable.ContainsKey(2000) == false) syncHashTable.Add(2000, new System.Collections.Generic.Dictionary<int, int>() {
                 *  { 100, 2345 }
                 * });*/
                foreach (var item in syncHashTable)
                {
                    var tick      = item.Key;
                    int localHash = 0;

                    GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.DataLabel(tick.ToString(), GUILayout.Width(col1));
                    }
                    GUILayout.EndHorizontal();
                    var stateHashResult = 0;
                    foreach (var kv in item.Value)
                    {
                        var hash = kv.Value;
                        if (localHash != 0 && localHash != hash)
                        {
                            stateHashResult = -1;
                            break;
                        }
                        else if (localHash != 0)
                        {
                            stateHashResult = 1;
                        }
                        localHash = hash;
                    }

                    foreach (var kv in item.Value)
                    {
                        var playerId = kv.Key;
                        GUILayout.BeginHorizontal();
                        {
                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(string.Empty); }, tableStyle, GUILayout.Width(col1), GUILayout.Height(cellHeight));
                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(playerId.ToString()); }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                            GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(kv.Value.ToString()); }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                            GUILayoutExt.Box(padding, margin, () => {
                                GUILayout.BeginHorizontal();
                                GUILayout.FlexibleSpace();

                                if (stateHashResult == 1)
                                {
                                    using (new GUILayoutExt.GUIColorUsing(Color.green)) {
                                        GUILayout.Toggle(true, new GUIContent(string.Empty, $"Local hash synced with player #{playerId}."), StatesHistoryModuleEditor.syncBoxStyle);
                                    }
                                }
                                else if (stateHashResult == -1)
                                {
                                    using (new GUILayoutExt.GUIColorUsing(Color.red)) {
                                        GUILayout.Toggle(true, new GUIContent(string.Empty, $"Local hash is not the same as player #{playerId} has, your server must resync that player."), StatesHistoryModuleEditor.syncBoxStyle);
                                    }
                                }
                                else
                                {
                                    using (new GUILayoutExt.GUIColorUsing(Color.yellow)) {
                                        GUILayout.Toggle(false, new GUIContent(string.Empty, $"Local hash is not sync yet with player #{playerId}, current tick is less than remote."), StatesHistoryModuleEditor.syncBoxStyle);
                                    }
                                }

                                GUILayout.FlexibleSpace();
                                GUILayout.EndHorizontal();
                            }, tableStyle, GUILayout.Width(col3), GUILayout.Height(cellHeight));
                        }
                        GUILayout.EndHorizontal();
                    }
                }
            });
            this.syncTableFoldState = val;

            GUILayoutExt.Separator();
            val = this.statesHistoryFoldState;
            GUILayoutExt.FoldOut(ref val, "States History", () => {
                var padding    = 2f;
                var margin     = 2f;
                var col1       = 60f;
                var col2       = 70f;
                var cellHeight = 22f;
                var tableStyle = (GUIStyle)"Box";

                UnityEngine.GUILayout.BeginHorizontal();
                {
                    if (UnityEngine.GUILayout.Button("Entities", UnityEditor.EditorStyles.miniButtonLeft) == true)
                    {
                        var world = Worlds.currentWorld;
                        this.PrintEntities(world.currentState);
                    }

                    if (UnityEngine.GUILayout.Button("Events", UnityEditor.EditorStyles.miniButtonMid) == true)
                    {
                        foreach (System.Collections.DictionaryEntry ren in this.target.GetData())
                        {
                            var entry = (ME.ECS.Collections.SortedList <long, HistoryEvent>)ren.Value;
                            for (int i = 0; i < entry.Count; ++i)
                            {
                                UnityEngine.Debug.Log(entry.GetByIndex(i).ToString());
                            }
                        }
                    }

                    if (UnityEngine.GUILayout.Button("Reset State", UnityEditor.EditorStyles.miniButtonRight) == true)
                    {
                        this.target.RecalculateFromResetState();
                    }
                }
                UnityEngine.GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Tick", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col1),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Hash", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.ExpandWidth(true),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Actions", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col2),
                                     GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();

                var dataStates = this.target.GetDataStates();
                var entries    = dataStates.GetEntries();
                foreach (var entryData in entries)
                {
                    var entry = entryData as ME.ECS.Network.IStatesHistoryEntry;
                    var state = entry.GetData() as State;
                    UnityEngine.GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(entry.isEmpty == true ? "-" : state.tick.ToString()); }, tableStyle, GUILayout.Width(col1), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(entry.isEmpty == true ? "-" : state.GetHash().ToString()); }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => {
                            EditorGUI.BeginDisabledGroup(entry.isEmpty == true);
                            if (UnityEngine.GUILayout.Button("Entities") == true)
                            {
                                this.PrintEntities(state);
                            }
                            EditorGUI.EndDisabledGroup();
                        }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                    }
                    UnityEngine.GUILayout.EndHorizontal();
                }
            });
            this.statesHistoryFoldState = val;
            GUILayoutExt.Separator();

            GUILayoutExt.Separator();
            val = this.eventsFoldState;
            GUILayoutExt.FoldOut(ref val, "Events Table", () => {
                const float padding    = 2f;
                const float margin     = 2f;
                const float col1       = 60f;
                const float col2       = 50f;
                const float cellHeight = 22f;
                var tableStyle         = (GUIStyle)"Box";

                GUILayout.BeginHorizontal();
                {
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Tick", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col1),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Player", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.Width(col2),
                                     GUILayout.Height(cellHeight));
                    GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.TableCaption("Rpc ID", EditorStyles.miniBoldLabel); }, tableStyle,
                                     GUILayout.ExpandWidth(true),
                                     GUILayout.Height(cellHeight));
                }
                GUILayout.EndHorizontal();

                var events = this.target.GetEvents();
                foreach (var item in events)
                {
                    var tick = item.tick;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.DataLabel(tick.ToString(), GUILayout.Width(col1));
                    }
                    GUILayout.EndHorizontal();

                    var playerId = item.order;
                    GUILayout.BeginHorizontal();
                    {
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(tick.ToString()); }, tableStyle, GUILayout.Width(col1), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(playerId.ToString()); }, tableStyle, GUILayout.Width(col2), GUILayout.Height(cellHeight));
                        GUILayoutExt.Box(padding, margin, () => { GUILayoutExt.DataLabel(item.rpcId.ToString()); }, tableStyle, GUILayout.ExpandWidth(true), GUILayout.Height(cellHeight));
                    }
                    GUILayout.EndHorizontal();
                }
            });
            this.eventsFoldState = val;

            return(false);
        }
Пример #57
0
        private static int GUI_SetFont(UE.GUIStyle style, Font font)
        {
            int guiSkinFontSizeBuffer = style.fontSize;

            if (font != null)
            {
                if (font.fontObject == null && Unity.API.UnityWinForms.gResources != null)
                {
                    var fonts = Unity.API.UnityWinForms.gResources.Fonts;
                    if (fonts != null)
                    {
                        for (int i = 0; i < fonts.Count; i++)
                        {
                            var fontItem = fonts[i];
                            if (fontItem.fontNames[0] != font.Name)
                            {
                                continue;
                            }

                            font.fontObject = fontItem;
                            break;
                        }
                    }
                }

                if (font.fontObject != null)
                {
                    style.font = (UE.Font)font.fontObject;
                }
                else
                {
                    style.font = null;
#if UNITY_EDITOR
                    UnityEngine.Debug.LogError("Font not found: " + font.Name);
#endif
                }

                var fontStyle = font.Style;
                style.fontSize = (int)font.Size;
                bool styleBold   = (fontStyle & FontStyle.Bold) == FontStyle.Bold;
                bool styleItalic = (fontStyle & FontStyle.Italic) == FontStyle.Italic;
                if (styleBold)
                {
                    if (styleItalic)
                    {
                        style.fontStyle = UnityEngine.FontStyle.BoldAndItalic;
                    }
                    else
                    {
                        style.fontStyle = UnityEngine.FontStyle.Bold;
                    }
                }
                else if (styleItalic)
                {
                    style.fontStyle = UnityEngine.FontStyle.Italic;
                }
                else
                {
                    style.fontStyle = UnityEngine.FontStyle.Normal;
                }
            }
            else
            {
                if (UnityWinForms.gResources.Fonts.Count > 0)
                {
                    var _font = UnityWinForms.gResources.Fonts[0];
                    if (_font != null)
                    {
                        style.font = _font;
                    }
                    style.fontSize  = 12;
                    style.fontStyle = UnityEngine.FontStyle.Normal;
                }
            }
            return(guiSkinFontSizeBuffer);
        }
        public static void Draw()
        {
            pbarBgStyle = PlayFabEditorHelper.uiStyle.GetStyle("progressBarBg");
            if (currentProgressBarState == ProgressBarStates.off)
            {
                stTime         = 0;
                endTime        = 0;
                progressWidth  = 0;
                lastUpdateTime = 0;
                isReveresed    = false;

                progressWidth = EditorGUIUtility.currentViewWidth;
                pbarStyle     = PlayFabEditorHelper.uiStyle.GetStyle("progressBarClear");
                pbarBgStyle   = PlayFabEditorHelper.uiStyle.GetStyle("progressBarClear");
                //return;
            }
            else if (EditorWindow.focusedWindow != PlayFabEditor.window)
            {
                // pause draw while we are in the bg
                return;
            }
            else if (currentProgressBarState == ProgressBarStates.success)
            {
                if ((float)EditorApplication.timeSinceStartup - stTime < animationSpeed)
                {
                    progressWidth = EditorGUIUtility.currentViewWidth;
                    pbarStyle     = PlayFabEditorHelper.uiStyle.GetStyle("progressBarSuccess");
                }
                else if (PlayFabEditor.blockingRequests.Count > 0)
                {
                    UpdateState(ProgressBarStates.spin);
                }
                else
                {
                    UpdateState(ProgressBarStates.off);
                }
            }
            else if (currentProgressBarState == ProgressBarStates.warning)
            {
                if ((float)EditorApplication.timeSinceStartup - stTime < animationSpeed)
                {
                    progressWidth = EditorGUIUtility.currentViewWidth;
                    pbarStyle     = PlayFabEditorHelper.uiStyle.GetStyle("progressBarWarn");
                }
                else if (PlayFabEditor.blockingRequests.Count > 0)
                {
                    UpdateState(ProgressBarStates.spin);
                }
                else
                {
                    UpdateState(ProgressBarStates.off);
                }
            }
            else if (currentProgressBarState == ProgressBarStates.error)
            {
                if ((float)EditorApplication.timeSinceStartup - stTime < animationSpeed)
                {
                    progressWidth = EditorGUIUtility.currentViewWidth;
                    pbarStyle     = PlayFabEditorHelper.uiStyle.GetStyle("progressBarError");
                }
                else if (PlayFabEditor.blockingRequests.Count > 0)
                {
                    UpdateState(ProgressBarStates.spin);
                }
                else
                {
                    UpdateState(ProgressBarStates.off);
                }
            }
            else
            {
                if ((float)EditorApplication.timeSinceStartup - lastUpdateTime > tickRate)
                {
                    lastUpdateTime = (float)EditorApplication.timeSinceStartup;
                    pbarStyle      = PlayFabEditorHelper.uiStyle.GetStyle("progressBarFg");

                    if (currentProgressBarState == ProgressBarStates.on)
                    {
                        progressWidth = EditorGUIUtility.currentViewWidth * progress;
                    }
                    else if (currentProgressBarState == ProgressBarStates.spin)
                    {
                        var currentTime = (float)EditorApplication.timeSinceStartup;
                        if (currentTime < endTime && !isReveresed)
                        {
                            UpdateProgress((currentTime - stTime) / animationSpeed);
                            progressWidth = EditorGUIUtility.currentViewWidth * progress;
                        }
                        else if (currentTime < endTime && isReveresed)
                        {
                            UpdateProgress((currentTime - stTime) / animationSpeed);
                            progressWidth = EditorGUIUtility.currentViewWidth - EditorGUIUtility.currentViewWidth * progress;
                        }
                        else
                        {
                            isReveresed = !isReveresed;
                            stTime      = (float)EditorApplication.timeSinceStartup;
                            endTime     = stTime + animationSpeed;
                        }
                    }
                }
            }

            GUILayout.BeginHorizontal(pbarBgStyle);
            if (isReveresed)
            {
                GUILayout.FlexibleSpace();
            }
            GUILayout.Label("", pbarStyle, GUILayout.Width(progressWidth));
            GUILayout.EndHorizontal();
        }
Пример #59
0
    private void DisplayTestGui(System.Collections.Generic.List <MyTest> tests)
    {
        UnityEditor.EditorGUILayout.LabelField("Test", UnityEditor.EditorStyles.boldLabel);
        UnityEditor.EditorGUILayout.BeginHorizontal();
        UnityEditor.EditorGUILayout.LabelField("Display test class name: ");
        EditorConfiguration.testPathDisplayed = UnityEditor.EditorGUILayout.Toggle(EditorConfiguration.testPathDisplayed);
        UnityEditor.EditorGUILayout.EndHorizontal();
        UnityEditor.EditorGUILayout.BeginVertical(UnityEngine.GUI.skin.textArea);

        int foldOutCounter = 0;

        foreach (var test in tests)
        {
            if (foldOutCounter > 0)
            {
                foldOutCounter--;
                continue;
            }

            if (tests.IndexOf(test) == selectedTest)
            {
                UnityEngine.GUIStyle gsAlterQuest = new UnityEngine.GUIStyle();
                gsAlterQuest.normal.background = MakeTexture(20, 20, selectedTestColor);
                UnityEditor.EditorGUILayout.BeginHorizontal(gsAlterQuest);
            }
            else
            {
                UnityEditor.EditorGUILayout.BeginHorizontal();
            }

            if (test.Type == typeof(NUnit.Framework.Internal.TestFixture))
            {
                UnityEditor.EditorGUILayout.LabelField("    ", UnityEngine.GUILayout.Width(30));
            }
            else if (test.Type == typeof(NUnit.Framework.Internal.TestMethod))
            {
                UnityEditor.EditorGUILayout.LabelField("    ", UnityEngine.GUILayout.Width(60));
            }

            var valueChanged = UnityEditor.EditorGUILayout.Toggle(test.Selected, UnityEngine.GUILayout.Width(10));
            if (valueChanged != test.Selected)
            {
                test.Selected = valueChanged;
                ChangeSelectionChildsAndParent(test);
            }

            var testName = test.TestName;
            if (!EditorConfiguration.testPathDisplayed)
            {
                if (test.ParentName == "")
                {
                    var splitedPath = testName.Split('/');
                    testName = splitedPath[splitedPath.Length - 1];
                }
                else
                {
                    var splitedPath = testName.Split('.');
                    testName = splitedPath[splitedPath.Length - 1];
                }
            }
            if (test.Status == 0)
            {
                var style = new UnityEngine.GUIStyle(UnityEngine.GUI.skin.label)
                {
                    alignment = UnityEngine.TextAnchor.MiddleLeft
                };
                UnityEditor.EditorGUILayout.LabelField(testName, style);
            }
            else
            {
                UnityEngine.Color     color = redColor;
                UnityEngine.Texture2D icon  = failIcon;
                if (test.Status == 1)
                {
                    color = greenColor;
                    icon  = passIcon;
                }
                UnityEngine.GUILayout.Label(icon, UnityEngine.GUILayout.Width(30));
                UnityEngine.GUIStyle guiStyle = new UnityEngine.GUIStyle {
                    normal = { textColor = color }
                };

                UnityEditor.EditorGUILayout.LabelField(testName, guiStyle, UnityEngine.GUILayout.ExpandWidth(true));
            }

            if (test.Type != typeof(NUnit.Framework.Internal.TestMethod))
            {
                test.FoldOut = UnityEditor.EditorGUILayout.Foldout(test.FoldOut, "");
                if (!test.FoldOut)
                {
                    if (test.Type == typeof(NUnit.Framework.Internal.TestAssembly))
                    {
                        foldOutCounter = tests.Count - 1;
                    }
                    else
                    {
                        foldOutCounter = test.TestCaseCount;
                    }
                }
            }

            if (!test.IsSuite)
            {
                if (UnityEngine.GUILayout.Button("Info", UnityEngine.GUILayout.Width(50)))
                {
                    selectedTest = tests.IndexOf(test);
                }
            }
            else
            {
                UnityEngine.GUILayout.Label("", new UnityEngine.GUIStyle {
                    stretchWidth = true
                });
            }
            UnityEditor.EditorGUILayout.EndHorizontal();
        }
        UnityEditor.EditorGUILayout.EndVertical();
    }
Пример #60
0
        public TextBubble(IGuiManager guiManager, string text, Transform worldPointToFollow, Camera camera)
        {
            mTweakablesHandler = new TweakablesHandler(mTweakablesPath, this);
            IgnoreUnusedVariableWarning(mTweakablesHandler);

            if (guiManager == null)
            {
                throw new ArgumentNullException("guiManager");
            }
            mGuiManager = guiManager;
            XmlGuiFactory loadTextBubble = new XmlGuiFactory(mResourcePath, guiManager);
            IGuiStyle     bubbleStyle    = null;
            IGuiStyle     textStyle      = null;

            foreach (IGuiStyle style in loadTextBubble.ConstructAllStyles())
            {
                if (style == null)
                {
                    continue;
                }
                if (style.Name == "TextBubbleStyleWindow")
                {
                    bubbleStyle = style;
                }
                else if (style.Name == "TextBubbleStyleBase")
                {
                    textStyle = style;
                }
            }

            if (bubbleStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            if (textStyle == null)
            {
                throw new Exception("Unable to load TextBubbleStyleBase from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            foreach (IGuiElement element in loadTextBubble.ConstructAllElements())
            {
                if (element is Window && element.Name == "TextBubbleWindow")
                {
                    mBubbleWindow = (Window)element;
                }
            }

            if (mBubbleWindow == null)
            {
                throw new Exception("Unable to load TextBubbleWindow from xml file at 'Resources/" + mResourcePath + ".xml'");
            }

            mFollowWorldSpaceObject = new FollowWorldSpaceObject
                                      (
                camera,
                worldPointToFollow,
                GuiAnchor.BottomLeft,
                new Vector2(0.0f, 0),                                // SDN: TODO:  make these offsets configurable
                new Vector3(0.0f, 1.8f, 0.0f)
                                      );

            guiManager.SetTopLevelPosition
            (
                mBubbleWindow,
                mFollowWorldSpaceObject
            );

            Textbox bubbleText = mBubbleWindow.SelectSingleElement <Textbox>("**/TextBubbleTextbox");

            mBubbleWindow.Style = bubbleStyle;
            bubbleText.Text     = text;

            Image    bubbleImage = mBubbleWindow.SelectSingleElement <Image>("**/TextBubbleImage");
            GuiFrame mainFrame   = mBubbleWindow.SelectSingleElement <GuiFrame>("**/TextBubbleFrame");

            mainFrame.RemoveChildWidget(bubbleImage);

            // Set the size of the window to be the smallest that draws the entire chat message
            UnityEngine.GUIStyle unityStyle = bubbleText.Style.GenerateUnityGuiStyle();
            unityStyle.wordWrap = false;
            GUIContent textContent = new GUIContent(text);

            Vector2 size = unityStyle.CalcSize(textContent);

            if (size.x > mMaxWidth)
            {
                size.x = mMaxWidth;
                unityStyle.wordWrap = true;
                size.y = unityStyle.CalcHeight(textContent, mMaxWidth);
            }
            if (size.x < mMinWidth)
            {
                size.x = mMinWidth;
            }
            size.x += mBubbleWindow.Style.InternalMargins.Left + mBubbleWindow.Style.InternalMargins.Right;
            size.y += mBubbleWindow.Style.InternalMargins.Top + mBubbleWindow.Style.InternalMargins.Bottom;

            mBubbleWindow.GuiSize = new FixedSize(size);
        }