UnityEngine.GUILayout.EndHorizontal()

Here are the examples of the csharp api UnityEngine.GUILayout.EndHorizontal() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

906 Examples 7

19 View Source File : WebSocketSample.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
    {
        GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                    GUILayout.Label(Text);
                GUILayout.EndScrollView();

                GUILayout.Space(5);

                GUILayout.FlexibleSpace();

                address = GUILayout.TextField(address);

                if (webSocket == null && GUILayout.Button("Open Web Socket"))
                {
                    // Create the WebSocket instance
                    webSocket = new WebSocket(new Uri(address));

#if !UNITY_WEBGL
                    webSocket.StartPingThread = true;

#if !BESTHTTP_DISABLE_PROXY
                    if (HTTPManager.Proxy != null)
                        webSocket.InternalRequest.Proxy = new HTTPProxy(HTTPManager.Proxy.Address, HTTPManager.Proxy.Credentials, false);
#endif
#endif

                    // Subscribe to the WS events
                    webSocket.OnOpen += OnOpen;
                    webSocket.OnMessage += OnMessageReceived;
                    webSocket.OnClosed += OnClosed;
                    webSocket.OnError += OnError;

                    // Start connecting to the server
                    webSocket.Open();

                    Text += "Opening Web Socket...\n";
                }

                if (webSocket != null && webSocket.IsOpen)
                {
                    GUILayout.Space(10);

                    GUILayout.BeginHorizontal();
                        msgToSend = GUILayout.TextField(msgToSend);

                        if (GUILayout.Button("Send", GUILayout.MaxWidth(70)))
                        {
                            Text += "Sending message...\n";

                            // Send message to the server
                            webSocket.Send(msgToSend);
                        }
                    GUILayout.EndHorizontal();

                    GUILayout.Space(10);

                    if (GUILayout.Button("Close"))
                    {
                        // Close the connection
                        webSocket.Close(1000, "Bye!");
                    }
                }
            });
    }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

override public void OnInspectorGUI()
        {
        	base.OnInspectorGUI();

            GUILayout.Space(3);
            EditorGUIUtils.SetGUIStyles();

            bool playMode = Application.isPlaying;
            _runtimeEditMode = _runtimeEditMode && playMode;

            GUILayout.BeginHorizontal();
            EditorGUIUtils.InspectorLogo();
            GUILayout.Label(_src.animationType.ToString() + (string.IsNullOrEmpty(_src.id) ? "" : " [" + _src.id + "]"), EditorGUIUtils.sideLogoIconBoldLabelStyle);
            // Up-down buttons
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("▲", DeGUI.styles.button.toolIco)) UnityEditorInternal.ComponentUtility.MoveComponentUp(_src);
            if (GUILayout.Button("▼", DeGUI.styles.button.toolIco)) UnityEditorInternal.ComponentUtility.MoveComponentDown(_src);
            GUILayout.EndHorizontal();

            if (playMode) {
                if (_runtimeEditMode) {
                    
                } else {
                    GUILayout.Space(8);
                    GUILayout.Label("Animation Editor disabled while in play mode", EditorGUIUtils.wordWrapLabelStyle);
                    if (!_src.isActive) {
                        GUILayout.Label("This animation has been toggled as inactive and won't be generated", EditorGUIUtils.wordWrapLabelStyle);
                        GUI.enabled = false;
                    }
                    if (GUILayout.Button(new GUIContent("Activate Edit Mode", "Switches to Runtime Edit Mode, where you can change animations values and restart them"))) {
                        _runtimeEditMode = true;
                    }
                    GUILayout.Label("NOTE: when using DOPlayNext, the sequence is determined by the DOTweenAnimation Components order in the target GameObject's Inspector", EditorGUIUtils.wordWrapLabelStyle);
                    GUILayout.Space(10);
                    if (!_runtimeEditMode) return;
                }
            }

            Undo.RecordObject(_src, "DOTween Animation");

//            _src.isValid = Validate(); // Moved down

            EditorGUIUtility.labelWidth = 110;

            if (playMode) {
                GUILayout.Space(4);
                DeGUILayout.Toolbar("Edit Mode Commands");
                DeGUILayout.BeginVBox(DeGUI.styles.box.stickyTop);
                    GUILayout.BeginHorizontal();
                    if (GUILayout.Button("TogglePause")) _src.tween.TogglePause();
                    if (GUILayout.Button("Rewind")) _src.tween.Rewind();
                    if (GUILayout.Button("Restart")) _src.tween.Restart();
                    GUILayout.EndHorizontal();
                    if (GUILayout.Button("Commit changes and restart")) {
                        _src.tween.Rewind();
                        _src.tween.Kill();
                        if (_src.isValid) {
                            _src.CreateTween();
                            _src.tween.Play();
                        }
                    }
                    GUILayout.Label("To apply your changes when exiting Play mode, use the Component's upper right menu and choose \"Copy Component\", then \"Paste Component Values\" after exiting Play mode", DeGUI.styles.label.wordwrap);
                DeGUILayout.EndVBox();
            } else {
                bool hasManager = _src.GetComponent<DOTweenVisualManager>() != null;
                if (!hasManager) {
                    if (GUILayout.Button(new GUIContent("Add Manager", "Adds a manager component which allows you to choose additional options for this gameObject"))) {
                        _src.gameObject.AddComponent<DOTweenVisualManager>();
                    }
                }
            }

            GUILayout.BeginHorizontal();
                DOTweenAnimationType prevAnimType = _src.animationType;
//                _src.animationType = (DOTweenAnimationType)EditorGUILayout.EnumPopup(_src.animationType, EditorGUIUtils.popupButton);
                _src.isActive = EditorGUILayout.Toggle(new GUIContent("", "If unchecked, this animation will not be created"), _src.isActive, GUILayout.Width(16));
                GUI.enabled = _src.isActive;
                _src.animationType = AnimationToDOTweenAnimationType(_AnimationType[EditorGUILayout.Popup(DOTweenAnimationTypeToPopupId(_src.animationType), _AnimationType)]);
                _src.autoPlay = DeGUILayout.ToggleButton(_src.autoPlay, new GUIContent("AutoPlay", "If selected, the tween will play automatically"));
                _src.autoKill = DeGUILayout.ToggleButton(_src.autoKill, new GUIContent("AutoKill", "If selected, the tween will be killed when it completes, and won't be reusable"));
            GUILayout.EndHorizontal();
            if (prevAnimType != _src.animationType) {
                // Set default optional values based on animation type
                _src.endValueTransform = null;
                _src.useTargetAsV3 = false;
                switch (_src.animationType) {
                case DOTweenAnimationType.Move:
                case DOTweenAnimationType.LocalMove:
                case DOTweenAnimationType.Rotate:
                case DOTweenAnimationType.LocalRotate:
                case DOTweenAnimationType.Scale:
                    _src.endValueV3 = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.Scale;
                    break;
                case DOTweenAnimationType.UIWidthHeight:
                    _src.endValueV3 = Vector3.zero;
                    _src.endValueFloat = 0;
                    _src.optionalBool0 = _src.animationType == DOTweenAnimationType.UIWidthHeight;
                    break;
                case DOTweenAnimationType.Color:
                case DOTweenAnimationType.Fade:
                    _isLightSrc = _src.GetComponent<Light>() != null;
                    _src.endValueFloat = 0;
                    break;
                case DOTweenAnimationType.Text:
                    _src.optionalBool0 = true;
                    break;
                case DOTweenAnimationType.PunchPosition:
                case DOTweenAnimationType.PunchRotation:
                case DOTweenAnimationType.PunchScale:
                    _src.endValueV3 = _src.animationType == DOTweenAnimationType.PunchRotation ? new Vector3(0,180,0) : Vector3.one;
                    _src.optionalFloat0 = 1;
                    _src.optionalInt0 = 10;
                    _src.optionalBool0 = false;
                    break;
                case DOTweenAnimationType.ShakePosition:
                case DOTweenAnimationType.ShakeRotation:
                case DOTweenAnimationType.ShakeScale:
                    _src.endValueV3 = _src.animationType == DOTweenAnimationType.ShakeRotation ? new Vector3(90,90,90) : Vector3.one;
                    _src.optionalInt0 = 10;
                    _src.optionalFloat0 = 90;
                    _src.optionalBool0 = false;
                    break;
                case DOTweenAnimationType.CameraAspect:
                case DOTweenAnimationType.CameraFieldOfView:
                case DOTweenAnimationType.CameraOrthoSize:
                    _src.endValueFloat = 0;
                    break;
                case DOTweenAnimationType.CameraPixelRect:
                case DOTweenAnimationType.CameraRect:
                    _src.endValueRect = new Rect(0, 0, 0, 0);
                    break;
                }
            }
            if (_src.animationType == DOTweenAnimationType.None) {
                _src.isValid = false;
                if (GUI.changed) EditorUtility.SetDirty(_src);
                return;
            }

            if (prevAnimType != _src.animationType || ComponentsChanged()) {
                _src.isValid = Validate();
                // See if we need to choose between multiple targets
                if (_src.animationType == DOTweenAnimationType.Fade && _src.GetComponent<CanvasGroup>() != null && _src.GetComponent<Image>() != null) {
                    _chooseTargetMode = ChooseTargetMode.BetweenCanvasGroupAndImage;
                    // Rereplacedign target and forcedTargetType if lost
                    if (_src.forcedTargetType == TargetType.Unset) _src.forcedTargetType = _src.targetType;
                    switch (_src.forcedTargetType) {
                    case TargetType.CanvasGroup:
                        _src.target = _src.GetComponent<CanvasGroup>();
                        break;
                    case TargetType.Image:
                        _src.target = _src.GetComponent<Image>();
                        break;
                    }
                } else {
                    _chooseTargetMode = ChooseTargetMode.None;
                    _src.forcedTargetType = TargetType.Unset;
                }
            }

            if (!_src.isValid) {
                GUI.color = Color.red;
                GUILayout.BeginVertical(GUI.skin.box);
                GUILayout.Label("No valid Component was found for the selected animation", EditorGUIUtils.wordWrapLabelStyle);
                GUILayout.EndVertical();
                GUI.color = Color.white;
                if (GUI.changed) EditorUtility.SetDirty(_src);
                return;
            }

            // Special cases in which multiple target types could be used (set after validation)
            if (_chooseTargetMode == ChooseTargetMode.BetweenCanvasGroupAndImage && _src.forcedTargetType != TargetType.Unset) {
                FadeTargetType fadeTargetType = (FadeTargetType)Enum.Parse(typeof(FadeTargetType), _src.forcedTargetType.ToString());
                TargetType prevTargetType = _src.forcedTargetType;
                _src.forcedTargetType = (TargetType)Enum.Parse(typeof(TargetType), EditorGUILayout.EnumPopup(_src.animationType + " Target", fadeTargetType).ToString());
                if (_src.forcedTargetType != prevTargetType) {
                    // Target type change > replacedign correct target
                    switch (_src.forcedTargetType) {
                    case TargetType.CanvasGroup:
                        _src.target = _src.GetComponent<CanvasGroup>();
                        break;
                    case TargetType.Image:
                        _src.target = _src.GetComponent<Image>();
                        break;
                    }
                }
            }

            GUILayout.BeginHorizontal();
            _src.duration = EditorGUILayout.FloatField("Duration", _src.duration);
            if (_src.duration < 0) _src.duration = 0;
            _src.isSpeedBased = DeGUILayout.ToggleButton(_src.isSpeedBased, new GUIContent("SpeedBased", "If selected, the duration will count as units/degree x second"), DeGUI.styles.button.tool, GUILayout.Width(75));
            GUILayout.EndHorizontal();
            _src.delay = EditorGUILayout.FloatField("Delay", _src.delay);
            if (_src.delay < 0) _src.delay = 0;
            _src.isIndependentUpdate = EditorGUILayout.Toggle("Ignore TimeScale", _src.isIndependentUpdate);
            _src.easeType = EditorGUIUtils.FilteredEasePopup(_src.easeType);
            if (_src.easeType == Ease.INTERNAL_Custom) {
                _src.easeCurve = EditorGUILayout.CurveField("   Ease Curve", _src.easeCurve);
            }
            _src.loops = EditorGUILayout.IntField(new GUIContent("Loops", "Set to -1 for infinite loops"), _src.loops);
            if (_src.loops < -1) _src.loops = -1;
            if (_src.loops > 1 || _src.loops == -1)
                _src.loopType = (LoopType)EditorGUILayout.EnumPopup("   Loop Type", _src.loopType);
            _src.id = EditorGUILayout.TextField("ID", _src.id);

            bool canBeRelative = true;
            // End value and eventual specific options
            switch (_src.animationType) {
            case DOTweenAnimationType.Move:
            case DOTweenAnimationType.LocalMove:
                GUIEndValueV3(_src.animationType == DOTweenAnimationType.Move);
                _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                canBeRelative = !_src.useTargetAsV3;
                break;
            case DOTweenAnimationType.Rotate:
            case DOTweenAnimationType.LocalRotate:
                if (_src.GetComponent<Rigidbody2D>()) GUIEndValueFloat();
                else {
                    GUIEndValueV3();
                    _src.optionalRotationMode = (RotateMode)EditorGUILayout.EnumPopup("    Rotation Mode", _src.optionalRotationMode);
                }
                break;
            case DOTweenAnimationType.Scale:
                if (_src.optionalBool0) GUIEndValueFloat();
                else GUIEndValueV3();
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;
            case DOTweenAnimationType.UIWidthHeight:
                if (_src.optionalBool0) GUIEndValueFloat();
                else GUIEndValueV2();
                _src.optionalBool0 = EditorGUILayout.Toggle("Uniform Scale", _src.optionalBool0);
                break;
            case DOTweenAnimationType.Color:
                GUIEndValueColor();
                canBeRelative = false;
                break;
            case DOTweenAnimationType.Fade:
                GUIEndValueFloat();
                if (_src.endValueFloat < 0) _src.endValueFloat = 0;
                if (!_isLightSrc && _src.endValueFloat > 1) _src.endValueFloat = 1;
                canBeRelative = false;
                break;
            case DOTweenAnimationType.Text:
                GUIEndValueString();
                _src.optionalBool0 = EditorGUILayout.Toggle("Rich Text Enabled", _src.optionalBool0);
                _src.optionalScrambleMode = (ScrambleMode)EditorGUILayout.EnumPopup("Scramble Mode", _src.optionalScrambleMode);
                _src.optionalString = EditorGUILayout.TextField(new GUIContent("Custom Scramble", "Custom characters to use in case of ScrambleMode.Custom"), _src.optionalString);
                break;
            case DOTweenAnimationType.PunchPosition:
            case DOTweenAnimationType.PunchRotation:
            case DOTweenAnimationType.PunchScale:
                GUIEndValueV3();
                canBeRelative = false;
                _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the punch vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Elasticity", "How much the vector will go beyond the starting position when bouncing backwards"), _src.optionalFloat0, 0, 1);
                if (_src.animationType == DOTweenAnimationType.PunchPosition) _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                break;
            case DOTweenAnimationType.ShakePosition:
            case DOTweenAnimationType.ShakeRotation:
            case DOTweenAnimationType.ShakeScale:
                GUIEndValueV3();
                canBeRelative = false;
                _src.optionalInt0 = EditorGUILayout.IntSlider(new GUIContent("    Vibrato", "How much will the shake vibrate"), _src.optionalInt0, 1, 50);
                _src.optionalFloat0 = EditorGUILayout.Slider(new GUIContent("    Randomness", "The shake randomness"), _src.optionalFloat0, 0, 90);
                if (_src.animationType == DOTweenAnimationType.ShakePosition) _src.optionalBool0 = EditorGUILayout.Toggle("    Snapping", _src.optionalBool0);
                break;
            case DOTweenAnimationType.CameraAspect:
            case DOTweenAnimationType.CameraFieldOfView:
            case DOTweenAnimationType.CameraOrthoSize:
                GUIEndValueFloat();
                canBeRelative = false;
                break;
            case DOTweenAnimationType.CameraBackgroundColor:
                GUIEndValueColor();
                canBeRelative = false;
                break;
            case DOTweenAnimationType.CameraPixelRect:
            case DOTweenAnimationType.CameraRect:
                GUIEndValueRect();
                canBeRelative = false;
                break;
            }

            // Final settings
            if (canBeRelative) _src.isRelative = EditorGUILayout.Toggle("    Relative", _src.isRelative);

            // Events
            AnimationInspectorGUI.AnimationEvents(this, _src);

            if (GUI.changed) EditorUtility.SetDirty(_src);
        }

19 View Source File : EasyTouchWelcomeScreen.cs
License : MIT License
Project Creator : XINCGer

bool Button(Texture texture, string heading, string body, int space=10){

		GUILayout.BeginHorizontal();
		
		GUILayout.Space(54);
		GUILayout.Box(texture, GUIStyle.none, GUILayout.MaxWidth(48));
		GUILayout.Space(10);
		
		GUILayout.BeginVertical();
		GUILayout.Space(1);
		GUILayout.Label(heading, EditorStyles.boldLabel);
		GUILayout.Label(body);
		GUILayout.EndVertical();
		
		GUILayout.EndHorizontal();
		
		var rect = GUILayoutUtility.GetLastRect();
		EditorGUIUtility.AddCursorRect(rect, MouseCursor.Link);
			
		bool returnValue = false;
		if (Event.current.type == EventType.MouseDown && rect.Contains(Event.current.mousePosition)){
			returnValue = true;
		}
		
		GUILayout.Space(space);

		return returnValue;
	}

19 View Source File : ETCGuiTools.cs
License : MIT License
Project Creator : XINCGer

public static void EndGroup(bool endSpace = true){
		GUILayout.Space(3f);
		GUILayout.EndVertical();
		EditorGUILayout.EndHorizontal();
		GUILayout.Space(3f);
		GUILayout.EndHorizontal();
		
		if (endSpace){
			GUILayout.Space(10f);
		}
	}

19 View Source File : AuthenticationSample.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
    {
        GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
        {
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                GUILayout.BeginVertical();

                if (signalRConnection.AuthenticationProvider == null)
                {
                    GUILayout.BeginHorizontal();
                        GUILayout.Label("Username (Enter 'User'):");
                        userName = GUILayout.TextField(userName, GUILayout.MinWidth(100));
                    GUILayout.EndHorizontal();

                    GUILayout.BeginHorizontal();
                        GUILayout.Label("Roles (Enter 'Invoker' or 'Admin'):");
                        role = GUILayout.TextField(role, GUILayout.MinWidth(100));
                    GUILayout.EndHorizontal();

                    if (GUILayout.Button("Log in"))
                        Restart();
                }

                for (int i = 0; i < signalRConnection.Hubs.Length; ++i)
                    (signalRConnection.Hubs[i] as BaseHub).Draw();

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

19 View Source File : DemoHubSample.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
    {
        GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
        {
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                GUILayout.BeginVertical();

                    demoHub.Draw();

                    typedDemoHub.Draw();

                    GUILayout.Label("Read State Value");
                    GUILayout.BeginHorizontal();
                        GUILayout.Space(20);
                        GUILayout.Label(vbReadStateResult);
                    GUILayout.EndHorizontal();

                    GUILayout.Space(10);

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

    }

19 View Source File : SocketIOWePlaySample.cs
License : MIT License
Project Creator : XINCGer

void DrawControls()
    {
        GUILayout.BeginHorizontal();
            GUILayout.Label("Controls:");

            for (int i = 0; i < controls.Length; ++i)
                if (GUILayout.Button(controls[i]))
                    Socket.Emit("move", controls[i]);

            GUILayout.Label(" Connections: " + connections);

        GUILayout.EndHorizontal();
    }

19 View Source File : SocketIOWePlaySample.cs
License : MIT License
Project Creator : XINCGer

void DrawChat(bool withInput = true)
    {
        GUILayout.BeginVertical();

            // Draw the messages
            scrollPos = GUILayout.BeginScrollView(scrollPos, false, false);
                for (int i = 0; i < messages.Count; ++i)
                    GUILayout.Label(messages[i], GUILayout.MinWidth(Screen.width));
            GUILayout.EndScrollView();

            if (withInput)
            {
                GUILayout.Label("Your message: ");

                GUILayout.BeginHorizontal();

                    messageToSend = GUILayout.TextField(messageToSend);

                    if (GUILayout.Button("Send", GUILayout.MaxWidth(100)))
                        SendMessage();

                GUILayout.EndHorizontal();
            }

        GUILayout.EndVertical();
    }

19 View Source File : SampleSelector.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
    {
        var stats = HTTPManager.GetGeneralStatistics(StatisticsQueryFlags.All);

        // Connection statistics
        GUIHelper.DrawArea(new Rect(0, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                // Header
                GUIHelper.DrawCenteredText("Connections");

                GUILayout.Space(5);

                GUIHelper.DrawRow("Sum:", stats.Connections.ToString());
                GUIHelper.DrawRow("Active:", stats.ActiveConnections.ToString());
                GUIHelper.DrawRow("Free:", stats.FreeConnections.ToString());
                GUIHelper.DrawRow("Recycled:", stats.RecycledConnections.ToString());
                GUIHelper.DrawRow("Requests in queue:", stats.RequestsInQueue.ToString());
            });

        // Cache statistics
        GUIHelper.DrawArea(new Rect(Screen.width / 3, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                GUIHelper.DrawCenteredText("Cache");

#if !BESTHTTP_DISABLE_CACHING && (!UNITY_WEBGL || UNITY_EDITOR)
                if (!BestHTTP.Caching.HTTPCacheService.IsSupported)
                {
#endif
                    GUI.color = Color.yellow;
                    GUIHelper.DrawCenteredText("Disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                    GUI.color = Color.white;
#if !BESTHTTP_DISABLE_CACHING && (!UNITY_WEBGL || UNITY_EDITOR)
                }
                else
                {
                    GUILayout.Space(5);

                    GUIHelper.DrawRow("Cached enreplacedies:", stats.CacheEnreplacedyCount.ToString());
                    GUIHelper.DrawRow("Sum Size (bytes): ", stats.CacheSize.ToString("N0"));

                    GUILayout.BeginVertical();

                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Clear Cache"))
                        BestHTTP.Caching.HTTPCacheService.BeginClear();

                    GUILayout.EndVertical();
                }
#endif
            });

        // Cookie statistics
        GUIHelper.DrawArea(new Rect((Screen.width / 3) * 2, 0, Screen.width / 3, statisticsHeight), false, () =>
            {
                GUIHelper.DrawCenteredText("Cookies");

#if !BESTHTTP_DISABLE_COOKIES && (!UNITY_WEBGL || UNITY_EDITOR)
                if (!BestHTTP.Cookies.CookieJar.IsSavingSupported)
                {
#endif
                    GUI.color = Color.yellow;
                    GUIHelper.DrawCenteredText("Saving and loading from disk is disabled in WebPlayer, WebGL & Samsung Smart TV Builds!");
                    GUI.color = Color.white;
#if !BESTHTTP_DISABLE_COOKIES && (!UNITY_WEBGL || UNITY_EDITOR)
                }
                else
                {
                    GUILayout.Space(5);

                    GUIHelper.DrawRow("Cookies:", stats.CookieCount.ToString());
                    GUIHelper.DrawRow("Estimated size (bytes):", stats.CookieJarSize.ToString("N0"));

                    GUILayout.BeginVertical();

                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Clear Cookies"))
                        BestHTTP.Cookies.CookieJar.Clear();
 
                    GUILayout.EndVertical();
                }
#endif
            });

        if (SelectedSample == null || (SelectedSample != null && !SelectedSample.IsRunning))
        {
            // Draw the list of samples
            GUIHelper.DrawArea(new Rect(0, statisticsHeight + 5, SelectedSample == null ? Screen.width : Screen.width / 3, Screen.height - statisticsHeight - 5), false, () =>
                {
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                    for (int i = 0; i < Samples.Count; ++i)
                        DrawSample(Samples[i]);
                    GUILayout.EndScrollView();
                });

            if (SelectedSample != null)
                DrawSampleDetails(SelectedSample);
        }
        else if (SelectedSample != null && SelectedSample.IsRunning)
        {
            GUILayout.BeginArea(new Rect(0, Screen.height - 50, Screen.width, 50), string.Empty);
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();

                    GUILayout.BeginVertical();
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Back", GUILayout.MinWidth(100)))
                        SelectedSample.DestroyUnityObject();
                    GUILayout.FlexibleSpace();
                    GUILayout.EndVertical();

                GUILayout.EndHorizontal();
            GUILayout.EndArea();
        }
    }

19 View Source File : AuthenticationSample.cs
License : MIT License
Project Creator : XINCGer

public void Draw()
    {
        GUILayout.Label(this.replacedle);

        GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            messages.Draw(Screen.width - 20, 100);
        GUILayout.EndHorizontal();
    }

19 View Source File : ConnectionStatusSample.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
    {
        GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
        {
            GUILayout.BeginHorizontal();

                if (GUILayout.Button("START") && signalRConnection.State != ConnectionStates.Connected)
                    signalRConnection.Open();

                if (GUILayout.Button("STOP") && signalRConnection.State == ConnectionStates.Connected)
                {
                    signalRConnection.Close();
                    messages.Clear();
                }

                if (GUILayout.Button("PING") && signalRConnection.State == ConnectionStates.Connected)
                {
                    // Call a Hub-method on the server.
                    signalRConnection["StatusHub"].Call("Ping");
                }

            GUILayout.EndHorizontal();

            GUILayout.Space(20);

            GUILayout.Label("Connection Status Messages");

            GUILayout.BeginHorizontal();
                GUILayout.Space(20);
                messages.Draw(Screen.width - 20, 0);
            GUILayout.EndHorizontal();
        });
    }

19 View Source File : SocketIOChatSample.cs
License : MIT License
Project Creator : XINCGer

void DrawChatScreen()
    {
        GUIHelper.DrawArea(GUIHelper.ClientArea, true, () =>
            {
                GUILayout.BeginVertical();
                    scrollPos = GUILayout.BeginScrollView(scrollPos);
                        GUILayout.Label(chatLog, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
                    GUILayout.EndScrollView();

                    string typing = string.Empty;

                    if (typingUsers.Count > 0)
                    {
                        typing += string.Format("{0}", typingUsers[0]);

                        for (int i = 1; i < typingUsers.Count; ++i)
                            typing += string.Format(", {0}", typingUsers[i]);

                        if (typingUsers.Count == 1)
                            typing += " is typing!";
                        else
                            typing += " are typing!";
                    }

                    GUILayout.Label(typing);

                    GUILayout.Label("Type here:");

                    GUILayout.BeginHorizontal();
                    message = GUILayout.TextField(message);

                    if (GUILayout.Button("Send", GUILayout.MaxWidth(100)))
                        SendMessage();
                    GUILayout.EndHorizontal();

                    if (GUI.changed)
                        UpdateTyping();

                GUILayout.EndVertical();
            });
    }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

void GUIEndValueV2()
        {
            GUILayout.BeginHorizontal();
            GUIToFromButton();
            _src.endValueV2 = EditorGUILayout.Vector2Field("", _src.endValueV2, GUILayout.Height(16));
            GUILayout.EndHorizontal();
        }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

void GUIEndValueString()
        {
            GUILayout.BeginHorizontal();
            GUIToFromButton();
            _src.endValueString = EditorGUILayout.TextArea(_src.endValueString, EditorGUIUtils.wordWrapTextArea);
            GUILayout.EndHorizontal();
        }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

void GUIEndValueRect()
        {
            GUILayout.BeginHorizontal();
            GUIToFromButton();
            _src.endValueRect = EditorGUILayout.RectField(_src.endValueRect);
            GUILayout.EndHorizontal();
        }

19 View Source File : DemoHubSample.cs
License : MIT License
Project Creator : XINCGer

public void Draw()
    {
        GUILayout.Label("Typed callback");

        GUILayout.BeginHorizontal();
            GUILayout.Space(20);
            GUILayout.BeginVertical();
                GUILayout.Label(typedEcreplacedsult);
                GUILayout.Label(typedEchoClientResult);
            GUILayout.EndVertical();
        GUILayout.EndHorizontal();

        GUILayout.Space(10);
    }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

void GUIEndValueFloat()
        {
            GUILayout.BeginHorizontal();
            GUIToFromButton();
            _src.endValueFloat = EditorGUILayout.FloatField(_src.endValueFloat);
            GUILayout.EndHorizontal();
        }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

void GUIEndValueColor()
        {
            GUILayout.BeginHorizontal();
            GUIToFromButton();
            _src.endValueColor = EditorGUILayout.ColorField(_src.endValueColor);
            GUILayout.EndHorizontal();
        }

19 View Source File : DOTweenAnimationInspector.cs
License : MIT License
Project Creator : XINCGer

void GUIEndValueV3(bool optionalTransform = false)
        {
            GUILayout.BeginHorizontal();
            GUIToFromButton();
            if (_src.useTargetAsV3) {
                Transform prevT = _src.endValueTransform;
                _src.endValueTransform = EditorGUILayout.ObjectField(_src.endValueTransform, typeof(Transform), true) as Transform;
                if (_src.endValueTransform != prevT && _src.endValueTransform != null) {
                    // Check that it's a Transform for a Transform or a RectTransform for a RectTransform
                    if (_src.GetComponent<RectTransform>() != null) {
                        if (_src.endValueTransform.GetComponent<RectTransform>() == null) {
                            EditorUtility.DisplayDialog("DOTween Pro", "For Unity UI elements, the target must also be a UI element", "Ok");
                            _src.endValueTransform = null;
                        }
                    } else if (_src.endValueTransform.GetComponent<RectTransform>() != null) {
                        EditorUtility.DisplayDialog("DOTween Pro", "You can't use a UI target for a non UI object", "Ok");
                        _src.endValueTransform = null;
                    }
                }
            } else {
                _src.endValueV3 = EditorGUILayout.Vector3Field("", _src.endValueV3, GUILayout.Height(16));
            }
            if (optionalTransform) {
                if (GUILayout.Button(_src.useTargetAsV3 ? "target" : "value", EditorGUIUtils.sideBtStyle, GUILayout.Width(44))) _src.useTargetAsV3 = !_src.useTargetAsV3;
            }
            GUILayout.EndHorizontal();
            if (_src.useTargetAsV3 && _src.endValueTransform != null && _src.target is RectTransform) {
                EditorGUILayout.HelpBox("NOTE: when using a UI target, the tween will be created during Start instead of Awake", MessageType.Info);
            }
        }

19 View Source File : HTGuiTools.cs
License : MIT License
Project Creator : XINCGer

public static void EndGroup(bool endSpace = true){
		GUILayout.Space(3f);
		GUILayout.EndVertical();
		EditorGUILayout.EndHorizontal();
		GUILayout.Space(3f);
		GUILayout.EndHorizontal();

		if (endSpace){
			GUILayout.Space(10f);
		}
	}

19 View Source File : SpriteSelector.cs
License : MIT License
Project Creator : XINCGer

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

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

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

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

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

			Texture2D tex = atlas.texture as Texture2D;

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

			BetterList<string> sprites = atlas.GetListOfSprites(NGUISettings.partialSprite);
			
			float size = 80f;
			float padded = size + 10f;
#if UNITY_4_7
			int screenWidth = Screen.width;
#else
			int screenWidth = (int)EditorGUIUtility.currentViewWidth;
#endif
			int columns = Mathf.FloorToInt(screenWidth / padded);
			if (columns < 1) columns = 1;

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

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

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

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

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

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

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

						if (Event.current.type == EventType.Repaint)
						{
							// On top of the button we have a checkboard grid
							NGUIEditorTools.DrawTiledTexture(rect, NGUIEditorTools.backdropTexture);
							Rect uv = new Rect(sprite.x, sprite.y, sprite.width, sprite.height);
							uv = NGUIMath.ConvertToTexCoords(uv, tex.width, tex.height);
	
							// Calculate the texture's scale that's needed to display the sprite in the clipped area
							float scaleX = rect.width / uv.width;
							float scaleY = rect.height / uv.height;
	
							// Stretch the sprite so that it will appear proper
							float aspect = (scaleY / scaleX) / ((float)tex.height / tex.width);
							Rect clipRect = rect;
	
							if (aspect != 1f)
							{
								if (aspect < 1f)
								{
									// The sprite is taller than it is wider
									float padding = size * (1f - aspect) * 0.5f;
									clipRect.xMin += padding;
									clipRect.xMax -= padding;
								}
								else
								{
									// The sprite is wider than it is taller
									float padding = size * (1f - 1f / aspect) * 0.5f;
									clipRect.yMin += padding;
									clipRect.yMax -= padding;
								}
							}
	
							GUI.DrawTextureWithTexCoords(clipRect, tex, uv);
	
							// Draw the selection
							if (NGUISettings.selectedSprite == sprite.name)
							{
								NGUIEditorTools.DrawOutline(rect, new Color(0.4f, 1f, 0f, 1f));
							}
						}

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

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

			if (close) Close();
		}
	}

19 View Source File : UIAtlasMaker.cs
License : MIT License
Project Creator : XINCGer

void OnGUI ()
	{
		if (mLastAtlas != NGUISettings.atlas)
			mLastAtlas = NGUISettings.atlas;

		bool update = false;
		bool replace = false;

		NGUIEditorTools.SetLabelWidth(84f);
		GUILayout.Space(3f);

		NGUIEditorTools.DrawHeader("Input", true);
		NGUIEditorTools.BeginContents(false);

		GUILayout.BeginHorizontal();
		{
			ComponentSelector.Draw<UIAtlas>("Atlas", NGUISettings.atlas, OnSelectAtlas, true, GUILayout.MinWidth(80f));

			EditorGUI.BeginDisabledGroup(NGUISettings.atlas == null);
			if (GUILayout.Button("New", GUILayout.Width(40f)))
				NGUISettings.atlas = null;
			EditorGUI.EndDisabledGroup();
		}
		GUILayout.EndHorizontal();

		List<Texture> textures = GetSelectedTextures();

		if (NGUISettings.atlas != null)
		{
			Material mat = NGUISettings.atlas.spriteMaterial;
			Texture tex = NGUISettings.atlas.texture;

			// Material information
			GUILayout.BeginHorizontal();
			{
				if (mat != null)
				{
					if (GUILayout.Button("Material", GUILayout.Width(76f))) Selection.activeObject = mat;
					GUILayout.Label(" " + mat.name);
				}
				else
				{
					GUI.color = Color.grey;
					GUILayout.Button("Material", GUILayout.Width(76f));
					GUI.color = Color.white;
					GUILayout.Label(" N/A");
				}
			}
			GUILayout.EndHorizontal();

			// Texture atlas information
			GUILayout.BeginHorizontal();
			{
				if (tex != null)
				{
					if (GUILayout.Button("Texture", GUILayout.Width(76f))) Selection.activeObject = tex;
					GUILayout.Label(" " + tex.width + "x" + tex.height);
				}
				else
				{
					GUI.color = Color.grey;
					GUILayout.Button("Texture", GUILayout.Width(76f));
					GUI.color = Color.white;
					GUILayout.Label(" N/A");
				}
			}
			GUILayout.EndHorizontal();
		}

		GUILayout.BeginHorizontal();
		NGUISettings.atlasPadding = Mathf.Clamp(EditorGUILayout.IntField("Padding", NGUISettings.atlasPadding, GUILayout.Width(100f)), 0, 8);
		GUILayout.Label((NGUISettings.atlasPadding == 1 ? "pixel" : "pixels") + " between sprites");
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		NGUISettings.atlasTrimming = EditorGUILayout.Toggle("Trim Alpha", NGUISettings.atlasTrimming, GUILayout.Width(100f));
		GUILayout.Label("Remove empty space");
		GUILayout.EndHorizontal();

		bool fixedShader = false;

		if (NGUISettings.atlas != null)
		{
			Material mat = NGUISettings.atlas.spriteMaterial;

			if (mat != null)
			{
				Shader shader = mat.shader;

				if (shader != null)
				{
					if (shader.name == "Unlit/Transparent Colored")
					{
						NGUISettings.atlasPMA = false;
						fixedShader = true;
					}
					else if (shader.name == "Unlit/Premultiplied Colored")
					{
						NGUISettings.atlasPMA = true;
						fixedShader = true;
					}
				}
			}
		}

		if (!fixedShader)
		{
			GUILayout.BeginHorizontal();
			NGUISettings.atlasPMA = EditorGUILayout.Toggle("PMA Shader", NGUISettings.atlasPMA, GUILayout.Width(100f));
			GUILayout.Label("Pre-multiplied alpha", GUILayout.MinWidth(70f));
			GUILayout.EndHorizontal();
		}

		//GUILayout.BeginHorizontal();
		//NGUISettings.keepPadding = EditorGUILayout.Toggle("Keep Padding", NGUISettings.keepPadding, GUILayout.Width(100f));
		//GUILayout.Label("or replace with trimmed pixels", GUILayout.MinWidth(70f));
		//GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		NGUISettings.unityPacking = EditorGUILayout.Toggle("Unity Packer", NGUISettings.unityPacking, GUILayout.Width(100f));
		GUILayout.Label("or custom packer", GUILayout.MinWidth(70f));
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		NGUISettings.trueColorAtlas = EditorGUILayout.Toggle("Truecolor", NGUISettings.trueColorAtlas, GUILayout.Width(100f));
		GUILayout.Label("force ARGB32 textures", GUILayout.MinWidth(70f));
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		NGUISettings.autoUpgradeSprites = EditorGUILayout.Toggle("Auto-upgrade", NGUISettings.trueColorAtlas, GUILayout.Width(100f));
		GUILayout.Label("replace textures with sprites", GUILayout.MinWidth(70f));
		GUILayout.EndHorizontal();

		if (!NGUISettings.unityPacking)
		{
			GUILayout.BeginHorizontal();
			NGUISettings.forceSquareAtlas = EditorGUILayout.Toggle("Force Square", NGUISettings.forceSquareAtlas, GUILayout.Width(100f));
			GUILayout.Label("if on, forces a square atlas texture", GUILayout.MinWidth(70f));
			GUILayout.EndHorizontal();
		}

#if UNITY_IPHONE || UNITY_ANDROID
		GUILayout.BeginHorizontal();
		NGUISettings.allow4096 = EditorGUILayout.Toggle("4096x4096", NGUISettings.allow4096, GUILayout.Width(100f));
		GUILayout.Label("if off, limit atlases to 2048x2048");
		GUILayout.EndHorizontal();
#endif
		NGUIEditorTools.EndContents();

		if (NGUISettings.atlas != null)
		{
			GUILayout.BeginHorizontal();
			GUILayout.Space(20f);

			if (textures.Count > 0)
			{
				update = GUILayout.Button("Add/Update");
			}
			else if (GUILayout.Button("View Sprites"))
			{
				SpriteSelector.ShowSelected();
			}

			GUILayout.Space(20f);
			GUILayout.EndHorizontal();
		}
		else
		{
			EditorGUILayout.HelpBox("You can create a new atlas by selecting one or more textures in the Project View window, then clicking \"Create\".", MessageType.Info);

			EditorGUI.BeginDisabledGroup(textures.Count == 0);
			GUILayout.BeginHorizontal();
			GUILayout.Space(20f);
			bool create = GUILayout.Button("Create");
			GUILayout.Space(20f);
			GUILayout.EndHorizontal();
			EditorGUI.EndDisabledGroup();

			if (create)
			{
				string path = EditorUtility.SaveFilePanelInProject("Save As",
					"New Atlas.prefab", "prefab", "Save atlas as...", NGUISettings.currentPath);

				if (!string.IsNullOrEmpty(path))
				{
					NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path);
					GameObject go = replacedetDatabase.LoadreplacedetAtPath(path, typeof(GameObject)) as GameObject;
					string matPath = path.Replace(".prefab", ".mat");
					replace = true;

					// Try to load the material
					Material mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;

					// If the material doesn't exist, create it
					if (mat == null)
					{
						Shader shader = Shader.Find(NGUISettings.atlasPMA ? "Unlit/Premultiplied Colored" : "Unlit/Transparent Colored");
						mat = new Material(shader);

						// Save the material
						replacedetDatabase.Createreplacedet(mat, matPath);
						replacedetDatabase.Refresh(ImportreplacedetOptions.ForceSynchronousImport);

						// Load the material so it's usable
						mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
					}

					// Create a new prefab for the atlas
					Object prefab = (go != null) ? go : PrefabUtility.CreateEmptyPrefab(path);

					// Create a new game object for the atlas
					string atlasName = path.Replace(".prefab", "");
					atlasName = atlasName.Substring(path.LastIndexOfAny(new char[] { '/', '\\' }) + 1);
					go = new GameObject(atlasName);
					go.AddComponent<UIAtlas>().spriteMaterial = mat;

					// Update the prefab
					PrefabUtility.ReplacePrefab(go, prefab);
					DestroyImmediate(go);
					replacedetDatabase.Savereplacedets();
					replacedetDatabase.Refresh(ImportreplacedetOptions.ForceSynchronousImport);

					// Select the atlas
					go = replacedetDatabase.LoadreplacedetAtPath(path, typeof(GameObject)) as GameObject;
					NGUISettings.atlas = go.GetComponent<UIAtlas>();
					Selection.activeGameObject = go;
				}
			}
		}

		string selection = null;
		Dictionary<string, int> spriteList = GetSpriteList(textures);

		if (spriteList.Count > 0)
		{
			NGUIEditorTools.DrawHeader("Sprites", true);
			{
				GUILayout.BeginHorizontal();
				GUILayout.Space(3f);
				GUILayout.BeginVertical();

				mScroll = GUILayout.BeginScrollView(mScroll);

				bool delete = false;
				int index = 0;
				foreach (KeyValuePair<string, int> iter in spriteList)
				{
					++index;

					GUILayout.Space(-1f);
					bool highlight = (UIAtlasInspector.instance != null) && (NGUISettings.selectedSprite == iter.Key);
					GUI.backgroundColor = highlight ? Color.white : new Color(0.8f, 0.8f, 0.8f);
					GUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(20f));
					GUI.backgroundColor = Color.white;
					GUILayout.Label(index.ToString(), GUILayout.Width(24f));

					if (GUILayout.Button(iter.Key, "OL TextField", GUILayout.Height(20f)))
						selection = iter.Key;

					if (iter.Value == 2)
					{
						GUI.color = Color.green;
						GUILayout.Label("Add", GUILayout.Width(27f));
						GUI.color = Color.white;
					}
					else if (iter.Value == 1)
					{
						GUI.color = Color.cyan;
						GUILayout.Label("Update", GUILayout.Width(45f));
						GUI.color = Color.white;
					}
					else
					{
						if (mDelNames.Contains(iter.Key))
						{
							GUI.backgroundColor = Color.red;

							if (GUILayout.Button("Delete", GUILayout.Width(60f)))
							{
								delete = true;
							}
							GUI.backgroundColor = Color.green;
							if (GUILayout.Button("X", GUILayout.Width(22f)))
							{
								mDelNames.Remove(iter.Key);
								delete = false;
							}
							GUI.backgroundColor = Color.white;
						}
						else
						{
							// If we have not yet selected a sprite for deletion, show a small "X" button
							if (GUILayout.Button("X", GUILayout.Width(22f))) mDelNames.Add(iter.Key);
						}
					}
					GUILayout.EndHorizontal();
				}
				GUILayout.EndScrollView();
				GUILayout.EndVertical();
				GUILayout.Space(3f);
				GUILayout.EndHorizontal();

				// If this sprite was marked for deletion, remove it from the atlas
				if (delete)
				{
					List<SpriteEntry> sprites = new List<SpriteEntry>();
					ExtractSprites(NGUISettings.atlas, sprites);

					for (int i = sprites.Count; i > 0; )
					{
						SpriteEntry ent = sprites[--i];
						if (mDelNames.Contains(ent.name))
							sprites.RemoveAt(i);
					}
					UpdateAtlas(NGUISettings.atlas, sprites);
					mDelNames.Clear();
					NGUIEditorTools.RepaintSprites();
				}
				else if (update) UpdateAtlas(textures, true);
				else if (replace) UpdateAtlas(textures, false);

				if (NGUISettings.atlas != null && !string.IsNullOrEmpty(selection))
				{
					NGUIEditorTools.SelectSprite(selection);
				}
				else if (NGUISettings.autoUpgradeSprites && (update || replace))
				{
					NGUIEditorTools.UpgradeTexturesToSprites(NGUISettings.atlas);
					NGUIEditorTools.RepaintSprites();
				}
			}
		}

		if (NGUISettings.atlas != null && textures.Count == 0)
			EditorGUILayout.HelpBox("You can reveal more options by selecting one or more textures in the Project View window.", MessageType.Info);

		// Uncomment this line if you want to be able to force-sort the atlas
		//if (NGUISettings.atlas != null && GUILayout.Button("Sort Alphabetically")) NGUISettings.atlas.SortAlphabetically();
	}

19 View Source File : UICameraEditor.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		UICamera cam = target as UICamera;
		GUILayout.Space(3f);

		serializedObject.Update();

		SerializedProperty et = serializedObject.FindProperty("eventType");

		if (et.hasMultipleDifferentValues)
		{
			EditorGUILayout.PropertyField(et);
		}
		else
		{
			string[] options = new string[] { "3D World", "3D UI", "2D World", "2D UI" };
			int val = EditorGUILayout.Popup("Event Type", et.intValue, options);
			if (val != et.intValue) et.intValue = val;
		}

		SerializedProperty ev = serializedObject.FindProperty("eventsGoToColliders");

		if (ev != null)
		{
			bool val = ev.boolValue;
			bool newVal = EventsGo.Colliders == (EventsGo)EditorGUILayout.EnumPopup("Events go to...",
				ev.boolValue ? EventsGo.Colliders : EventsGo.Rigidbodies);
			if (val != newVal) ev.boolValue = newVal;
		}

		if (UICamera.eventHandler != cam)
		{
			EditorGUILayout.PropertyField(serializedObject.FindProperty("eventReceiverMask"), new GUIContent("Event Mask"));
			serializedObject.ApplyModifiedProperties();

			EditorGUILayout.HelpBox("All other settings are inherited from the First Camera.", MessageType.Info);

			if (GUILayout.Button("Select the First Camera"))
			{
				Selection.activeGameObject = UICamera.eventHandler.gameObject;
			}
		}
		else
		{
			serializedObject.DrawProperty("processEventsIn");

			SerializedProperty mouse = serializedObject.FindProperty("useMouse");
			SerializedProperty touch = serializedObject.FindProperty("useTouch");
			SerializedProperty keyboard = serializedObject.FindProperty("useKeyboard");
			SerializedProperty controller = serializedObject.FindProperty("useController");

			EditorGUILayout.PropertyField(serializedObject.FindProperty("eventReceiverMask"), new GUIContent("Event Mask"));
			EditorGUILayout.PropertyField(serializedObject.FindProperty("debug"));

			GUILayout.BeginHorizontal();
			EditorGUILayout.PropertyField(serializedObject.FindProperty("commandClick"), GUILayout.Width(140f));
			GUILayout.Label("= Right-Click on OSX", GUILayout.MinWidth(30f));
			GUILayout.EndHorizontal();

			EditorGUI.BeginDisabledGroup(!mouse.boolValue && !touch.boolValue);
			{
				EditorGUILayout.PropertyField(serializedObject.FindProperty("allowMulreplacedouch"));
			}
			EditorGUI.EndDisabledGroup();

			EditorGUI.BeginDisabledGroup(!(mouse.boolValue && (touch.boolValue || controller.boolValue)));
			{
				EditorGUILayout.PropertyField(serializedObject.FindProperty("autoHideCursor"));
			}
			EditorGUI.EndDisabledGroup();

			EditorGUI.BeginDisabledGroup(!mouse.boolValue);
			EditorGUILayout.PropertyField(serializedObject.FindProperty("stickyTooltip"));
			EditorGUI.EndDisabledGroup();

			GUILayout.BeginHorizontal();
			EditorGUILayout.PropertyField(serializedObject.FindProperty("longPressTooltip"));
			GUILayout.EndHorizontal();

			EditorGUI.BeginDisabledGroup(!mouse.boolValue);
			GUILayout.BeginHorizontal();
			EditorGUILayout.PropertyField(serializedObject.FindProperty("tooltipDelay"));
			GUILayout.Label("seconds", GUILayout.MinWidth(60f));
			GUILayout.EndHorizontal();
			EditorGUI.EndDisabledGroup();

			GUILayout.BeginHorizontal();
			SerializedProperty rd = serializedObject.FindProperty("rangeDistance");
			EditorGUILayout.PropertyField(rd, new GUIContent("Raycast Range"));
			GUILayout.Label(rd.floatValue < 0f ? "unlimited" : "units", GUILayout.MinWidth(60f));
			GUILayout.EndHorizontal();

			NGUIEditorTools.SetLabelWidth(80f);

			if (NGUIEditorTools.DrawHeader("Event Sources"))
			{
				NGUIEditorTools.BeginContents();
				{
					GUILayout.BeginHorizontal();
					EditorGUILayout.PropertyField(mouse, new GUIContent("Mouse"), GUILayout.MinWidth(100f));
					EditorGUILayout.PropertyField(touch, new GUIContent("Touch"), GUILayout.MinWidth(100f));
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					EditorGUILayout.PropertyField(keyboard, new GUIContent("Keyboard"), GUILayout.MinWidth(100f));
					EditorGUILayout.PropertyField(controller, new GUIContent("Controller"), GUILayout.MinWidth(100f));
					GUILayout.EndHorizontal();
				}
				NGUIEditorTools.EndContents();
			}

			if ((mouse.boolValue || touch.boolValue) && NGUIEditorTools.DrawHeader("Thresholds"))
			{
				NGUIEditorTools.BeginContents();
				{
					EditorGUI.BeginDisabledGroup(!mouse.boolValue);
					GUILayout.BeginHorizontal();
					EditorGUILayout.PropertyField(serializedObject.FindProperty("mouseDragThreshold"), new GUIContent("Mouse Drag"), GUILayout.Width(120f));
					GUILayout.Label("pixels");
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					EditorGUILayout.PropertyField(serializedObject.FindProperty("mouseClickThreshold"), new GUIContent("Mouse Click"), GUILayout.Width(120f));
					GUILayout.Label("pixels");
					GUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();

					EditorGUI.BeginDisabledGroup(!touch.boolValue);
					GUILayout.BeginHorizontal();
					EditorGUILayout.PropertyField(serializedObject.FindProperty("touchDragThreshold"), new GUIContent("Touch Drag"), GUILayout.Width(120f));
					GUILayout.Label("pixels");
					GUILayout.EndHorizontal();

					GUILayout.BeginHorizontal();
					EditorGUILayout.PropertyField(serializedObject.FindProperty("touchClickThreshold"), new GUIContent("Touch Tap"), GUILayout.Width(120f));
					GUILayout.Label("pixels");
					GUILayout.EndHorizontal();
					EditorGUI.EndDisabledGroup();
				}
				NGUIEditorTools.EndContents();
			}

			if ((mouse.boolValue || keyboard.boolValue || controller.boolValue) && NGUIEditorTools.DrawHeader("Axes and Keys"))
			{
				NGUIEditorTools.BeginContents();
				{
					EditorGUILayout.PropertyField(serializedObject.FindProperty("horizontalAxisName"), new GUIContent("Navigate X"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("verticalAxisName"), new GUIContent("Navigate Y"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("horizontalPanAxisName"), new GUIContent("Pan X"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("verticalPanAxisName"), new GUIContent("Pan Y"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("scrollAxisName"), new GUIContent("Scroll"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("submitKey0"), new GUIContent("Submit 1"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("submitKey1"), new GUIContent("Submit 2"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("cancelKey0"), new GUIContent("Cancel 1"));
					EditorGUILayout.PropertyField(serializedObject.FindProperty("cancelKey1"), new GUIContent("Cancel 2"));
				}
				NGUIEditorTools.EndContents();
			}
			serializedObject.ApplyModifiedProperties();
		}
	}

19 View Source File : UIFontMaker.cs
License : MIT License
Project Creator : XINCGer

void OnGUI ()
	{
		Object fnt = (Object)NGUISettings.FMFont ?? (Object)NGUISettings.BMFont;
		UIFont uiFont = (fnt as UIFont);

		NGUIEditorTools.SetLabelWidth(80f);
		GUILayout.Space(3f);

		NGUIEditorTools.DrawHeader("Input", true);
		NGUIEditorTools.BeginContents(false);

		GUILayout.BeginHorizontal();
		mType = (FontType)EditorGUILayout.EnumPopup("Type", mType, GUILayout.MinWidth(200f));
		NGUIEditorTools.DrawPadding();
		GUILayout.EndHorizontal();
		Create create = Create.None;

		if (mType == FontType.ImportedBitmap)
		{
			NGUISettings.fontData = EditorGUILayout.ObjectField("Font Data", NGUISettings.fontData, typeof(Textreplacedet), false) as Textreplacedet;
			NGUISettings.fontTexture = EditorGUILayout.ObjectField("Texture", NGUISettings.fontTexture, typeof(Texture2D), false, GUILayout.Width(140f)) as Texture2D;
			NGUIEditorTools.EndContents();

			// Draw the atlas selection only if we have the font data and texture specified, just to make it easier
			EditorGUI.BeginDisabledGroup(NGUISettings.fontData == null || NGUISettings.fontTexture == null);
			{
				NGUIEditorTools.DrawHeader("Output", true);
				NGUIEditorTools.BeginContents(false);
				ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, false);
				NGUIEditorTools.EndContents();
			}
			EditorGUI.EndDisabledGroup();

			if (NGUISettings.fontData == null)
			{
				EditorGUILayout.HelpBox("To create a font from a previously exported FNT file, you need to use BMFont on " +
					"Windows or your choice of Glyph Designer or the less expensive bmGlyph on the Mac.\n\n" +
					"Either of these tools will create a FNT file for you that you will drag & drop into the field above.", MessageType.Info);
			}
			else if (NGUISettings.fontTexture == null)
			{
				EditorGUILayout.HelpBox("When exporting your font, you should get two files: the FNT, and the texture. Only one texture can be used per font.", MessageType.Info);
			}
			else if (NGUISettings.atlas == null)
			{
				EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
					"labels using this font will generate an extra draw call.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);
			}

			EditorGUI.BeginDisabledGroup(NGUISettings.fontData == null || NGUISettings.fontTexture == null);
			{
				GUILayout.BeginHorizontal();
				GUILayout.Space(20f);
				if (GUILayout.Button("Create the Font")) create = Create.Import;
				GUILayout.Space(20f);
				GUILayout.EndHorizontal();
			}
			EditorGUI.EndDisabledGroup();
		}
		else
		{
			GUILayout.BeginHorizontal();
			if (NGUIEditorTools.DrawPrefixButton("Source"))
				ComponentSelector.Show<Font>(OnUnityFont, new string[] { ".ttf", ".otf" });

			Font ttf = EditorGUILayout.ObjectField(NGUISettings.FMFont, typeof(Font), false) as Font;
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			{
				NGUISettings.FMSize = EditorGUILayout.IntField("Size", NGUISettings.FMSize, GUILayout.Width(120f));

				if (mType == FontType.Dynamic)
				{
					NGUISettings.fontStyle = (FontStyle)EditorGUILayout.EnumPopup(NGUISettings.fontStyle);
					NGUIEditorTools.DrawPadding();
				}
			}
			GUILayout.EndHorizontal();

			// Choose the font style if there are multiple faces present
			if (mType == FontType.GeneratedBitmap)
			{
				if (!FreeType.isPresent)
				{
					string filename = (Application.platform == RuntimePlatform.WindowsEditor) ? "FreeType.dll" : "FreeType.dylib";
					EditorGUILayout.HelpBox(filename + " is missing", MessageType.Error);

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

					if (GUILayout.Button("Find " + filename))
					{
						string path = EditorUtility.OpenFilePanel("Find " + filename, NGUISettings.currentPath,
							(Application.platform == RuntimePlatform.WindowsEditor) ? "dll" : "dylib");

						if (!string.IsNullOrEmpty(path))
						{
							if (System.IO.Path.GetFileName(path) == filename)
							{
								NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path);
								NGUISettings.pathToFreeType = path;
							}
							else Debug.LogError("The library must be named '" + filename + "'");
						}
					}
					GUILayout.Space(20f);
					GUILayout.EndHorizontal();
				}
				else if (ttf != null)
				{
					string[] faces = FreeType.GetFaces(ttf);

					if (faces != null)
					{
						if (mFaceIndex >= faces.Length) mFaceIndex = 0;

						if (faces.Length > 1)
						{
							GUILayout.Label("Style", EditorStyles.boldLabel);
							for (int i = 0; i < faces.Length; ++i)
							{
								GUILayout.BeginHorizontal();
								GUILayout.Space(10f);
								if (DrawOption(i == mFaceIndex, " " + faces[i]))
									mFaceIndex = i;
								GUILayout.EndHorizontal();
							}
						}
					}

					NGUISettings.fontKerning = EditorGUILayout.Toggle("Kerning", NGUISettings.fontKerning);

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

					CharacterMap cm = characterMap;

					GUILayout.BeginHorizontal(GUILayout.Width(100f));
					GUILayout.BeginVertical();
					GUI.changed = false;
					if (DrawOption(cm == CharacterMap.Numeric, " Numeric")) cm = CharacterMap.Numeric;
					if (DrawOption(cm == CharacterMap.Ascii, " ASCII")) cm = CharacterMap.Ascii;
					if (DrawOption(cm == CharacterMap.Latin, " Latin")) cm = CharacterMap.Latin;
					if (DrawOption(cm == CharacterMap.Custom, " Custom")) cm = CharacterMap.Custom;
					if (GUI.changed) characterMap = cm;
					GUILayout.EndVertical();

					EditorGUI.BeginDisabledGroup(cm != CharacterMap.Custom);
					{
						if (cm != CharacterMap.Custom)
						{
							string chars = "";

							if (cm == CharacterMap.Ascii)
							{
								for (int i = 33; i < 127; ++i)
									chars += System.Convert.ToChar(i);
							}
							else if (cm == CharacterMap.Numeric)
							{
								chars = "0123456789";
							}
							else if (cm == CharacterMap.Latin)
							{
								for (int i = 33; i < 127; ++i)
									chars += System.Convert.ToChar(i);

								for (int i = 161; i < 256; ++i)
									chars += System.Convert.ToChar(i);
							}

							NGUISettings.charsToInclude = chars;
						}

						GUI.changed = false;

						string text = NGUISettings.charsToInclude;

						if (cm == CharacterMap.Custom)
						{
							text = EditorGUILayout.TextArea(text, GUI.skin.textArea,
								GUILayout.Height(80f), GUILayout.Width(Screen.width - 100f));
						}
						else
						{
							GUILayout.Label(text, GUI.skin.textArea,
								GUILayout.Height(80f), GUILayout.Width(Screen.width - 100f));
						}

						if (GUI.changed)
						{
							string final = "";

							for (int i = 0; i < text.Length; ++i)
							{
								char c = text[i];
								if (c < 33) continue;
								string s = c.ToString();
								if (!final.Contains(s)) final += s;
							}

							if (final.Length > 0)
							{
								char[] chars = final.ToCharArray();
								System.Array.Sort(chars);
								final = new string(chars);
							}
							else final = "";

							NGUISettings.charsToInclude = final;
						}
					}
					EditorGUI.EndDisabledGroup();
					GUILayout.EndHorizontal();
				}
			}
			NGUIEditorTools.EndContents();

			if (mType == FontType.Dynamic)
			{
				EditorGUI.BeginDisabledGroup(ttf == null);
				GUILayout.BeginHorizontal();
				GUILayout.Space(20f);
				if (GUILayout.Button("Create the Font")) create = Create.Dynamic;
				GUILayout.Space(20f);
				GUILayout.EndHorizontal();
				EditorGUI.EndDisabledGroup();
#if UNITY_3_5
				EditorGUILayout.HelpBox("Dynamic fonts require Unity 4.0 or higher.", MessageType.Error);
#else
				// Helpful info
				if (ttf == null)
				{
					EditorGUILayout.HelpBox("You don't have to create a UIFont to use dynamic fonts. You can just reference the Unity Font directly on the label.", MessageType.Info);
				}
				EditorGUILayout.HelpBox("Please note that dynamic fonts can't be made a part of an atlas, and using dynamic fonts will result in at least one extra draw call.", MessageType.Warning);
#endif
			}
			else
			{
				bool isBuiltIn = (ttf != null) && string.IsNullOrEmpty(UnityEditor.replacedetDatabase.GetreplacedetPath(ttf));

				// Draw the atlas selection only if we have the font data and texture specified, just to make it easier
				EditorGUI.BeginDisabledGroup(ttf == null || isBuiltIn || !FreeType.isPresent);
				{
					NGUIEditorTools.DrawHeader("Output", true);
					NGUIEditorTools.BeginContents(false);
					ComponentSelector.Draw<UIAtlas>(NGUISettings.atlas, OnSelectAtlas, false);
					NGUIEditorTools.EndContents();

					if (ttf == null)
					{
						EditorGUILayout.HelpBox("You can create a bitmap font by specifying a dynamic font to use as the source.", MessageType.Info);
					}
					else if (isBuiltIn)
					{
						EditorGUILayout.HelpBox("You chose an embedded font. You can't create a bitmap font from an embedded resource.", MessageType.Warning);
					}
					else if (NGUISettings.atlas == null)
					{
						EditorGUILayout.HelpBox("You can create a font that doesn't use a texture atlas. This will mean that the text " +
							"labels using this font will generate an extra draw call.\n\nIf you do specify an atlas, the font's texture will be added to it automatically.", MessageType.Info);
					}

					GUILayout.BeginHorizontal();
					GUILayout.Space(20f);
					if (GUILayout.Button("Create the Font")) create = Create.Bitmap;
					GUILayout.Space(20f);
					GUILayout.EndHorizontal();
				}
				EditorGUI.EndDisabledGroup();
			}
		}

		if (create == Create.None) return;

		// Open the "Save As" file dialog
#if UNITY_3_5
		string prefabPath = EditorUtility.SaveFilePanel("Save As",
			NGUISettings.currentPath, "New Font.prefab", "prefab");
#else
		string prefabPath = EditorUtility.SaveFilePanelInProject("Save As",
			"New Font.prefab", "prefab", "Save font as...", NGUISettings.currentPath);
#endif
		if (string.IsNullOrEmpty(prefabPath)) return;
		NGUISettings.currentPath = System.IO.Path.GetDirectoryName(prefabPath);

		// Load the font's prefab
		GameObject go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
		Object prefab = null;
		string fontName;

		// Font doesn't exist yet
		if (go == null || go.GetComponent<UIFont>() == null)
		{
			// Create a new prefab for the atlas
			prefab = PrefabUtility.CreateEmptyPrefab(prefabPath);

			fontName = prefabPath.Replace(".prefab", "");
			fontName = fontName.Substring(prefabPath.LastIndexOfAny(new char[] { '/', '\\' }) + 1);

			// Create a new game object for the font
			go = new GameObject(fontName);
			uiFont = go.AddComponent<UIFont>();
		}
		else
		{
			uiFont = go.GetComponent<UIFont>();
			fontName = go.name;
		}

		if (create == Create.Dynamic)
		{
			uiFont.atlas = null;
			uiFont.dynamicFont = NGUISettings.FMFont;
			uiFont.dynamicFontStyle = NGUISettings.fontStyle;
			uiFont.defaultSize = NGUISettings.FMSize;
		}
		else if (create == Create.Import)
		{
			Material mat = null;

			if (NGUISettings.atlas != null)
			{
				// Add the font's texture to the atlas
				UIAtlasMaker.AddOrUpdate(NGUISettings.atlas, NGUISettings.fontTexture);
			}
			else
			{
				// Create a material for the font
				string matPath = prefabPath.Replace(".prefab", ".mat");
				mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;

				// If the material doesn't exist, create it
				if (mat == null)
				{
					Shader shader = Shader.Find("Unlit/Transparent Colored");
					mat = new Material(shader);

					// Save the material
					replacedetDatabase.Createreplacedet(mat, matPath);
					replacedetDatabase.Refresh(ImportreplacedetOptions.ForceSynchronousImport);

					// Load the material so it's usable
					mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
				}

				mat.mainTexture = NGUISettings.fontTexture;
			}

			uiFont.dynamicFont = null;
			BMFontReader.Load(uiFont.bmFont, NGUITools.GetHierarchy(uiFont.gameObject), NGUISettings.fontData.bytes);

			if (NGUISettings.atlas == null)
			{
				uiFont.atlas = null;
				uiFont.material = mat;
			}
			else
			{
				uiFont.spriteName = NGUISettings.fontTexture.name;
				uiFont.atlas = NGUISettings.atlas;
			}
			NGUISettings.FMSize = uiFont.defaultSize;
		}
		else if (create == Create.Bitmap)
		{
			// Create the bitmap font
			BMFont bmFont;
			Texture2D tex;

			if (FreeType.CreateFont(
				NGUISettings.FMFont,
				NGUISettings.FMSize, mFaceIndex,
				NGUISettings.fontKerning,
				NGUISettings.charsToInclude, 1, out bmFont, out tex))
			{
				uiFont.bmFont = bmFont;
				tex.name = fontName;

				if (NGUISettings.atlas != null)
				{
					// Add this texture to the atlas and destroy it
					UIAtlasMaker.AddOrUpdate(NGUISettings.atlas, tex);
					NGUITools.DestroyImmediate(tex);
					NGUISettings.fontTexture = null;
					tex = null;

					uiFont.atlas = NGUISettings.atlas;
					uiFont.spriteName = fontName;
				}
				else
				{
					string texPath = prefabPath.Replace(".prefab", ".png");
					string matPath = prefabPath.Replace(".prefab", ".mat");

					byte[] png = tex.EncodeToPNG();
					FileStream fs = File.OpenWrite(texPath);
					fs.Write(png, 0, png.Length);
					fs.Close();

					// See if the material already exists
					Material mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;

					// If the material doesn't exist, create it
					if (mat == null)
					{
						Shader shader = Shader.Find("Unlit/Transparent Colored");
						mat = new Material(shader);

						// Save the material
						replacedetDatabase.Createreplacedet(mat, matPath);
						replacedetDatabase.Refresh(ImportreplacedetOptions.ForceSynchronousImport);

						// Load the material so it's usable
						mat = replacedetDatabase.LoadreplacedetAtPath(matPath, typeof(Material)) as Material;
					}
					else replacedetDatabase.Refresh(ImportreplacedetOptions.ForceSynchronousImport);

					// Re-load the texture
					tex = replacedetDatabase.LoadreplacedetAtPath(texPath, typeof(Texture2D)) as Texture2D;

					// replacedign the texture
					mat.mainTexture = tex;
					NGUISettings.fontTexture = tex;

					uiFont.atlas = null;
					uiFont.material = mat;
				}
			}
			else return;
		}

		if (prefab != null)
		{
			// Update the prefab
			PrefabUtility.ReplacePrefab(go, prefab);
			DestroyImmediate(go);
			replacedetDatabase.Refresh(ImportreplacedetOptions.ForceSynchronousImport);

			// Select the atlas
			go = replacedetDatabase.LoadreplacedetAtPath(prefabPath, typeof(GameObject)) as GameObject;
			uiFont = go.GetComponent<UIFont>();
		}

		if (uiFont != null)
		{
			NGUISettings.FMFont = null;
			NGUISettings.BMFont = uiFont;
		}
		MarkAsChanged();
		Selection.activeGameObject = go;
	}

19 View Source File : UILabelInspector.cs
License : MIT License
Project Creator : XINCGer

protected override bool ShouldDrawProperties ()
	{
		mLabel = mWidget as UILabel;

		GUILayout.BeginHorizontal();

#if DYNAMIC_FONT
		mFontType = (FontType)EditorGUILayout.EnumPopup(mFontType, "DropDown", GUILayout.Width(74f));
		if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(64f)))
#else
		mFontType = FontType.NGUI;
		if (NGUIEditorTools.DrawPrefixButton("Font", GUILayout.Width(74f)))
#endif
		{
			if (mFontType == FontType.NGUI)
			{
				ComponentSelector.Show<UIFont>(OnNGUIFont);
			}
			else
			{
				ComponentSelector.Show<Font>(OnUnityFont, new string[] { ".ttf", ".otf" });
			}
		}

		bool isValid = false;
		SerializedProperty fnt = null;
		SerializedProperty ttf = null;

		if (mFontType == FontType.NGUI)
		{
			GUI.changed = false;
			fnt = NGUIEditorTools.DrawProperty("", serializedObject, "mFont", GUILayout.MinWidth(40f));

			if (fnt.objectReferenceValue != null)
			{
				if (GUI.changed) serializedObject.FindProperty("mTrueTypeFont").objectReferenceValue = null;
				NGUISettings.ambigiousFont = fnt.objectReferenceValue;
				isValid = true;
			}
		}
		else
		{
			GUI.changed = false;
			ttf = NGUIEditorTools.DrawProperty("", serializedObject, "mTrueTypeFont", GUILayout.MinWidth(40f));

			if (ttf.objectReferenceValue != null)
			{
				if (GUI.changed) serializedObject.FindProperty("mFont").objectReferenceValue = null;
				NGUISettings.ambigiousFont = ttf.objectReferenceValue;
				isValid = true;
			}
		}

		GUILayout.EndHorizontal();

		if (mFontType == FontType.Unity)
		{
			EditorGUILayout.HelpBox("Dynamic fonts suffer from issues in Unity itself where your characters may disappear, get garbled, or just not show at times. Use this feature at your own risk.\n\n" +
				"When you do run into such issues, please submit a Bug Report to Unity via Help -> Report a Bug (as this is will be a Unity bug, not an NGUI one).", MessageType.Warning);
		}

		NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");

		EditorGUI.BeginDisabledGroup(!isValid);
		{
			UIFont uiFont = (fnt != null) ? fnt.objectReferenceValue as UIFont : null;
			Font dynFont = (ttf != null) ? ttf.objectReferenceValue as Font : null;

			if (uiFont != null && uiFont.isDynamic)
			{
				dynFont = uiFont.dynamicFont;
				uiFont = null;
			}

			if (dynFont != null)
			{
				GUILayout.BeginHorizontal();
				{
					EditorGUI.BeginDisabledGroup((ttf != null) ? ttf.hasMultipleDifferentValues : fnt.hasMultipleDifferentValues);
					
					SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));
					NGUISettings.fontSize = prop.intValue;
					
					prop = NGUIEditorTools.DrawProperty("", serializedObject, "mFontStyle", GUILayout.MinWidth(40f));
					NGUISettings.fontStyle = (FontStyle)prop.intValue;
					
					NGUIEditorTools.DrawPadding();
					EditorGUI.EndDisabledGroup();
				}
				GUILayout.EndHorizontal();
			}
			else if (uiFont != null)
			{
				GUILayout.BeginHorizontal();
				SerializedProperty prop = NGUIEditorTools.DrawProperty("Font Size", serializedObject, "mFontSize", GUILayout.Width(142f));

				EditorGUI.BeginDisabledGroup(true);
				if (!serializedObject.isEditingMultipleObjects)
				{
					if (mLabel.overflowMethod == UILabel.Overflow.ShrinkContent)
						GUILayout.Label(" Actual: " + mLabel.finalFontSize + "/" + mLabel.defaultFontSize);
					else GUILayout.Label(" Default: " + mLabel.defaultFontSize);
				}
				EditorGUI.EndDisabledGroup();

				NGUISettings.fontSize = prop.intValue;
				GUILayout.EndHorizontal();
			}

			bool ww = GUI.skin.textField.wordWrap;
			GUI.skin.textField.wordWrap = true;
			SerializedProperty sp = serializedObject.FindProperty("mText");

			if (sp.hasMultipleDifferentValues)
			{
				NGUIEditorTools.DrawProperty("", sp, GUILayout.Height(128f));
			}
			else
			{
				GUIStyle style = new GUIStyle(EditorStyles.textField);
				style.wordWrap = true;

				float height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 100f);
				bool offset = true;

				if (height > 90f)
				{
					offset = false;
					height = style.CalcHeight(new GUIContent(sp.stringValue), Screen.width - 20f);
				}
				else
				{
					GUILayout.BeginHorizontal();
					GUILayout.BeginVertical(GUILayout.Width(76f));
					GUILayout.Space(3f);
					GUILayout.Label("Text");
					GUILayout.EndVertical();
					GUILayout.BeginVertical();
				}
				Rect rect = EditorGUILayout.GetControlRect(GUILayout.Height(height));

				GUI.changed = false;
				string text = EditorGUI.TextArea(rect, sp.stringValue, style);
				if (GUI.changed) sp.stringValue = text;

				if (offset)
				{
					GUILayout.EndVertical();
					GUILayout.EndHorizontal();
				}
			}

			GUI.skin.textField.wordWrap = ww;

			NGUIEditorTools.DrawPaddedProperty("Modifier", serializedObject, "mModifier");

			SerializedProperty ov = NGUIEditorTools.DrawPaddedProperty("Overflow", serializedObject, "mOverflow");
			NGUISettings.overflowStyle = (UILabel.Overflow)ov.intValue;
			if (NGUISettings.overflowStyle == UILabel.Overflow.ClampContent)
				NGUIEditorTools.DrawProperty("Use Ellipsis", serializedObject, "mOverflowEllipsis", GUILayout.Width(110f));

			if (NGUISettings.overflowStyle == UILabel.Overflow.ResizeFreely)
			{
				GUILayout.BeginHorizontal();
				SerializedProperty s = NGUIEditorTools.DrawPaddedProperty("Max Width", serializedObject, "mOverflowWidth");
				if (s != null && s.intValue < 1) GUILayout.Label("unlimited");
				GUILayout.EndHorizontal();
			}

			NGUIEditorTools.DrawPaddedProperty("Alignment", serializedObject, "mAlignment");

			if (dynFont != null)
				NGUIEditorTools.DrawPaddedProperty("Keep crisp", serializedObject, "keepCrispWhenShrunk");

			EditorGUI.BeginDisabledGroup(mLabel.bitmapFont != null && mLabel.bitmapFont.packedFontShader);
			GUILayout.BeginHorizontal();
			SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient",
			GUILayout.Width(95f));

			EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
			{
				NGUIEditorTools.SetLabelWidth(30f);
				NGUIEditorTools.DrawProperty("Top", serializedObject, "mGradientTop", GUILayout.MinWidth(40f));
				GUILayout.EndHorizontal();
				GUILayout.BeginHorizontal();
				NGUIEditorTools.SetLabelWidth(50f);
				GUILayout.Space(79f);

				NGUIEditorTools.DrawProperty("Bottom", serializedObject, "mGradientBottom", GUILayout.MinWidth(40f));
				NGUIEditorTools.SetLabelWidth(80f);
			}
			EditorGUI.EndDisabledGroup();
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			GUILayout.Label("Effect", GUILayout.Width(76f));
			sp = NGUIEditorTools.DrawProperty("", serializedObject, "mEffectStyle", GUILayout.MinWidth(16f));

			EditorGUI.BeginDisabledGroup(!sp.hasMultipleDifferentValues && !sp.boolValue);
			{
				NGUIEditorTools.DrawProperty("", serializedObject, "mEffectColor", GUILayout.MinWidth(10f));
				GUILayout.EndHorizontal();

				GUILayout.BeginHorizontal();
				{
					GUILayout.Label(" ", GUILayout.Width(56f));
					NGUIEditorTools.SetLabelWidth(20f);
					NGUIEditorTools.DrawProperty("X", serializedObject, "mEffectDistance.x", GUILayout.MinWidth(40f));
					NGUIEditorTools.DrawProperty("Y", serializedObject, "mEffectDistance.y", GUILayout.MinWidth(40f));
					NGUIEditorTools.DrawPadding();
					NGUIEditorTools.SetLabelWidth(80f);
				}
			}
			EditorGUI.EndDisabledGroup();
			GUILayout.EndHorizontal();
			EditorGUI.EndDisabledGroup();

			sp = NGUIEditorTools.DrawProperty("Float spacing", serializedObject, "mUseFloatSpacing", GUILayout.Width(100f));

			if (!sp.boolValue)
			{
				GUILayout.BeginHorizontal();
				GUILayout.Label("Spacing", GUILayout.Width(56f));
				NGUIEditorTools.SetLabelWidth(20f);
				NGUIEditorTools.DrawProperty("X", serializedObject, "mSpacingX", GUILayout.MinWidth(40f));
				NGUIEditorTools.DrawProperty("Y", serializedObject, "mSpacingY", GUILayout.MinWidth(40f));
				NGUIEditorTools.DrawPadding();
				NGUIEditorTools.SetLabelWidth(80f);
				GUILayout.EndHorizontal();
			}
			else
			{
				GUILayout.BeginHorizontal();
				GUILayout.Label("Spacing", GUILayout.Width(56f));
				NGUIEditorTools.SetLabelWidth(20f);
				NGUIEditorTools.DrawProperty("X", serializedObject, "mFloatSpacingX", GUILayout.MinWidth(40f));
				NGUIEditorTools.DrawProperty("Y", serializedObject, "mFloatSpacingY", GUILayout.MinWidth(40f));
				NGUIEditorTools.DrawPadding();
				NGUIEditorTools.SetLabelWidth(80f);
				GUILayout.EndHorizontal();
			}
			
			NGUIEditorTools.DrawProperty("Max Lines", serializedObject, "mMaxLineCount", GUILayout.Width(110f));

			GUILayout.BeginHorizontal();
			sp = NGUIEditorTools.DrawProperty("BBCode", serializedObject, "mEncoding", GUILayout.Width(100f));
			EditorGUI.BeginDisabledGroup(!sp.boolValue || mLabel.bitmapFont == null || !mLabel.bitmapFont.hreplacedymbols);
			NGUIEditorTools.SetLabelWidth(60f);
			NGUIEditorTools.DrawPaddedProperty("Symbols", serializedObject, "mSymbols");
			NGUIEditorTools.SetLabelWidth(80f);
			EditorGUI.EndDisabledGroup();
			GUILayout.EndHorizontal();
		}
		EditorGUI.EndDisabledGroup();
		return isValid;
	}

19 View Source File : UIPanelInspector.cs
License : MIT License
Project Creator : XINCGer

protected override bool ShouldDrawProperties ()
	{
		float alpha = EditorGUILayout.Slider("Alpha", mPanel.alpha, 0f, 1f);

		if (alpha != mPanel.alpha)
		{
			NGUIEditorTools.RegisterUndo("Panel Alpha", mPanel);
			mPanel.alpha = alpha;
		}

		GUILayout.BeginHorizontal();
		{
			EditorGUILayout.PrefixLabel("Depth");

			int depth = mPanel.depth;
			if (GUILayout.Button("Back", GUILayout.Width(60f))) --depth;
			depth = EditorGUILayout.IntField(depth, GUILayout.MinWidth(20f));
			if (GUILayout.Button("Forward", GUILayout.Width(68f))) ++depth;

			if (mPanel.depth != depth)
			{
				NGUIEditorTools.RegisterUndo("Panel Depth", mPanel);
				mPanel.depth = depth;

				if (UIPanelTool.instance != null)
					UIPanelTool.instance.Repaint();

				if (UIDrawCallViewer.instance != null)
					UIDrawCallViewer.instance.Repaint();
			}
		}
		GUILayout.EndHorizontal();

		int matchingDepths = 0;

		for (int i = 0, imax = UIPanel.list.Count; i < imax; ++i)
		{
			UIPanel p = UIPanel.list[i];
			if (p != null && mPanel.depth == p.depth)
				++matchingDepths;
		}

		if (matchingDepths > 1)
		{
			EditorGUILayout.HelpBox(matchingDepths + " panels are sharing the depth value of " + mPanel.depth, MessageType.Warning);
		}

		UIDrawCall.Clipping clipping = (UIDrawCall.Clipping)EditorGUILayout.EnumPopup("Clipping", mPanel.clipping);

		if (mPanel.clipping != clipping)
		{
			mPanel.clipping = clipping;
			EditorUtility.SetDirty(mPanel);
		}

		// Contributed by Benzino07: http://www.tasharen.com/forum/index.php?topic=6956.15
		GUILayout.BeginHorizontal();
		{
			EditorGUILayout.PrefixLabel("Sorting Layer");

			// Get the names of the Sorting layers
			System.Type internalEditorUtilityType = typeof(InternalEditorUtility);
			PropertyInfo sortingLayersProperty = internalEditorUtilityType.GetProperty("sortingLayerNames", BindingFlags.Static | BindingFlags.NonPublic);
			string[] names = (string[])sortingLayersProperty.GetValue(null, new object[0]);

			int index = 0;
			if (!string.IsNullOrEmpty(mPanel.sortingLayerName))
			{
				for (int i = 0; i < names.Length; i++)
				{
					if (mPanel.sortingLayerName == names[i])
					{
						index = i;
						break;
					}
				}
			}

			// Get the selected index and update the panel sorting layer if it has changed
			int selectedIndex = EditorGUILayout.Popup(index, names);

			if (index != selectedIndex)
			{
				mPanel.sortingLayerName = names[selectedIndex];
				EditorUtility.SetDirty(mPanel);
			}
		}
		GUILayout.EndHorizontal();

		if (mPanel.clipping != UIDrawCall.Clipping.None)
		{
			Vector4 range = mPanel.baseClipRegion;

			// Scroll view is ancreplacedd, meaning it adjusts the offset itself, so we don't want it to be modifiable
			//EditorGUI.BeginDisabledGroup(mPanel.GetComponent<UIScrollView>() != null);
			GUI.changed = false;
			GUILayout.BeginHorizontal();
			GUILayout.Space(80f);
			Vector3 off = EditorGUILayout.Vector2Field("Offset", mPanel.clipOffset, GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (GUI.changed)
			{
				NGUIEditorTools.RegisterUndo("Clipping Change", mPanel);
				mPanel.clipOffset = off;
				EditorUtility.SetDirty(mPanel);
			}
			//EditorGUI.EndDisabledGroup();

			GUILayout.BeginHorizontal();
			GUILayout.Space(80f);
			Vector2 pos = EditorGUILayout.Vector2Field("Center", new Vector2(range.x, range.y), GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			GUILayout.Space(80f);
			Vector2 size = EditorGUILayout.Vector2Field("Size", new Vector2(range.z, range.w), GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (size.x < 0f) size.x = 0f;
			if (size.y < 0f) size.y = 0f;

			range.x = pos.x;
			range.y = pos.y;
			range.z = size.x;
			range.w = size.y;

			if (mPanel.baseClipRegion != range)
			{
				NGUIEditorTools.RegisterUndo("Clipping Change", mPanel);
				mPanel.baseClipRegion = range;
				EditorUtility.SetDirty(mPanel);
			}

			if (mPanel.clipping == UIDrawCall.Clipping.SoftClip)
			{
				GUILayout.BeginHorizontal();
				GUILayout.Space(80f);
				Vector2 soft = EditorGUILayout.Vector2Field("Softness", mPanel.clipSoftness, GUILayout.MinWidth(20f));
				GUILayout.EndHorizontal();

				if (soft.x < 0f) soft.x = 0f;
				if (soft.y < 0f) soft.y = 0f;

				if (mPanel.clipSoftness != soft)
				{
					NGUIEditorTools.RegisterUndo("Clipping Change", mPanel);
					mPanel.clipSoftness = soft;
					EditorUtility.SetDirty(mPanel);
				}
			}
			else if (mPanel.clipping == UIDrawCall.Clipping.TextureMask)
			{
				NGUIEditorTools.SetLabelWidth(0f);
				GUILayout.Space(-90f);
				Texture2D tex = (Texture2D)EditorGUILayout.ObjectField(mPanel.clipTexture,
					typeof(Texture2D), false, GUILayout.Width(70f), GUILayout.Height(70f));
				GUILayout.Space(20f);

				if (mPanel.clipTexture != tex)
				{
					NGUIEditorTools.RegisterUndo("Clipping Change", mPanel);
					mPanel.clipTexture = tex;
					EditorUtility.SetDirty(mPanel);
				}
				NGUIEditorTools.SetLabelWidth(80f);
			}
		}

		if (clipping != UIDrawCall.Clipping.None && !NGUIEditorTools.IsUniform(mPanel.transform.lossyScale))
		{
			EditorGUILayout.HelpBox("Clipped panels must have a uniform scale, or clipping won't work properly!", MessageType.Error);

			if (GUILayout.Button("Auto-fix"))
			{
				NGUIEditorTools.FixUniform(mPanel.gameObject);
			}
		}

		if (NGUIEditorTools.DrawHeader("Advanced Options"))
		{
			NGUIEditorTools.BeginContents();

			GUILayout.BeginHorizontal();
			UIPanel.RenderQueue rq = (UIPanel.RenderQueue)EditorGUILayout.EnumPopup("Render Q", mPanel.renderQueue);

			if (mPanel.renderQueue != rq)
			{
				mPanel.renderQueue = rq;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
				if (UIDrawCallViewer.instance != null)
					UIDrawCallViewer.instance.Repaint();
			}

			if (rq != UIPanel.RenderQueue.Automatic)
			{
				int sq = EditorGUILayout.IntField(mPanel.startingRenderQueue, GUILayout.Width(40f));

				if (mPanel.startingRenderQueue != sq)
				{
					mPanel.startingRenderQueue = sq;
					mPanel.RebuildAllDrawCalls();
					EditorUtility.SetDirty(mPanel);
					if (UIDrawCallViewer.instance != null)
						UIDrawCallViewer.instance.Repaint();
				}
			}
			GUILayout.EndHorizontal();

			GUI.changed = false;
			GUILayout.BeginHorizontal();
			int so = EditorGUILayout.IntField("Sort Order", mPanel.sortingOrder, GUILayout.Width(120f));
			if (so == 0) GUILayout.Label("Automatic", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();
			if (GUI.changed) mPanel.sortingOrder = so;

			GUILayout.BeginHorizontal();
			bool norms = EditorGUILayout.Toggle("Normals", mPanel.generateNormals, GUILayout.Width(100f));
			GUILayout.Label("Needed for lit shaders", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (mPanel.generateNormals != norms)
			{
				mPanel.generateNormals = norms;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
			}

			GUILayout.BeginHorizontal();
			bool uv2 = EditorGUILayout.Toggle("UV2", mPanel.generateUV2, GUILayout.Width(100f));
			GUILayout.Label("For custom shader effects", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (mPanel.generateUV2 != uv2)
			{
				mPanel.generateUV2 = uv2;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
			}
#if !UNITY_4_7
			serializedObject.DrawProperty("shadowMode");
#endif
			GUILayout.BeginHorizontal();
			bool cull = EditorGUILayout.Toggle("Cull", mPanel.cullWhileDragging, GUILayout.Width(100f));
			GUILayout.Label("Cull widgets while dragging them", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (mPanel.cullWhileDragging != cull)
			{
				mPanel.cullWhileDragging = cull;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
			}

			GUILayout.BeginHorizontal();
			bool alw = EditorGUILayout.Toggle("Visible", mPanel.alwaysOnScreen, GUILayout.Width(100f));
			GUILayout.Label("Check if widgets never go off-screen", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (mPanel.alwaysOnScreen != alw)
			{
				mPanel.alwaysOnScreen = alw;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
			}

			GUILayout.BeginHorizontal();
			NGUIEditorTools.DrawProperty("Padding", serializedObject, "softBorderPadding", GUILayout.Width(100f));
			GUILayout.Label("Soft border pads content", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			EditorGUI.BeginDisabledGroup(mPanel.GetComponent<UIRoot>() != null);
			bool off = EditorGUILayout.Toggle("Offset", mPanel.anchorOffset && mPanel.GetComponent<UIRoot>() == null, GUILayout.Width(100f));
			GUILayout.Label("Offset anchors by position", GUILayout.MinWidth(20f));
			EditorGUI.EndDisabledGroup();
			GUILayout.EndHorizontal();

			if (mPanel.anchorOffset != off)
			{
				mPanel.anchorOffset = off;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
			}

			GUILayout.BeginHorizontal();
			bool stat = EditorGUILayout.Toggle("Static", mPanel.widgetsAreStatic, GUILayout.Width(100f));
			GUILayout.Label("Check if widgets won't move", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();

			if (mPanel.widgetsAreStatic != stat)
			{
				mPanel.widgetsAreStatic = stat;
				mPanel.RebuildAllDrawCalls();
				EditorUtility.SetDirty(mPanel);
			}

			if (stat)
			{
				EditorGUILayout.HelpBox("Only mark the panel as 'static' if you know FOR CERTAIN that the widgets underneath will not move, rotate, or scale. Doing this improves performance, but moving widgets around will have no effect.", MessageType.Warning);
			}

			GUILayout.BeginHorizontal();
			bool tool = EditorGUILayout.Toggle("Panel Tool", mPanel.showInPanelTool, GUILayout.Width(100f));
			GUILayout.Label("Show in panel tool");
			GUILayout.EndHorizontal();

			if (mPanel.showInPanelTool != tool)
			{
				mPanel.showInPanelTool = !mPanel.showInPanelTool;
				EditorUtility.SetDirty(mPanel);
				EditorWindow.FocusWindowIfItsOpen<UIPanelTool>();
			}
			NGUIEditorTools.EndContents();
		}
		return true;
	}

19 View Source File : UIPopupListInspector.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		serializedObject.Update();
		NGUIEditorTools.SetLabelWidth(80f);

		GUILayout.BeginHorizontal();
		GUILayout.Space(6f);
		GUILayout.Label("Options");
		GUILayout.EndHorizontal();

		string text = "";
		foreach (string s in mList.items) text += s + "\n";

		GUILayout.Space(-14f);
		GUILayout.BeginHorizontal();
		GUILayout.Space(84f);
		string modified = EditorGUILayout.TextArea(text, GUILayout.Height(100f));
		GUILayout.EndHorizontal();

		if (modified != text)
		{
			RegisterUndo();
			string[] split = modified.Split(new char[] { '\n' }, System.StringSplitOptions.RemoveEmptyEntries);
			mList.items.Clear();
			foreach (string s in split) mList.items.Add(s);

			if (string.IsNullOrEmpty(mList.value) || !mList.items.Contains(mList.value))
			{
				mList.value = mList.items.Count > 0 ? mList.items[0] : "";
			}
		}

		NGUIEditorTools.DrawProperty("Position", serializedObject, "position");
		NGUIEditorTools.DrawProperty("Alignment", serializedObject, "alignment");
		NGUIEditorTools.DrawProperty("Open on", serializedObject, "openOn");
		NGUIEditorTools.DrawProperty("On Top", serializedObject, "separatePanel");
		NGUIEditorTools.DrawProperty("Localized", serializedObject, "isLocalized");

		GUI.changed = false;
		var sp = NGUIEditorTools.DrawProperty("Keep Value", serializedObject, "keepValue");

		if (GUI.changed)
		{
			serializedObject.FindProperty("mSelectedItem").stringValue = (sp.boolValue && mList.items.Count > 0) ? mList.items[0] : "";
		}

		EditorGUI.BeginDisabledGroup(!sp.boolValue);
		{
			GUI.changed = false;
			string sel = NGUIEditorTools.DrawList("Initial Value", mList.items.ToArray(), mList.value);
			if (GUI.changed) serializedObject.FindProperty("mSelectedItem").stringValue = sel;
		}
		EditorGUI.EndDisabledGroup();

		DrawAtlas();
		DrawFont();

		NGUIEditorTools.DrawEvents("On Value Change", mList, mList.onChange);

		serializedObject.ApplyModifiedProperties();
	}

19 View Source File : UIPopupListInspector.cs
License : MIT License
Project Creator : XINCGer

void DrawAtlas()
	{
		if (NGUIEditorTools.DrawHeader("Atlas"))
		{
			NGUIEditorTools.BeginContents();

			SerializedProperty atlreplacedp = null;

			GUILayout.BeginHorizontal();
			{
				if (NGUIEditorTools.DrawPrefixButton("Atlas"))
					ComponentSelector.Show<UIAtlas>(OnSelectAtlas);
				atlreplacedp = NGUIEditorTools.DrawProperty("", serializedObject, "atlas");
			}
			GUILayout.EndHorizontal();

			if (atlreplacedp != null && atlreplacedp.objectReferenceValue != null)
			{
				NGUIEditorTools.DrawPaddedSpriteField("Background", mList.atlas, mList.backgroundSprite, OnBackground);
				NGUIEditorTools.DrawPaddedSpriteField("Highlight", mList.atlas, mList.highlightSprite, OnHighlight);
			}
			else
			{
				serializedObject.DrawProperty("background2DSprite", "Background");
				serializedObject.DrawProperty("highlight2DSprite", "Highlight");
			}

			EditorGUILayout.Space();

			NGUIEditorTools.DrawProperty("Background", serializedObject, "backgroundColor");
			NGUIEditorTools.DrawProperty("Highlight", serializedObject, "highlightColor");
			NGUIEditorTools.DrawProperty("Overlap", serializedObject, "overlap", GUILayout.Width(110f));
			NGUIEditorTools.DrawProperty("Animated", serializedObject, "isAnimated");
			NGUIEditorTools.EndContents();
		}
	}

19 View Source File : UIRectEditor.cs
License : MIT License
Project Creator : XINCGer

protected void DrawAnchor (int index, bool targetSelection)
	{
		//if (targetSelection) GUILayout.Space(3f);

		//NGUIEditorTools.SetLabelWidth(16f);
		GUILayout.BeginHorizontal();
		GUILayout.Label(PrefixName[index], GUILayout.Width(NGUISettings.minimalisticLook ? 65f : 56f));

		UIRect myRect = serializedObject.targetObject as UIRect;
		string name = FieldName[index];

		SerializedProperty tar = serializedObject.FindProperty(name + ".target");
		SerializedProperty rel = serializedObject.FindProperty(name + ".relative");
		SerializedProperty abs = serializedObject.FindProperty(name + ".absolute");

		if (targetSelection)
		{
			Object before = tar.objectReferenceValue;
			NGUIEditorTools.DrawProperty("", tar, false, GUILayout.MinWidth(20f));
			Object after = tar.objectReferenceValue;

			if (after != null || tar.hasMultipleDifferentValues)
			{
				if (before != after && after != null)
					UpdateAnchor(index, true);
			}

			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal();
			GUILayout.Label(" ", GUILayout.Width(NGUISettings.minimalisticLook ? 65f : 56f));
		}

		UIRect targetRect = GetRect(tar);
		Camera targetCam = GetCamera(tar);
		float relative = rel.floatValue;
		bool isCommon = (targetRect == null && targetCam == null) || IsCommon(relative);
		int previousOrigin = 1;

		if (targetRect != null || targetCam != null)
		{
			if (mCustom[index] || !isCommon) previousOrigin = 3;
			else if (relative == 0f) previousOrigin = 0;
			else if (relative == 1f) previousOrigin = 2;
		}

		// Draw the origin selection list
		EditorGUI.BeginDisabledGroup(targetRect == null && targetCam == null);
		int newOrigin = IsHorizontal[index] ?
			EditorGUILayout.Popup(previousOrigin, HorizontalList) :
			EditorGUILayout.Popup(previousOrigin, VerticalList);
		EditorGUI.EndDisabledGroup();

		// "Set to Current" choice
		if (newOrigin == 4)
		{
			newOrigin = 3;

			Vector3[] sides = targetRect.GetSides(myRect.cachedTransform);

			float f0, f1;

			if (IsHorizontal[index])
			{
				f0 = sides[0].x;
				f1 = sides[2].x;
			}
			else
			{
				f0 = sides[3].y;
				f1 = sides[1].y;
			}

			// Final position after both relative and absolute values are taken into consideration
			float final = Mathf.Floor(0.5f + Mathf.Lerp(0f, f1 - f0, rel.floatValue) + abs.intValue);

			rel.floatValue = final / (f1 - f0);
			abs.intValue = 0;

			serializedObject.ApplyModifiedProperties();
			serializedObject.Update();
		}

		mCustom[index] = (newOrigin == 3);

		// If the origin changes
		if (newOrigin != 3 && previousOrigin != newOrigin)
		{
			// Desired relative value
			if (newOrigin == 0) relative = 0f;
			else if (newOrigin == 2) relative = 1f;
			else relative = 0.5f;

			Vector3[] sides = (targetRect != null) ?
				targetRect.GetSides(myRect.cachedTransform) :
				targetCam.GetSides(myRect.cachedTransform);

			// Calculate the current position based from the bottom-left
			float f0, f1;

			if (IsHorizontal[index])
			{
				f0 = sides[0].x;
				f1 = sides[2].x;
			}
			else
			{
				f0 = sides[3].y;
				f1 = sides[1].y;
			}

			// Final position after both relative and absolute values are taken into consideration
			float final = Mathf.Floor(0.5f + Mathf.Lerp(f0, f1, rel.floatValue) + abs.intValue);

			rel.floatValue = relative;
			abs.intValue = Mathf.FloorToInt(final + 0.5f - Mathf.Lerp(f0, f1, relative));

			serializedObject.ApplyModifiedProperties();
			serializedObject.Update();
		}

		if (mCustom[index])
		{
			// Draw the relative value
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal();
			GUILayout.Space(64f);

			relative = rel.floatValue;
			bool isOutside01 = relative < 0f || relative > 1f;

			// Horizontal slider for relative values, for convenience
			//EditorGUI.BeginDisabledGroup(isOutside01);
			{
				GUILayout.Space(10f);
				float val = GUILayout.HorizontalSlider(relative, 0f, 1f);

				NGUIEditorTools.DrawProperty("", rel, false, GUILayout.Width(40f));

				if (!isOutside01 && val != relative)
				{
					Vector3[] sides = (targetRect != null) ?
						targetRect.GetSides(myRect.cachedTransform) :
						targetCam.GetSides(myRect.cachedTransform);

					// Calculate the current position based from the bottom-left
					float f0, f1;

					if (IsHorizontal[index])
					{
						f0 = sides[0].x;
						f1 = sides[2].x;
					}
					else
					{
						f0 = sides[3].y;
						f1 = sides[1].y;
					}

					float size = (f1 - f0);
					int intVal = Mathf.FloorToInt(val * size + 0.5f);
					//intVal = ((intVal >> 1) << 1);
					rel.floatValue = (size > 0f) ? intVal / size : 0.5f;
				}
			}
			//EditorGUI.EndDisabledGroup();
		}

		// Draw the absolute value
		NGUIEditorTools.SetLabelWidth(16f);
		NGUIEditorTools.DrawProperty("+", abs, false, GUILayout.Width(60f));
		
		GUILayout.EndHorizontal();
		NGUIEditorTools.SetLabelWidth(NGUISettings.minimalisticLook ? 69f : 62f);
	}

19 View Source File : UIScrollViewEditor.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		NGUIEditorTools.SetLabelWidth(130f);

		GUILayout.Space(3f);
		serializedObject.Update();

		SerializedProperty sppv = serializedObject.FindProperty("contentPivot");
		UIWidget.Pivot before = (UIWidget.Pivot)sppv.intValue;

		NGUIEditorTools.DrawProperty("Content Origin", sppv, false);

		SerializedProperty sp = NGUIEditorTools.DrawProperty("Movement", serializedObject, "movement");

		if (((UIScrollView.Movement)sp.intValue) == UIScrollView.Movement.Custom)
		{
			NGUIEditorTools.SetLabelWidth(20f);

			GUILayout.BeginHorizontal();
			GUILayout.Space(114f);
			NGUIEditorTools.DrawProperty("X", serializedObject, "customMovement.x", GUILayout.MinWidth(20f));
			NGUIEditorTools.DrawProperty("Y", serializedObject, "customMovement.y", GUILayout.MinWidth(20f));
			GUILayout.EndHorizontal();
		}

		NGUIEditorTools.SetLabelWidth(130f);

		NGUIEditorTools.DrawProperty("Drag Effect", serializedObject, "dragEffect");
		NGUIEditorTools.DrawProperty("Scroll Wheel Factor", serializedObject, "scrollWheelFactor");
		NGUIEditorTools.DrawProperty("Momentum Amount", serializedObject, "momentumAmount");

		NGUIEditorTools.DrawProperty("Restrict Within Panel", serializedObject, "restrictWithinPanel");
		NGUIEditorTools.DrawProperty("Constrain On Drag", serializedObject, "constrainOnDrag");
		NGUIEditorTools.DrawProperty("Cancel Drag If Fits", serializedObject, "disableDragIfFits");
		NGUIEditorTools.DrawProperty("Smooth Drag Start", serializedObject, "smoothDragStart");
		NGUIEditorTools.DrawProperty("IOS Drag Emulation", serializedObject, "iOSDragEmulation");

		NGUIEditorTools.SetLabelWidth(100f);

		if (NGUIEditorTools.DrawHeader("Scroll Bars"))
		{
			NGUIEditorTools.BeginContents();
			NGUIEditorTools.DrawProperty("Horizontal", serializedObject, "horizontalScrollBar");
			NGUIEditorTools.DrawProperty("Vertical", serializedObject, "verticalScrollBar");
			NGUIEditorTools.DrawProperty("Show Condition", serializedObject, "showScrollBars");
			NGUIEditorTools.EndContents();
		}
		serializedObject.ApplyModifiedProperties();

		if (before != (UIWidget.Pivot)sppv.intValue)
		{
			(target as UIScrollView).ResetPosition();
		}
	}

19 View Source File : UISpriteInspector.cs
License : MIT License
Project Creator : XINCGer

protected override bool ShouldDrawProperties ()
	{
		GUILayout.BeginHorizontal();
		if (NGUIEditorTools.DrawPrefixButton("Atlas"))
			ComponentSelector.Show<UIAtlas>(OnSelectAtlas);
		SerializedProperty atlas = NGUIEditorTools.DrawProperty("", serializedObject, "mAtlas", GUILayout.MinWidth(20f));
		
		if (GUILayout.Button("Edit", GUILayout.Width(40f)))
		{
			if (atlas != null)
			{
				UIAtlas atl = atlas.objectReferenceValue as UIAtlas;
				NGUISettings.atlas = atl;
				if (atl != null) NGUIEditorTools.Select(atl.gameObject);
			}
		}
		GUILayout.EndHorizontal();

		SerializedProperty sp = serializedObject.FindProperty("mSpriteName");
		NGUIEditorTools.DrawAdvancedSpriteField(atlas.objectReferenceValue as UIAtlas, sp.stringValue, SelectSprite, false);

		NGUIEditorTools.DrawProperty("Material", serializedObject, "mMat");
		return true;
	}

19 View Source File : UIToggleInspector.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		serializedObject.Update();

		NGUIEditorTools.SetLabelWidth(100f);
		UIToggle toggle = target as UIToggle;

		GUILayout.Space(6f);
		GUI.changed = false;

		GUILayout.BeginHorizontal();
		SerializedProperty sp = NGUIEditorTools.DrawProperty("Group", serializedObject, "group", GUILayout.Width(120f));
		GUILayout.Label(" - zero means 'none'");
		GUILayout.EndHorizontal();

		EditorGUI.BeginDisabledGroup(sp.intValue == 0);
		NGUIEditorTools.DrawProperty("  State of 'None'", serializedObject, "optionCanBeNone");
		EditorGUI.EndDisabledGroup();

		NGUIEditorTools.DrawProperty("Starting State", serializedObject, "startsActive");
		NGUIEditorTools.SetLabelWidth(80f);

		if (NGUIEditorTools.DrawMinimalisticHeader("State Transition"))
		{
			NGUIEditorTools.BeginContents(true);

			SerializedProperty sprite = serializedObject.FindProperty("activeSprite");
			SerializedProperty animator = serializedObject.FindProperty("animator");
			SerializedProperty animation = serializedObject.FindProperty("activeAnimation");
			SerializedProperty tween = serializedObject.FindProperty("tween");

			if (sprite.objectReferenceValue != null)
			{
				NGUIEditorTools.DrawProperty("Sprite", sprite, false);
				serializedObject.DrawProperty("invertSpriteState");
			}
			else if (animator.objectReferenceValue != null)
			{
				NGUIEditorTools.DrawProperty("Animator", animator, false);
			}
			else if (animation.objectReferenceValue != null)
			{
				NGUIEditorTools.DrawProperty("Animation", animation, false);
			}
			else if (tween.objectReferenceValue != null)
			{
				NGUIEditorTools.DrawProperty("Tween", tween, false);
			}
			else
			{
				NGUIEditorTools.DrawProperty("Sprite", serializedObject, "activeSprite");
				NGUIEditorTools.DrawProperty("Animator", animator, false);
				NGUIEditorTools.DrawProperty("Animation", animation, false);
				NGUIEditorTools.DrawProperty("Tween", tween, false);
			}

			if (serializedObject.isEditingMultipleObjects)
			{
				NGUIEditorTools.DrawProperty("Instant", serializedObject, "instantTween");
			}
			else
			{
				GUI.changed = false;
				Transition tr = toggle.instantTween ? Transition.Instant : Transition.Smooth;
				GUILayout.BeginHorizontal();
				tr = (Transition)EditorGUILayout.EnumPopup("Transition", tr);
				NGUIEditorTools.DrawPadding();
				GUILayout.EndHorizontal();

				if (GUI.changed)
				{
					NGUIEditorTools.RegisterUndo("Toggle Change", toggle);
					toggle.instantTween = (tr == Transition.Instant);
					NGUITools.SetDirty(toggle);
				}
			}
			NGUIEditorTools.EndContents();
		}

		NGUIEditorTools.DrawEvents("On Value Change", toggle, toggle.onChange);
		serializedObject.ApplyModifiedProperties();
	}

19 View Source File : UITweenerEditor.cs
License : MIT License
Project Creator : XINCGer

protected void DrawCommonProperties ()
	{
		UITweener tw = target as UITweener;

		if (NGUIEditorTools.DrawHeader("Tweener"))
		{
			NGUIEditorTools.BeginContents();
			NGUIEditorTools.SetLabelWidth(110f);

			GUI.changed = false;

			UITweener.Style style = (UITweener.Style)EditorGUILayout.EnumPopup("Play Style", tw.style);
			AnimationCurve curve = EditorGUILayout.CurveField("Animation Curve", tw.animationCurve, GUILayout.Width(170f), GUILayout.Height(62f));
			//UITweener.Method method = (UITweener.Method)EditorGUILayout.EnumPopup("Play Method", tw.method);

			GUILayout.BeginHorizontal();
			float dur = EditorGUILayout.FloatField("Duration", tw.duration, GUILayout.Width(170f));
			GUILayout.Label("seconds");
			GUILayout.EndHorizontal();

			GUILayout.BeginHorizontal();
			float del = EditorGUILayout.FloatField("Start Delay", tw.delay, GUILayout.Width(170f));
			GUILayout.Label("seconds");
			GUILayout.EndHorizontal();

			int tg = EditorGUILayout.IntField("Tween Group", tw.tweenGroup, GUILayout.Width(170f));
			bool ts = EditorGUILayout.Toggle("Ignore TimeScale", tw.ignoreTimeScale);
			bool fx = EditorGUILayout.Toggle("Use Fixed Update", tw.useFixedUpdate);

			if (GUI.changed)
			{
				NGUIEditorTools.RegisterUndo("Tween Change", tw);
				tw.animationCurve = curve;
				//tw.method = method;
				tw.style = style;
				tw.ignoreTimeScale = ts;
				tw.tweenGroup = tg;
				tw.duration = dur;
				tw.delay = del;
				tw.useFixedUpdate = fx;
				NGUITools.SetDirty(tw);
			}
			NGUIEditorTools.EndContents();
		}

		NGUIEditorTools.SetLabelWidth(80f);
		NGUIEditorTools.DrawEvents("On Finished", tw, tw.onFinished);
	}

19 View Source File : UIWrapContentEditor.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		GUILayout.Space(6f);
		NGUIEditorTools.SetLabelWidth(90f);

		string fieldName = "Item Size";
		string error = null;
		UIScrollView sv = null;

		if (!serializedObject.isEditingMultipleObjects)
		{
			UIWrapContent list = target as UIWrapContent;
			sv = NGUITools.FindInParents<UIScrollView>(list.gameObject);

			if (sv == null)
			{
				error = "UIWrappedList needs a Scroll View on its parent in order to work properly";
			}
			else if (sv.movement == UIScrollView.Movement.Horizontal) fieldName = "Item Width";
			else if (sv.movement == UIScrollView.Movement.Vertical) fieldName = "Item Height";
			else
			{
				error = "Scroll View needs to be using Horizontal or Vertical movement";
			}
		}

		serializedObject.Update();
		GUILayout.BeginHorizontal();
		NGUIEditorTools.DrawProperty(fieldName, serializedObject, "itemSize", GUILayout.Width(130f));
		GUILayout.Label("pixels");
		GUILayout.EndHorizontal();

		GUILayout.BeginHorizontal();
		SerializedProperty sp1 = NGUIEditorTools.DrawProperty("Range Limit", serializedObject, "minIndex", GUILayout.Width(130f));
		NGUIEditorTools.SetLabelWidth(20f);
		SerializedProperty sp2 = NGUIEditorTools.DrawProperty("to", serializedObject, "maxIndex", GUILayout.Width(60f));
		NGUIEditorTools.SetLabelWidth(90f);
		if (sp1.intValue == sp2.intValue) GUILayout.Label("unlimited");
		GUILayout.EndHorizontal();

		serializedObject.DrawProperty("hideInactive");

		NGUIEditorTools.DrawProperty("Cull Content", serializedObject, "cullContent");

		if (!string.IsNullOrEmpty(error))
		{
			EditorGUILayout.HelpBox(error, MessageType.Error);
			if (sv != null && GUILayout.Button("Select the Scroll View"))
				Selection.activeGameObject = sv.gameObject;
		}

		serializedObject.ApplyModifiedProperties();

		if (sp1.intValue != sp2.intValue)
		{
			if ((target as UIWrapContent).GetComponent<UICenterOnChild>() != null)
			{
				EditorGUILayout.HelpBox("Limiting indices doesn't play well with UICenterOnChild. You should either not limit the indices, or not use UICenterOnChild.", MessageType.Warning);
			}
		}
	}

19 View Source File : UIAtlasInspector.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		NGUIEditorTools.SetLabelWidth(80f);
		mAtlas = target as UIAtlas;

		UISpriteData sprite = (mAtlas != null) ? mAtlas.GetSprite(NGUISettings.selectedSprite) : null;

		GUILayout.Space(6f);

		if (mAtlas.replacement != null)
		{
			mType = AtlasType.Reference;
			mReplacement = mAtlas.replacement;
		}

		GUILayout.BeginHorizontal();
		AtlasType after = (AtlasType)EditorGUILayout.EnumPopup("Atlas Type", mType);
		NGUIEditorTools.DrawPadding();
		GUILayout.EndHorizontal();

		if (mType != after)
		{
			if (after == AtlasType.Normal)
			{
				mType = AtlasType.Normal;
				OnSelectAtlas(null);
			}
			else
			{
				mType = AtlasType.Reference;
			}
		}

		if (mType == AtlasType.Reference)
		{
			ComponentSelector.Draw<UIAtlas>(mAtlas.replacement, OnSelectAtlas, true);

			GUILayout.Space(6f);
			EditorGUILayout.HelpBox("You can have one atlas simply point to " +
				"another one. This is useful if you want to be " +
				"able to quickly replace the contents of one " +
				"atlas with another one, for example for " +
				"swapping an SD atlas with an HD one, or " +
				"replacing an English atlas with a Chinese " +
				"one. All the sprites referencing this atlas " +
				"will update their references to the new one.", MessageType.Info);

			if (mReplacement != mAtlas && mAtlas.replacement != mReplacement)
			{
				NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
				mAtlas.replacement = mReplacement;
				NGUITools.SetDirty(mAtlas);
			}
			return;
		}

		//GUILayout.Space(6f);
		Material mat = EditorGUILayout.ObjectField("Material", mAtlas.spriteMaterial, typeof(Material), false) as Material;

		if (mAtlas.spriteMaterial != mat)
		{
			NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
			mAtlas.spriteMaterial = mat;

			// Ensure that this atlas has valid import settings
			if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);

			mAtlas.MarkAsChanged();
		}

		if (mat != null)
		{
			Textreplacedet ta = EditorGUILayout.ObjectField("TP Import", null, typeof(Textreplacedet), false) as Textreplacedet;

			if (ta != null)
			{
				// Ensure that this atlas has valid import settings
				if (mAtlas.texture != null) NGUIEditorTools.ImportTexture(mAtlas.texture, false, false, !mAtlas.premultipliedAlpha);

				NGUIEditorTools.RegisterUndo("Import Sprites", mAtlas);
				NGUIJson.LoadSpriteData(mAtlas, ta);
				if (sprite != null) sprite = mAtlas.GetSprite(sprite.name);
				mAtlas.MarkAsChanged();
			}

			float pixelSize = EditorGUILayout.FloatField("Pixel Size", mAtlas.pixelSize, GUILayout.Width(120f));

			if (pixelSize != mAtlas.pixelSize)
			{
				NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
				mAtlas.pixelSize = pixelSize;
			}
		}

		if (mAtlas.spriteMaterial != null)
		{
			Color blueColor = new Color(0f, 0.7f, 1f, 1f);
			Color greenColor = new Color(0.4f, 1f, 0f, 1f);

			if (sprite == null && mAtlas.spriteList.Count > 0)
			{
				string spriteName = NGUISettings.selectedSprite;
				if (!string.IsNullOrEmpty(spriteName)) sprite = mAtlas.GetSprite(spriteName);
				if (sprite == null) sprite = mAtlas.spriteList[0];
			}

			if (sprite != null)
			{
				if (sprite == null) return;
					
				Texture2D tex = mAtlas.spriteMaterial.mainTexture as Texture2D;

				if (tex != null)
				{
					if (!NGUIEditorTools.DrawHeader("Sprite Details")) return;

					NGUIEditorTools.BeginContents();

					GUILayout.Space(3f);
					NGUIEditorTools.DrawAdvancedSpriteField(mAtlas, sprite.name, SelectSprite, true);
					GUILayout.Space(6f);

					GUI.changed = false;

					GUI.backgroundColor = greenColor;
					NGUIEditorTools.IntVector sizeA = NGUIEditorTools.IntPair("Dimensions", "X", "Y", sprite.x, sprite.y);
					NGUIEditorTools.IntVector sizeB = NGUIEditorTools.IntPair(null, "Width", "Height", sprite.width, sprite.height);

					EditorGUILayout.Separator();
					GUI.backgroundColor = blueColor;
					NGUIEditorTools.IntVector borderA = NGUIEditorTools.IntPair("Border", "Left", "Right", sprite.borderLeft, sprite.borderRight);
					NGUIEditorTools.IntVector borderB = NGUIEditorTools.IntPair(null, "Bottom", "Top", sprite.borderBottom, sprite.borderTop);

					EditorGUILayout.Separator();
					GUI.backgroundColor = Color.white;
					NGUIEditorTools.IntVector padA = NGUIEditorTools.IntPair("Padding", "Left", "Right", sprite.paddingLeft, sprite.paddingRight);
					NGUIEditorTools.IntVector padB = NGUIEditorTools.IntPair(null, "Bottom", "Top", sprite.paddingBottom, sprite.paddingTop);

					if (GUI.changed)
					{
						NGUIEditorTools.RegisterUndo("Atlas Change", mAtlas);
						
						sprite.x = sizeA.x;
						sprite.y = sizeA.y;
						sprite.width = sizeB.x;
						sprite.height = sizeB.y;

						sprite.paddingLeft = padA.x;
						sprite.paddingRight = padA.y;
						sprite.paddingBottom = padB.x;
						sprite.paddingTop = padB.y;

						sprite.borderLeft = borderA.x;
						sprite.borderRight = borderA.y;
						sprite.borderBottom = borderB.x;
						sprite.borderTop = borderB.y;

						MarkSpriteAsDirty();
					}

					GUILayout.Space(3f);

					GUILayout.BeginHorizontal();

					if (GUILayout.Button("Duplicate"))
					{
						UIAtlasMaker.SpriteEntry se = UIAtlasMaker.DuplicateSprite(mAtlas, sprite.name);
						if (se != null) NGUISettings.selectedSprite = se.name;
					}

					if (GUILayout.Button("Save As..."))
					{
						string path = EditorUtility.SaveFilePanel("Save As",
							NGUISettings.currentPath, sprite.name + ".png", "png");

						if (!string.IsNullOrEmpty(path))
						{
							NGUISettings.currentPath = System.IO.Path.GetDirectoryName(path);
							UIAtlasMaker.SpriteEntry se = UIAtlasMaker.ExtractSprite(mAtlas, sprite.name);

							if (se != null)
							{
								byte[] bytes = se.tex.EncodeToPNG();
								File.WriteAllBytes(path, bytes);
								//replacedetDatabase.Importreplacedet(path);
								if (se.temporaryTexture) DestroyImmediate(se.tex);
							}
						}
					}
					GUILayout.EndHorizontal();
					NGUIEditorTools.EndContents();
				}

				if (NGUIEditorTools.DrawHeader("Modify"))
				{
					NGUIEditorTools.BeginContents();

					EditorGUILayout.BeginHorizontal();
					GUILayout.Space(20f);
					EditorGUILayout.BeginVertical();

					NGUISettings.backgroundColor = EditorGUILayout.ColorField("Background", NGUISettings.backgroundColor);

					if (GUILayout.Button("Add a Shadow")) AddShadow(sprite);
					if (GUILayout.Button("Add a Soft Outline")) AddOutline(sprite);

					if (GUILayout.Button("Add a Transparent Border")) AddTransparentBorder(sprite);
					if (GUILayout.Button("Add a Clamped Border")) AddClampedBorder(sprite);
					if (GUILayout.Button("Add a Tiled Border")) AddTiledBorder(sprite);
					EditorGUI.BeginDisabledGroup(!sprite.hasBorder);
					if (GUILayout.Button("Crop Border")) CropBorder(sprite);
					EditorGUI.EndDisabledGroup();

					EditorGUILayout.EndVertical();
					GUILayout.Space(20f);
					EditorGUILayout.EndHorizontal();

					NGUIEditorTools.EndContents();
				}

				if (NGUIEditorTools.previousSelection != null)
				{
					GUILayout.Space(3f);
					GUI.backgroundColor = Color.green;

					if (GUILayout.Button("<< Return to " + NGUIEditorTools.previousSelection.name))
					{
						NGUIEditorTools.SelectPrevious();
					}
					GUI.backgroundColor = Color.white;
				}
			}
		}
	}

19 View Source File : UIBasicSpriteEditor.cs
License : MIT License
Project Creator : XINCGer

protected override void DrawCustomProperties ()
	{
		GUILayout.Space(6f);

		SerializedProperty sp = NGUIEditorTools.DrawProperty("Type", serializedObject, "mType", GUILayout.MinWidth(20f));

		UISprite.Type type = (UISprite.Type)sp.intValue;

		if (type == UISprite.Type.Simple)
		{
			NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
		}
		else if (type == UISprite.Type.Tiled)
		{
			NGUIEditorTools.DrawBorderProperty("Trim", serializedObject, "mBorder");
			NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
		}
		else if (type == UISprite.Type.Sliced)
		{
			NGUIEditorTools.DrawBorderProperty("Border", serializedObject, "mBorder");
			NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");

			EditorGUI.BeginDisabledGroup(sp.hasMultipleDifferentValues);
			{
				sp = serializedObject.FindProperty("centerType");
				bool val = (sp.intValue != (int)UISprite.AdvancedType.Invisible);

				if (val != EditorGUILayout.Toggle("Fill Center", val))
				{
					sp.intValue = val ? (int)UISprite.AdvancedType.Invisible : (int)UISprite.AdvancedType.Sliced;
				}
			}
			EditorGUI.EndDisabledGroup();
		}
		else if (type == UISprite.Type.Filled)
		{
			NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
			NGUIEditorTools.DrawProperty("Fill Dir", serializedObject, "mFillDirection", GUILayout.MinWidth(20f));
			GUILayout.BeginHorizontal();
			GUILayout.Space(4f);
			NGUIEditorTools.DrawProperty("Fill Amount", serializedObject, "mFillAmount", GUILayout.MinWidth(20f));
			GUILayout.Space(4f);
			GUILayout.EndHorizontal();
			NGUIEditorTools.DrawProperty("Invert Fill", serializedObject, "mInvert", GUILayout.MinWidth(20f));
		}
		else if (type == UISprite.Type.Advanced)
		{
			NGUIEditorTools.DrawBorderProperty("Border", serializedObject, "mBorder");
			NGUIEditorTools.DrawProperty("  Left", serializedObject, "leftType");
			NGUIEditorTools.DrawProperty("  Right", serializedObject, "rightType");
			NGUIEditorTools.DrawProperty("  Top", serializedObject, "topType");
			NGUIEditorTools.DrawProperty("  Bottom", serializedObject, "bottomType");
			NGUIEditorTools.DrawProperty("  Center", serializedObject, "centerType");
			NGUIEditorTools.DrawProperty("Flip", serializedObject, "mFlip");
		}
		
		if (type == UIBasicSprite.Type.Simple || type == UIBasicSprite.Type.Sliced) // Gradients get too complicated for tiled and filled.
		{
			GUILayout.BeginHorizontal();
			SerializedProperty gr = NGUIEditorTools.DrawProperty("Gradient", serializedObject, "mApplyGradient", GUILayout.Width(95f));

			EditorGUI.BeginDisabledGroup(!gr.hasMultipleDifferentValues && !gr.boolValue);
			{
				NGUIEditorTools.SetLabelWidth(30f);
				serializedObject.DrawProperty("mGradientTop", "Top", GUILayout.MinWidth(40f));
				GUILayout.EndHorizontal();
				GUILayout.BeginHorizontal();
				NGUIEditorTools.SetLabelWidth(50f);
				GUILayout.Space(79f);

				serializedObject.DrawProperty("mGradientBottom", "Bottom", GUILayout.MinWidth(40f));
				NGUIEditorTools.SetLabelWidth(80f);
			}
			EditorGUI.EndDisabledGroup();
			GUILayout.EndHorizontal();
		}
		base.DrawCustomProperties();
	}

19 View Source File : UILocalizeEditor.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI ()
	{
		serializedObject.Update();
		
		GUILayout.Space(6f);
		NGUIEditorTools.SetLabelWidth(80f);

		GUILayout.BeginHorizontal();
		// Key not found in the localization file -- draw it as a text field
		SerializedProperty sp = NGUIEditorTools.DrawProperty("Key", serializedObject, "key");

		string myKey = sp.stringValue;
		bool isPresent = (mKeys != null) && mKeys.Contains(myKey);
		GUI.color = isPresent ? Color.green : Color.red;
		GUILayout.BeginVertical(GUILayout.Width(22f));
		GUILayout.Space(2f);
		GUILayout.Label(isPresent? "\u2714" : "\u2718", "TL SelectionButtonNew", GUILayout.Height(20f));
		GUILayout.EndVertical();
		GUI.color = Color.white;
		GUILayout.EndHorizontal();

		if (isPresent)
		{
			if (NGUIEditorTools.DrawHeader("Preview"))
			{
				NGUIEditorTools.BeginContents();

				string[] keys = Localization.knownLanguages;
				string[] values;

				if (Localization.dictionary.TryGetValue(myKey, out values))
				{
					if (keys.Length != values.Length)
					{
						EditorGUILayout.HelpBox("Number of keys doesn't match the number of values! Did you modify the dictionaries by hand at some point?", MessageType.Error);
					}
					else
					{
						for (int i = 0; i < keys.Length; ++i)
						{
							GUILayout.BeginHorizontal();
							GUILayout.Label(keys[i], GUILayout.Width(66f));

							if (GUILayout.Button(values[i], "AS TextArea", GUILayout.MinWidth(80f), GUILayout.MaxWidth(Screen.width - 110f)))
							{
								(target as UILocalize).value = values[i];
								GUIUtility.hotControl = 0;
								GUIUtility.keyboardControl = 0;
							}
							GUILayout.EndHorizontal();
						}
					}
				}
				else GUILayout.Label("No preview available");

				NGUIEditorTools.EndContents();
			}
		}
		else if (mKeys != null && !string.IsNullOrEmpty(myKey))
		{
			GUILayout.BeginHorizontal();
			GUILayout.Space(80f);
			GUILayout.BeginVertical();
			GUI.backgroundColor = new Color(1f, 1f, 1f, 0.35f);

			int matches = 0;

			for (int i = 0, imax = mKeys.Count; i < imax; ++i)
			{
				if (mKeys[i].StartsWith(myKey, System.StringComparison.OrdinalIgnoreCase) || mKeys[i].Contains(myKey))
				{
					if (GUILayout.Button(mKeys[i] + " \u25B2", "CN CountBadge"))
					{
						sp.stringValue = mKeys[i];
						GUIUtility.hotControl = 0;
						GUIUtility.keyboardControl = 0;
					}
					
					if (++matches == 8)
					{
						GUILayout.Label("...and more");
						break;
					}
				}
			}
			GUI.backgroundColor = Color.white;
			GUILayout.EndVertical();
			GUILayout.Space(22f);
			GUILayout.EndHorizontal();
		}
		
		serializedObject.ApplyModifiedProperties();
	}

19 View Source File : ManifestInspector.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI()
        {
            if (_lastModify != File.GetLastWriteTime(Utility.replacedetsManifestreplacedet))
                BuildCahe();

            serializedObject.UpdateIfRequiredOrScript();
            EditorGUILayout.PropertyField(serializedObject.FindProperty("downloadURL"), true);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("activeVariants"), true);
            serializedObject.ApplyModifiedProperties();
            GUILayout.Space(5);
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("<<", EditorStyles.label, GUILayout.MaxWidth(40)))
            {
                _startLine -= DisplayLineNum;
            }

            _startLine = (int) GUILayout.HorizontalSlider(_startLine, 0, _lineIndex.Count - DisplayLineNum - 1);
            if (GUILayout.Button(">>", EditorStyles.label, GUILayout.MaxWidth(40)))
            {
                _startLine += DisplayLineNum;
            }

            if (GUILayout.Button("clear", EditorStyles.toolbarButton, GUILayout.MaxWidth(60)))
            {
                if (EditorUtility.DisplayDialog("Clear manifest!", "Do you really want to  clear the manifest?", "OK",
                    "Cancel"))
                    ResetManifest();
            }
            GUILayout.Space(2);
            if (GUILayout.Button("refresh", EditorStyles.toolbarButton, GUILayout.MaxWidth(60)))
            {
                BuildCahe();
            }

            GUILayout.EndHorizontal();
            GUILayout.Space(5);
            var maxLine = _lineIndex.Count - 1;
            _startLine = Math.Max(Math.Min(_startLine, maxLine - DisplayLineNum), 0);
            int start = _startLine;
            int end = Math.Min(_startLine + DisplayLineNum, maxLine);


            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
            GUI.enabled = false;
            EditorGUILayout.TextArea(_manifestStr.Substring(_lineIndex[start] + 1,
                _lineIndex[end] - _lineIndex[start] - 1));
            GUI.enabled = true;
            GUILayout.EndScrollView();
        }

19 View Source File : AlertDialog.cs
License : MIT License
Project Creator : XINCGer

private void DrawEditorGUI()
        {
            GUI.color = textColor;
            GUILayout.Space(12);
            GUILayout.BeginHorizontal();
            EditorGUILayout.LabelField(alertText);
            GUILayout.EndHorizontal();
            GUI.color = defaultColor;
        }

19 View Source File : ShaderForgeInspector.cs
License : MIT License
Project Creator : XINCGer

public override void OnInspectorGUI() {
			GUI.enabled = true;
			Shader shader = base.target as Shader;
			
			
			if(!SF_Tools.CanRunShaderForge()){
				SF_Tools.UnityOutOfDateGUI();
				return;
			}

			//EditorGUILayout.Inspectorreplacedlebar( false, base.target );


			if( hreplacedhaderForgeData ) {
				if( GUILayout.Button( "Open in Shader Forge" ) ) {
					if(Event.current.rawType != EventType.MouseDown)
						SF_Editor.Init( shader );
				}
			} else {
				GUILayout.BeginHorizontal();
				{
					//GUILayout.Label(SF_Styles.IconWarningSmall,GUILayout.Width(18),GUILayout.Height(18));
					GUI.color = Color.gray;
					GUILayout.Label( "No Shader Forge data found!", EditorStyles.miniLabel );
					GUI.color = Color.white;
				}
				GUILayout.EndHorizontal();
				//GUILayout.Label( "Opening this will clear the shader", EditorStyles.miniLabel );
				//GUI.color = new Color( 1f, 0.8f, 0.8f );
				if( GUILayout.Button( new GUIContent( "Replace with Shader Forge shader", SF_Styles.IconWarningSmall, "This will erase any existing shader code" ), hreplacedhaderForgeData ? "Button" : "MiniButton" ) ) {
					if( SF_GUI.AcceptedNewShaderReplaceDialog() ) {
						SF_Editor.Init( shader );
						SF_Editor.instance.ps.fChecker.UpdateAvailability();
						SF_Editor.instance.OnShaderModified( NodeUpdateType.Hard );
					}
					
				}
				//GUI.color = Color.white;
				
			}
			


			if( SF_Tools.advancedInspector ) {
				GUILayout.BeginHorizontal();
				{
					GUIStyle btnStyle = hreplacedhaderForgeData ? "MiniButton" : "Button";
					if( GUILayout.Button( "Open shader code", btnStyle ) ) {
						UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal( replacedetDatabase.GetreplacedetPath( shader ), 1 );
					}
					//if( GUILayout.Button( "Open compiled", btnStyle ) ) {
					//	OpenCompiledShader( shader );
					//}
				}
				GUILayout.EndHorizontal();
			}

			DrawUnitysInspector();

		}

19 View Source File : ToluaInjectionBlackListPanel.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
    {
        InitPathsInfo();
        InitFilterListDrawer();

        bool execGenerate = false;
        GUILayout.BeginHorizontal(EditorStyles.toolbar);
        {
            if (GUILayout.Button("Add", EditorStyles.toolbarButton))
            {
                AddNewPath();
            }
            if (GUILayout.Button("Save", EditorStyles.toolbarButton))
            {
                SavePathsInfo();
            }
            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Generate", EditorStyles.toolbarButton))
            {
                execGenerate = true;
            }
        }
        GUILayout.EndHorizontal();

        GUILayout.BeginVertical();
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            {
                pathUIList.DoLayoutList();
            }
            GUILayout.EndScrollView();
        }
        GUILayout.EndVertical();

        if (execGenerate)
        {
            Generate();
            Close();
        }
    }

19 View Source File : LutifyBrowser.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
	{
		if (m_Lutify == null)
			return; // Can happen when Unity is restarted and the LUT browser is still opened

		// Header
		GUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
		{
			EditorGUI.BeginChangeCheck();

			m_SelectedCollection = EditorGUILayout.Popup(m_SelectedCollection, m_CollectionMenu, EditorStyles.toolbarPopup, GUILayout.MaxWidth(170f));

			if (EditorGUI.EndChangeCheck())
			{
				m_ScrollView = Vector2.zero;
				m_Lutify._LastSelectedCategory = m_SelectedCollection;
			}

			GUILayout.FlexibleSpace();

			EditorGUI.BeginChangeCheck();

			m_Lutify._ThumbWidth = Mathf.RoundToInt(GUILayout.HorizontalSlider(m_Lutify._ThumbWidth, 100f, 300f, new GUIStyle("preSlider"), new GUIStyle("preSliderThumb"), GUILayout.Width(64f)));

			if (EditorGUI.EndChangeCheck())
				InternalGUIUtility.RepaintGameView();

			if (GUILayout.Button("?", EditorStyles.toolbarButton))
				Application.OpenURL("http://www.thomashourdel.com/lutify/");
		}
		GUILayout.EndHorizontal();

		// Component check
		if (!m_Lutify.enabled)
		{
			EditorGUILayout.HelpBox("Lutify is disabled ! Please enable the component get the LUT browser to work.", MessageType.Error);

			if (GUILayout.Button("Enable"))
				m_Lutify.enabled = true;

			return;
		}

		// Gallery
		List<Texture2D> luts = null;

		if (!m_Collections.TryGetValue(m_CollectionNames[m_SelectedCollection], out luts) || luts.Count == 0)
			return;

		m_ScrollView = GUILayout.BeginScrollView(m_ScrollView, false, false, GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
		{
			int w = Mathf.FloorToInt(position.width);
			int tw = m_Lutify._ThumbWidth;
			int th = m_Lutify._ThumbHeight;
			int spacing = 4;
			int margin = 16;
			int c = (w - margin) / (tw + spacing);

			GUILayout.BeginVertical();
			{
				GUILayout.Space(spacing);

				FilterMode filterMode = m_CollectionFilters[m_SelectedCollection];
				bool layoutState = false;
				int j = 0;

				for (int i = 0; i < luts.Count; i++)
				{
					j++;

					if (!layoutState)
					{
						GUILayout.BeginHorizontal();
						GUILayout.FlexibleSpace();
						layoutState = true;
					}

					Rect r = GUILayoutUtility.GetRect(tw, th);

					if (m_Lutify._PreviewRT != null)
						DrawPreview(r, luts[i], filterMode);

					if (j < c && c != 1 && i != luts.Count - 1)
						GUILayout.Space(spacing);

					if (layoutState && j == c)
					{
						GUILayout.FlexibleSpace();
						GUILayout.EndHorizontal();
						GUILayout.Space(spacing);
						layoutState = false;
						j = 0;
					}
				}

				if (layoutState && j < c)
				{
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
				}

				GUILayout.Space(spacing);
			}
			GUILayout.EndVertical();
		}
		GUILayout.EndScrollView();
	}

19 View Source File : ColaQuickWindowEditor.cs
License : MIT License
Project Creator : XINCGer

public void DrawColaFrameworkUI()
        {
            GUILayout.BeginHorizontal("HelpBox");
            EditorGUILayout.LabelField("== UI相关辅助 ==");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("创建NewUIView", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaGUIEditor.CreateColaUIView();
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("创建C#版UIView脚本", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                CreateScriptsEditor.CreateCSharpUIView();
            }
            if (GUILayout.Button("创建C#版Module脚本", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                CreateScriptsEditor.CreateCSharpModule();
            }
            if (GUILayout.Button("创建C#版Templates(UIView和Module)", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                CreateScriptsEditor.CreateCSharpModule();
            }
            GUILayout.EndHorizontal();
        }

19 View Source File : ColaQuickWindowEditor.cs
License : MIT License
Project Creator : XINCGer

private void DrawMiscUI()
        {
            GUILayout.BeginHorizontal("HelpBox");
            EditorGUILayout.LabelField("== 快捷功能 ==");
            GUILayout.EndHorizontal();
            if (GUILayout.Button("GC"))
            {
                CommonHelper.ClearMemory();
            }
            GUILayout.BeginHorizontal();
            if (GUILayout.Button("打开replacedetPath目录", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaEditHelper.OpenDirectory(AppConst.replacedetPath);
            }
            if (GUILayout.Button("打开GameLog文件目录", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaEditHelper.OpenDirectory(Path.Combine(AppConst.replacedetPath, "logs"));
            }
            GUILayout.EndHorizontal();
        }

19 View Source File : ColaQuickWindowEditor.cs
License : MIT License
Project Creator : XINCGer

private void DrawreplacedetUI()
        {
            GUILayout.BeginHorizontal("HelpBox");
            EditorGUILayout.LabelField("== 快捷功能 ==");
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Build Lua Bundle", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaEditHelper.BuildLuaBundle();
            }
            if (GUILayout.Button("Build Lua File", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaEditHelper.BuildLuaFile();
            }
            if (GUILayout.Button("Mark Lua Bundle", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaEditHelper.MarkreplacedetsToOneBundle(LuaConst.luaBaseTempDir, AppConst.LuaBaseBundle);
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Mark Sprite Bundle", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                ColaEditHelper.MarkreplacedetsWithDir("replacedets/Gamereplacedets/Arts/UI/Atlas/");
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("导出版本Json", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                var replacedetPath = "replacedets/Editor/Settings/AppVersion.replacedet";
                var replacedet = replacedetDatabase.LoadreplacedetAtPath<AppVersion>(replacedetPath);
                if (null != replacedet)
                {
                    var jsonStr = JsonMapper.ToJson(replacedet);
                    FileHelper.DeleteFile("replacedets/Resources/app_version.json");
                    FileHelper.WriteString("replacedets/Resources/app_version.json", jsonStr);
                    replacedetDatabase.Refresh();
                }
            }
            if (GUILayout.Button("导入Json文件", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                var jsonPath = "replacedets/Editor/Settings/AppVersion.json";
                using (var sr = new StreamReader(jsonPath))
                {
                    var jsonStr = sr.ReadToEnd();
                    var replacedet = JsonMapper.ToObject<AppVersion>(jsonStr);
                    Debug.Log(replacedet.UpdateContent);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Zip Lua", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                var result = ZipHelper.Zip("replacedets/Lua", Path.Combine(Application.dataPath, "../output/luaout.zip"));
                Debug.Log("Zip Lua结果:" + result);
            }
            if (GUILayout.Button("UnZip Lua", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                var filePath = Path.Combine("replacedets", "../output/luaout.zip");
                if (File.Exists(filePath))
                {
                    var result = ZipHelper.UnZip(filePath, Path.Combine("replacedets", "../output"));
                    Debug.Log("UnZip Lua结果:" + result);
                }
                else
                {
                    Debug.LogError("解压错误!要解压的文件不存在!路径:" + filePath);
                }
            }
            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("筛选出MD5码变化的lua文件", GUILayout.ExpandWidth(true), GUILayout.MaxHeight(30)))
            {
                var md5Dic = new Dictionary<string, string>();
                var luaMd5FilePath = ColaEditHelper.TempCachePath + "/LuaMD5.txt";
                if (File.Exists(luaMd5FilePath))
                {
                    using (var sm = new StreamReader(luaMd5FilePath, Encoding.UTF8))
                    {
                        var fileLines = sm.ReadToEnd().Split('\n');
                        foreach (var item in fileLines)
                        {
                            if (string.IsNullOrEmpty(item))
                            {
                                continue;
                            }
                            var lineContent = item.Split('|');
                            if (lineContent.Length == 2)
                            {
                                md5Dic[lineContent[0]] = lineContent[1];
                            }
                            else
                            {
                                Debug.LogError("LuaMD5.txt格式错误!内容为: " + lineContent);
                            }
                        }
                    }
                }

                var luaFiles = new List<string>(Directory.GetFiles(LuaLogicPath, "*.lua", SearchOption.AllDirectories));
                var fLength = (float)luaFiles.Count;

                int diffCnt = 0;
                for (int i = 0; i < luaFiles.Count; i++)
                {
                    var fileName = luaFiles[i];
                    string curMd5 = FileHelper.GetMD5Hash(fileName);
                    if (md5Dic.ContainsKey(fileName) && curMd5 == md5Dic[fileName])
                    {
                        continue;
                    }
                    diffCnt++;
                    string destPath = Regex.Replace(fileName, "^replacedets", "output");
                    FileHelper.EnsureParentDirExist(destPath);
                    File.Copy(fileName, destPath, true);
                    md5Dic[fileName] = curMd5;
                    EditorUtility.DisplayProgressBar("正在分析Lua差异化..", fileName, i / fLength);

                }

                var sb = new StringBuilder();
                foreach (var item in md5Dic)
                {
                    sb.AppendFormat("{0}|{1}", item.Key, item.Value).AppendLine();
                }
                FileHelper.WriteString(luaMd5FilePath, sb.ToString());
                EditorUtility.ClearProgressBar();

                Debug.LogFormat("Lua差异化分析完毕!共有{0}个差异化文件!", diffCnt);
            }
            GUILayout.EndHorizontal();
        }

19 View Source File : PreviewWindow.cs
License : MIT License
Project Creator : XINCGer

private void OnGUI()
        {
            modelEditor.DrawPreview(new Rect(50, 50, 300, 300));
            animEditor.DrawPreview(new Rect(400, 50, 300, 300));

            meshEditor.DrawPreview(new Rect(50, 400, 300, 300));
            matEditor.DrawPreview(new Rect(400, 400, 300, 300));

            textureEditor.DrawPreview(new Rect(750, 50, 300, 300));

            GUILayout.BeginArea(new Rect(750, 375, 300, 50));
            GUILayout.BeginHorizontal();
            audioEditor.OnPreviewSettings();
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            audioEditor.DrawPreview(new Rect(750, 400, 300, 300));

            Repaint();
        }

19 View Source File : TrickOverViewPreview.cs
License : MIT License
Project Creator : XINCGer

public void Draw(bool drawCodeExample)
		{
			if (TrickOverViewPreview.exampleGroupStyle == null)
			{
				TrickOverViewPreview.exampleGroupStyle = new GUIStyle(GUIStyle.none)
				{
					padding = new RectOffset(1, 1, 10, 0)
				};
			}
			if (TrickOverViewPreview.previewStyle == null)
			{
				TrickOverViewPreview.previewStyle = new GUIStyle(GUIStyle.none)
				{
					padding = new RectOffset(0, 0, 0, 0)
				};
			}

			GUILayout.BeginVertical(TrickOverViewPreview.exampleGroupStyle, new GUILayoutOption[0]);
			GUILayout.Label("Preview:", SirenixGUIStyles.Boldreplacedle, new GUILayoutOption[0]);
			GUILayout.BeginVertical(TrickOverViewPreview.previewStyle, GUILayoutOptions.ExpandWidth(true));
			Rect rect = GUIHelper.GetCurrentLayoutRect().Expand(4f, 0f);
			SirenixEditorGUI.DrawSolidRect(rect, EditorGUIUtility.isProSkin ? TrickOverViewPreview.previewBackgroundColorDark : TrickOverViewPreview.previewBackgroundColorLight, true);
			SirenixEditorGUI.DrawBorders(rect, 1, true);
			GUILayout.Space(8f);
			
			m_DrawCallbaclAction.Invoke(rect);
			this.tree = (this.tree ?? PropertyTree.Create(m_Example));
			this.tree.Draw(false);
			
			GUILayout.Space(8f);
			GUILayout.EndVertical();
			if (drawCodeExample && m_Example.GetTrickOverViewInfo().Code != null)
			{
				GUILayout.Space(12f);
				GUILayout.Label("Code", SirenixGUIStyles.Boldreplacedle, new GUILayoutOption[0]);
				Rect rect2 = SirenixEditorGUI.BeginToolbarBox(new GUILayoutOption[0]);
				SirenixEditorGUI.DrawSolidRect(rect2.HorizontalPadding(1f), SyntaxHighlighter.BackgroundColor, true);
				SirenixEditorGUI.BeginToolbarBoxHeader(22f);
				if (SirenixEditorGUI.ToolbarButton(this.showRaw ? "Highlighted" : "Raw", false))
				{
					this.showRaw = !this.showRaw;
				}
				GUILayout.FlexibleSpace();
				EditorGUILayoutExtension.LinkFileLabelField("点击此处定位到脚本目录", this.m_Example.GetTrickOverViewInfo().CodePath);
				GUILayout.FlexibleSpace();
				if (SirenixEditorGUI.ToolbarButton("Copy", false))
				{
					Clipboard.Copy<string>(this.m_Example.GetTrickOverViewInfo().Code);
				}
				SirenixEditorGUI.EndToolbarBoxHeader();
				if (TrickOverViewPreview.codeTextStyle == null)
				{
					TrickOverViewPreview.codeTextStyle = new GUIStyle(SirenixGUIStyles.MultiLineLabel);
					TrickOverViewPreview.codeTextStyle.normal.textColor = SyntaxHighlighter.TextColor;
					TrickOverViewPreview.codeTextStyle.active.textColor = SyntaxHighlighter.TextColor;
					TrickOverViewPreview.codeTextStyle.focused.textColor = SyntaxHighlighter.TextColor;
					TrickOverViewPreview.codeTextStyle.wordWrap = false;
				}
				GUIContent content = GUIHelper.TempContent(this.showRaw ? this.m_Example.GetTrickOverViewInfo().Code.TrimEnd(new char[]
				{
					'\n',
					'\r'
				}) : this.highlightedCode);
				Vector2 vector = TrickOverViewPreview.codeTextStyle.CalcSize(content);
				GUILayout.BeginHorizontal(new GUILayoutOption[0]);
				GUILayout.Space(-3f);
				GUILayout.BeginVertical(new GUILayoutOption[0]);
				GUIHelper.PushEventType((Event.current.type == EventType.ScrollWheel) ? EventType.Used : Event.current.type);
				this.scrollPosition = GUILayout.BeginScrollView(this.scrollPosition, true, false, GUI.skin.horizontalScrollbar, GUIStyle.none, new GUILayoutOption[]
				{
					GUILayout.MinHeight(vector.y + 20f)
				});
				Rect rect3 = GUILayoutUtility.GetRect(vector.x + 50f, vector.y).AddXMin(4f).AddY(2f);
				if (this.showRaw)
				{
					EditorGUI.SelectableLabel(rect3, this.m_Example.GetTrickOverViewInfo().Code, TrickOverViewPreview.codeTextStyle);
					GUILayout.Space(-14f);
				}
				else
				{
					GUI.Label(rect3, content, TrickOverViewPreview.codeTextStyle);
				}
				GUILayout.EndScrollView();
				GUIHelper.PopEventType();
				GUILayout.EndVertical();
				GUILayout.Space(-3f);
				GUILayout.EndHorizontal();
				GUILayout.Space(-3f);
				SirenixEditorGUI.EndToolbarBox();
			}
			GUILayout.EndVertical();
		}

19 View Source File : AllTrickOverViewEditorWindow.cs
License : MIT License
Project Creator : XINCGer

protected override void OnGUI()
        {
            GUILayout.BeginHorizontal();

            GUI.color = Color.HSVToRGB(
                Mathf.Cos((float) UnityEditor.EditorApplication.timeSinceStartup + 1f) * 0.125f + 0.325f, 1, 1);
            if (GUILayout.Button(
                new GUIContent("Create a Example OverView", EditorGUIUtility.FindTexture("Toolbar Plus")),
                "toolbarbutton", GUILayout.Width(200)))
            {
                m_ShouldDrawExampleCreatorUI = true;
            }

            GUI.color = Color.white;
            GUILayout.EndHorizontal();
            base.OnGUI();
        }

19 View Source File : GUIStylesPreview.cs
License : MIT License
Project Creator : XINCGer

void OnGUI()
        {
            if (position.width != _oldPosition.width && Event.current.type == EventType.Layout)
            {
                Drawings = null;
                _oldPosition = position;
            }

            // GUILayout.BeginHorizontal();
            //
            // if (GUILayout.Toggle(_showingStyles, "Styles", EditorStyles.toolbarButton) != _showingStyles)
            // {
            //     _showingStyles = !_showingStyles;
            //     _showingIcons = !_showingStyles;
            //     Drawings = null;
            // }

            // if (GUILayout.Toggle(_showingIcons, "Icons", EditorStyles.toolbarButton) != _showingIcons)
            // {
            //     _showingIcons = !_showingIcons;
            //     _showingStyles = !_showingIcons;
            //     Drawings = null;
            // }

            // GUILayout.EndHorizontal();

            GUILayout.Button("Styles");
            string newSearch = GUILayout.TextField(_search);
            if (newSearch != _search)
            {
                _search = newSearch;
                Drawings = null;
            }

            float top = 36;

            if (Drawings == null)
            {
                string lowerSearch = _search.ToLower();

                Drawings = new List<Drawing>();

                GUIContent inactiveText = new GUIContent("inactive");
                GUIContent activeText = new GUIContent("active");

                float x = 5.0f;
                float y = 5.0f;

                if (_showingStyles)
                {
                    foreach (GUIStyle ss in GUI.skin)
                    {
                        if (lowerSearch != "" && !ss.name.ToLower().Contains(lowerSearch))
                            continue;

                        GUIStyle thisStyle = ss;

                        Drawing draw = new Drawing();

                        float width = Mathf.Max(
                            100.0f,
                            GUI.skin.button.CalcSize(new GUIContent(ss.name)).x,
                            ss.CalcSize(inactiveText).x + ss.CalcSize(activeText).x
                        ) + 16.0f;

                        float height = 60.0f;

                        if (x + width > position.width - 32 && x > 5.0f)
                        {
                            x = 5.0f;
                            y += height + 10.0f;
                        }

                        draw.Rect = new Rect(x, y, width, height);

                        width -= 8.0f;

                        draw.Draw = () =>
                        {
                            if (GUILayout.Button(thisStyle.name, GUILayout.Width(width)))
                                CopyText("(GUIStyle)\"" + thisStyle.name + "\"");

                            GUILayout.BeginHorizontal();
                            GUILayout.Toggle(true, inactiveText, thisStyle, GUILayout.Width(width / 2));
                            GUILayout.Toggle(false, activeText, thisStyle, GUILayout.Width(width / 2));
                            GUILayout.EndHorizontal();
                        };

                        x += width + 18.0f;

                        Drawings.Add(draw);
                    }
                }

                _maxY = y;
            }

            Rect r = position;
            r.y = top;
            r.height -= r.y;
            r.x = r.width - 16;
            r.width = 16;

            float areaHeight = position.height - top;
            _scrollPos = GUI.VerticalScrollbar(r, _scrollPos, areaHeight, 0.0f, _maxY);

            Rect area = new Rect(0, top, position.width - 16.0f, areaHeight);
            GUILayout.BeginArea(area);
            int count = 0;
            foreach (Drawing draw in Drawings)
            {
                Rect newRect = draw.Rect;
                newRect.y -= _scrollPos;

                if (newRect.y + newRect.height > 0 && newRect.y < areaHeight)
                {
                    GUILayout.BeginArea(newRect, GUI.skin.textField);
                    draw.Draw();
                    GUILayout.EndArea();

                    count++;
                }
            }

            GUILayout.EndArea();
        }

19 View Source File : EditorGUILayoutExtension.cs
License : MIT License
Project Creator : XINCGer

public static float ScrollList(SerializedProperty _list, float _scroll, ref bool _foldout, int _count = 10)
        {
            _foldout = EditorGUILayout.Foldout(_foldout, _list.displayName, true);

            if (_foldout)
            {
                EditorGUI.indentLevel++;

                GUILayout.BeginHorizontal();
                int size = EditorGUILayout.DelayedIntField("Count", _list.arraySize);
                EditorGUI.indentLevel--;
                int targetIndex = -1;
                targetIndex = EditorGUILayout.DelayedIntField(targetIndex, GUILayout.Width(40));
                GUILayout.EndHorizontal();

                EditorGUI.indentLevel++;

                if (size != _list.arraySize)
                    _list.arraySize = size;

                GUILayout.BeginHorizontal();
                Rect r = EditorGUILayout.BeginVertical();

                if (_list.arraySize > _count)
                {
                    int startIndex = Mathf.CeilToInt(_list.arraySize * _scroll);
                    startIndex = Mathf.Max(0, startIndex);
                    for (int i = startIndex; i < startIndex + _count; i++)
                    {
                        EditorGUILayout.PropertyField(_list.GetArrayElementAtIndex(i));
                    }
                }
                else
                {
                    for (int i = 0; i < _list.arraySize; i++)
                    {
                        EditorGUILayout.PropertyField(_list.GetArrayElementAtIndex(i));
                    }
                }

                EditorGUILayout.EndVertical();
                if (_list.arraySize > _count)
                {
                    GUILayout.Space(20);
                    if (_list.arraySize > _count)
                    {
                        if (Event.current.type == EventType.ScrollWheel && r.Contains(Event.current.mousePosition))
                        {
                            _scroll += Event.current.delta.y * 0.01f;
                            Event.current.Use();
                        }
                        if (targetIndex != -1)
                        {
                            _scroll = Mathf.Clamp01((float)targetIndex / _list.arraySize);
                        }

                        r.xMin += r.width + 5;
                        r.width = 20;
                        _scroll = GUI.VerticalScrollbar(r, _scroll, (float)_count / _list.arraySize, 0, 1);
                    }
                }
                GUILayout.EndHorizontal();
                EditorGUI.indentLevel--;
            }

            return _scroll;
        }

See More Examples