UnityEngine.GUI.Box(UnityEngine.Rect, UnityEngine.GUIContent)

Here are the examples of the csharp api UnityEngine.GUI.Box(UnityEngine.Rect, UnityEngine.GUIContent) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

3 Examples 7

19 View Source File : LunarConsoleActionEditor.cs
License : GNU General Public License v3.0
Project Creator : Cytoid

void DrawListElement(Rect rect, int index, bool isActive, bool isFocused)
        {
            SerializedProperty arrayElementAtIndex = list.serializedProperty.GetArrayElementAtIndex(index);
            rect.y += 1f;
            Rect[] rowRects = GetRowRects(rect);
            Rect runtimeModeRect = rowRects[0];
            Rect targetRect = rowRects[1];
            Rect methodRect = rowRects[2];
            Rect argumentRect = rowRects[3];
            SerializedProperty modeProperty = arrayElementAtIndex.FindPropertyRelative(kPropMode);
            SerializedProperty targetProperty = arrayElementAtIndex.FindPropertyRelative(kPropTarget);
            SerializedProperty methodProperty = arrayElementAtIndex.FindPropertyRelative(kPropMethod);
            SerializedProperty argumentsProperty = arrayElementAtIndex.FindPropertyRelative(kPropArguments);

            Color backgroundColor = GUI.backgroundColor;
            GUI.backgroundColor = Color.white;

            var oldFlag = GUI.enabled;
            GUI.enabled = false;
            GUI.Box(runtimeModeRect, "Runtime Only", EditorStyles.popup);
            GUI.enabled = oldFlag;

            EditorGUI.BeginChangeCheck();
            GUI.Box(targetRect, GUIContent.none);
            EditorGUI.PropertyField(targetRect, targetProperty, GUIContent.none);
            if (EditorGUI.EndChangeCheck())
            {
                methodProperty.stringValue = null;
            }
            LunarPersistentListenerMode persistentListenerMode = (LunarPersistentListenerMode) modeProperty.enumValueIndex;
            if (targetProperty.objectReferenceValue == null || string.IsNullOrEmpty(methodProperty.stringValue))
            {
                persistentListenerMode = LunarPersistentListenerMode.Void;
            }
            SerializedProperty argumentProperty;
            switch (persistentListenerMode)
            {
                case LunarPersistentListenerMode.Object:
                    argumentProperty = argumentsProperty.FindPropertyRelative("m_objectArgument");
                    break;
                case LunarPersistentListenerMode.Int:
                    argumentProperty = argumentsProperty.FindPropertyRelative("m_intArgument");
                    break;
                case LunarPersistentListenerMode.Float:
                    argumentProperty = argumentsProperty.FindPropertyRelative("m_floatArgument");
                    break;
                case LunarPersistentListenerMode.String:
                    argumentProperty = argumentsProperty.FindPropertyRelative("m_stringArgument");
                    break;
                case LunarPersistentListenerMode.Bool:
                    argumentProperty = argumentsProperty.FindPropertyRelative("m_boolArgument");
                    break;
                default:
                    argumentProperty = argumentsProperty.FindPropertyRelative("m_intArgument");
                    break;
            }
            string argumentreplacedemblyTypeName = argumentsProperty.FindPropertyRelative(kPropObjectArgumentreplacedemblyTypeName).stringValue;
            Type argumentType = typeof(UnityEngine.Object);
            if (!string.IsNullOrEmpty(argumentreplacedemblyTypeName))
            {
                argumentType = (Type.GetType(argumentreplacedemblyTypeName, false) ?? typeof(UnityEngine.Object));
            }
            if (persistentListenerMode == LunarPersistentListenerMode.Object)
            {
                EditorGUI.BeginChangeCheck();
                UnityEngine.Object objectReferenceValue = EditorGUI.ObjectField(argumentRect, GUIContent.none, argumentProperty.objectReferenceValue, argumentType, true);
                if (EditorGUI.EndChangeCheck())
                {
                    argumentProperty.objectReferenceValue = objectReferenceValue;
                }
            }
            else if (persistentListenerMode != LunarPersistentListenerMode.Void)
            {
                EditorGUI.PropertyField(argumentRect, argumentProperty, GUIContent.none);
            }
            using (new DisabledScopeCompat(targetProperty.objectReferenceValue == null))
            {
                EditorGUI.BeginProperty(methodRect, GUIContent.none, methodProperty);
                GUIContent content;
                {
                    StringBuilder stringBuilder = new StringBuilder();
                    if (targetProperty.objectReferenceValue == null || string.IsNullOrEmpty(methodProperty.stringValue))
                    {
                        stringBuilder.Append("No Function");
                    }
                    else if (!LunarConsoleActionCall.IsPersistantListenerValid(targetProperty.objectReferenceValue, methodProperty.stringValue, persistentListenerMode))
                    {
                        string componentName = "UnknownComponent";
                        UnityEngine.Object target = targetProperty.objectReferenceValue;
                        if (target != null)
                        {
                            componentName = target.GetType().Name;
                        }
                        stringBuilder.Append(string.Format("<Missing {0}.{1}>", componentName, methodProperty.stringValue));
                    }
                    else
                    {
                        stringBuilder.Append(targetProperty.objectReferenceValue.GetType().Name);
                        if (!string.IsNullOrEmpty(methodProperty.stringValue))
                        {
                            stringBuilder.Append(".");
                            if (methodProperty.stringValue.StartsWith("set_"))
                            {
                                stringBuilder.Append(methodProperty.stringValue.Substring(4));
                            }
                            else
                            {
                                stringBuilder.Append(methodProperty.stringValue);
                            }
                        }
                    }
                    content = new GUIContent(stringBuilder.ToString());
                }
                if (GUI.Button(methodRect, content, EditorStyles.popup))
                {
                    BuildPopupList(arrayElementAtIndex).DropDown(methodRect);
                }
                EditorGUI.EndProperty();
            }
            GUI.backgroundColor = backgroundColor;
        }

19 View Source File : ErrorManager.cs
License : MIT License
Project Creator : LunariStudios

public void DrawErrors(CutsceneEditor editor) {
            InvokeOnBeginErrorChecking(editor);
            ErrorCheckers.CheckErrors(editor, errors);
            InvokeOnEndErrorChecking(editor);
            var cutscene = editor.Cutscene;
            var totalErrors = errors.Count;
            if (totalErrors <= 0) {
                return;
            }
            var max = (from message in errors select message.Level).Max();
            ShowErrors = GUILayout.Toggle(ShowErrors, GetErrorContent(totalErrors, max),
                ShiroiStyles.GetErrorStyle(max), GUILayout.MinHeight(ShiroiStyles.SingleLineHeight * 2));
            if (!ShowErrors) {
                GUILayout.Space(ShiroiStyles.SpaceHeight);
                return;
            }
            var init = GUI.backgroundColor;
            foreach (var errorMessage in errors) {
                var lines = errorMessage.Lines;
                var height = (lines.Length + 1) * ShiroiStyles.SingleLineHeight;
                var rect = GUILayoutUtility.GetRect(10, height, ShiroiStyles.ExpandWidthOption);
                Rect iconRect;
                Rect messagesRect;
                rect.Split(ShiroiStyles.IconSize, out iconRect, out messagesRect);

                GUI.backgroundColor = ShiroiStyles.GetColor(errorMessage.Level);
                GUI.Box(rect, GUIContent.none);
                GUI.Box(iconRect, ShiroiStyles.GetContent(errorMessage.Level));
                var index = errorMessage.TokenIndex;
                var token = cutscene[index];
                var label = string.Format("Token #{0} ({1})", index, token.GetType().Name);
                GUI.Label(messagesRect.GetLine(0), label, ShiroiStyles.Bold);
                for (uint i = 0; i < lines.Length; i++) {
                    var pos = messagesRect.GetLine(i + 1);
                    GUI.Label(pos, lines[i]);
                }
            }
            GUILayout.Space(ShiroiStyles.SpaceHeight);
            GUI.backgroundColor = init;
        }

19 View Source File : TokenList.cs
License : MIT License
Project Creator : LunariStudios

private void DrawBackground(Rect rect, int index, bool isactive, bool isfocused) {
            if (index == -1) {
                return;
            }

            var m = MappedToken.For(Cutscene[index]);
            var initColor = GUI.backgroundColor;
            GUI.backgroundColor = isfocused ? m.SelectedColor : m.Color;
            GUI.Box(rect, GUIContent.none);
            GUI.backgroundColor = initColor;
        }