public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (IsEnabled) {
                var propertyType = fieldInfo.FieldType;
                var target = fiSerializedPropertyUtility.GetTarget(property);
                var metadata = fiSerializedPropertyUtility.GetMetadata(property);
                var editor = PropertyEditor.Get(propertyType, fieldInfo).FirstEditor;

                if (property.prefabOverride) fiUnityInternalReflection.SetBoldDefaultFont(true);

                var savedHierarchyMode = EditorGUIUtility.hierarchyMode;
                EditorGUIUtility.hierarchyMode = true;

                EditorGUI.BeginChangeCheck();
                target = editor.Edit(position, label, target, metadata);

                if (EditorGUI.EndChangeCheck()) {
                    fiSerializedPropertyUtility.WriteTarget(property, target);
                    EditorUtility.SetDirty(property.serializedObject.targetObject);
                }

                EditorGUIUtility.hierarchyMode = savedHierarchyMode;

                if (property.prefabOverride) fiUnityInternalReflection.SetBoldDefaultFont(false);

                fiSerializedPropertyUtility.RevertPrefabContextMenu(position, property);
                return;
            }

            EditorGUI.PropertyField(position, property, label);
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = base.GetPropertyHeight(property, label);
            CheckRequiredComponents(property.GetValue<EntityBehaviour>());

            return height;
        }
		public override void OnGUI (Rect pos, SerializedProperty prop, GUIContent label) {


			SerializedProperty selection = prop.FindPropertyRelative("selection");
			SerializedProperty gameObject = prop.FindPropertyRelative("gameObject");

			CacheOwnerGameObject(prop.serializedObject);


			// draw the enum popup Field
			int oldEnumIndex = selection.enumValueIndex;

			EditorGUI.PropertyField(
				GetRectforRow(pos,0),
				selection,new GUIContent("Target"),true);

			if (oldEnumIndex !=selection.enumValueIndex)
			{
				if (selection.enumValueIndex==1)
				{
					gameObject.objectReferenceValue = ownerGameObject;
				}
			}

			if (selection.enumValueIndex==1)
			{
				EditorGUI.indentLevel++;

				EditorGUI.PropertyField(
					GetRectforRow(pos,1),
					gameObject,new GUIContent("Game Object"),true);
			}
	
		}
		/** Draws an integer field */
		public int IntField (GUIContent label, int value, int offset, int adjust, out Rect r) {
			GUIStyle intStyle = EditorStyles.numberField;
	
			EditorGUILayoutx.BeginIndent ();
			Rect r1 = GUILayoutUtility.GetRect (label,intStyle);
			
			Rect r2 = GUILayoutUtility.GetRect (new GUIContent (value.ToString ()),intStyle);
			
			EditorGUILayoutx.EndIndent();
			
			
			r2.width += (r2.x-r1.x);
			r2.x = r1.x+offset;
			r2.width -= offset+offset+adjust;
			
			r = new Rect ();
			r.x = r2.x+r2.width;
			r.y = r1.y;
			r.width = offset;
			r.height = r1.height;
			
			GUI.SetNextControlName ("IntField_"+label.text);
			value = EditorGUI.IntField (r2,"",value);
			
			bool on = GUI.GetNameOfFocusedControl () == "IntField_"+label.text;
			
			if (Event.current.type == EventType.Repaint) {	
				intStyle.Draw (r1,label,false,false,false,on);
			}
			
			return value;
		}
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, property);
            {
                if (EditorGUI.PropertyField(position, property))
                {
                    EditorGUILayout.PropertyField(property.FindPropertyRelative("type"));

                    switch (property.FindPropertyRelative("type").enumValueIndex)
                    {
                        case 0: // None
                            break;
                        case 1: // Sphere
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                        case 2: // Box
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("size"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                        case 3: // Capsule
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("center"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("direction"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("radius"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("height"));
                            EditorGUILayout.PropertyField(property.FindPropertyRelative("physicsMaterial"));
                            break;
                    }
                }
            }
            EditorGUI.EndProperty();
        }
 internal float GetPropertyHeightSafe(SerializedProperty property, GUIContent label)
 {
     ScriptAttributeUtility.s_DrawerStack.Push(this);
     float propertyHeight = this.GetPropertyHeight(property, label);
     ScriptAttributeUtility.s_DrawerStack.Pop();
     return propertyHeight;
 }
        public override float GetPropertyHeight(SerializedProperty _property, GUIContent _label)
        {
            if (_property.isArray)
                return EditorGUI.GetPropertyHeight(_property);

            return EditorGUI.GetPropertyHeight(_property) + kButtonHeight + kOffset;
        }
Example #8
0
        public static bool Foldout(bool open, GUIContent header, Action content)
        {
            if (foldoutStyle == null)
            {
                foldoutStyle = new GUIStyle(GUI.skin.FindStyle("ShurikenModuleBg"));
                foldoutStyle.padding = new RectOffset(10, 10, 10, 10);

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

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

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

                content();

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

            return open;
        }
        public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
        {
            EditorGUI.BeginProperty(position, label, prop);
            int indent = EditorGUI.indentLevel;
            EditorGUI.indentLevel = 0;
            position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), new GUIContent(label.text, (attribute as SingleLineAttribute).Tooltip));
            const float labelWidth = 32.0f;
            float widthAvailable = position.width - (labelWidth * 2.0f);
            float textFieldWidth = widthAvailable * 0.5f;

            switch (prop.type)
            {
                case "RangeOfIntegers":
                    DrawRangeField(position, labelWidth, textFieldWidth, prop, false);
                    break;

                case "RangeOfFloats":
                    DrawRangeField(position, labelWidth, textFieldWidth, prop, true);
                    break;
           
                default:
                    EditorGUI.HelpBox(position, "[Compact] doesn't work with type '" + prop.type + "'", MessageType.Error);
                    break;
            }

            EditorGUI.indentLevel = indent;
            EditorGUI.EndProperty();
        }
        /// <summary>
        ///   Gets the total height of this editor.
        /// </summary>
        /// <param name="property">Property to get the total height of the editor for.</param>
        /// <param name="label">The parameter is not used.</param>
        /// <returns>Total height of this editor.</returns>
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            SerializedProperty sourceProperty = this.GetSourceProperty(property);
            SerializedProperty memberProperty = this.GetMemberProperty(property);

            return EditorGUI.GetPropertyHeight(sourceProperty) + EditorGUI.GetPropertyHeight(memberProperty);
        }
        public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
        {
            float height = 0f; // since no stylesheet title (yet)

            /**
             * NOTE: This is weird (the following 3 lines
             * I commented out these on 20131129 because eDrivenGuiStyleSheet didn't render properly
             * (measured height of each declaration was zero)
             * It's weird because it worked fine with eDrivenStyleSheet and they both have the same base class
             * */
            /*if (!property.isExpanded)
            {
                return height;
            }*/

            SerializedProperty declarations = property.FindPropertyRelative("Declarations");
            int size = declarations.arraySize;

            if (size == 0)
            {
                return height; // +16f;
            }

            for (int i = 0; i < size; i++)
            {
                height += EditorGUI.GetPropertyHeight(declarations.GetArrayElementAtIndex(i));
            }

            // gaps
            if (size > 0)
                height += VerticalGap*(size - 1);

            return height;
        }
Example #12
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            if (list == null) initList(property, label);

            list.serializedProperty = property.FindPropertyRelative("tagList");
            list.DoList(position);
        }
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            var left  = position; left.xMax -= 40;
            var right = position; right.xMin = left.xMax + 2;

            EditorGUI.PropertyField(left, property);

            if (GUI.Button(right, "List") == true)
            {
                var menu = new GenericMenu();

                if (LeanLocalization.Instance != null)
                {
                    for (var j = 0; j < LeanLocalization.Instance.Languages.Count; j++)
                    {
                        var language = LeanLocalization.Instance.Languages[j];

                        menu.AddItem(new GUIContent(language), property.stringValue == language, () => { property.stringValue = language; property.serializedObject.ApplyModifiedProperties(); });
                    }
                }

                if (menu.GetItemCount() > 0)
                {
                    menu.DropDown(right);
                }
                else
                {
                    Debug.LogWarning("Your scene doesn't contain any languages, so the language name list couldn't be created.");
                }
            }
        }
		private void OnEnable()
		{
			_inputEvents = serializedObject.FindProperty("_inputEvents");
			_plusButtonContent = new GUIContent(EditorGUIUtility.Load("ol plus.png") as Texture, "Insert a new event after this one.");
			_minusButtonContent = new GUIContent(EditorGUIUtility.Load("ol minus.png") as Texture, "Delete this event.");
			_eventManager = (InputEventManager)target;
		}
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            rtpc = property.GetValue<AudioRTPC>();

            Begin(position, property, label);

            string rtpcName = string.Format("{4}{0} | {1} [{2}, {3}]", rtpc.Name, rtpc.Type, rtpc.MinValue, rtpc.MaxValue, rtpc.Scope == AudioRTPC.RTPCScope.Global ? "*" : "");
            PropertyField(property, rtpcName.ToGUIContent(), false);

            if (property.isExpanded)
            {
                EditorGUI.indentLevel++;

                PropertyField(property.FindPropertyRelative("Scope"), GUIContent.none);
                PropertyField(property.FindPropertyRelative("Name"));
                PropertyField(property.FindPropertyRelative("Type"));
                PropertyField(property.FindPropertyRelative("MinValue"));
                PropertyField(property.FindPropertyRelative("MaxValue"));
                PropertyField(property.FindPropertyRelative("Curve"));

                EditorGUI.indentLevel--;
            }

            End();
        }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
		{
			var spaceAttribute = attribute as SpaceAttribute;
			position.y += spaceAttribute.space;
			position.height -= spaceAttribute.space;
			EditorGUI.PropertyField(position, property, label);
		}
		/// <summary>
		/// 	Override this method to make your own GUI for the property
		/// </summary>
		/// <param name="position">Position</param>
		/// <param name="prop">Property</param>
		/// <param name="label">Label</param>
		public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
		{
			label = EditorGUI.BeginProperty(position, label, prop);

			position.height = EditorGUIUtility.singleLineHeight;
			Rect contents = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

			FindProperties(prop);

			// Draw the preview texture
			Rect textureRect = new Rect(contents);
			textureRect.x += textureRect.width - PREVIEW_TEXTURE_SIZE;
			textureRect.width = PREVIEW_TEXTURE_SIZE;
			textureRect.height = PREVIEW_TEXTURE_SIZE;

			EditorGUI.BeginChangeCheck();

			HydraEditorUtils.DrawUnindented(
										    () => HydraEditorUtils.TextureField(textureRect, GUIContent.none, m_TextureProp, true));

			// Draw the fields
			Rect contentRect = new Rect(contents);
			contentRect.width -= textureRect.width + HydraEditorUtils.STANDARD_HORIZONTAL_SPACING * 2.0f;
			HydraEditorUtils.DrawUnindented(
										    () =>
											HydraEditorUtils.EnumPopupField<Texture2DAttribute.Wrap>(contentRect, GUIContent.none, m_WrapProp,
																									 HydraEditorGUIStyles.enumStyle));

			// Clear the cache if the texture changes
			if (EditorGUI.EndChangeCheck())
				m_WrappedTextureProp.objectReferenceValue = null;

			EditorGUI.EndProperty();
		}
Example #18
0
        protected override void OnRender()
        {
            //GUI.skin.label.onNormal.
            var options = GetOptions().ToArray();
            var content = new GUIContent(Text, Image, Toolip);
            var oldFontStyle = GUI.skin.label.fontStyle;
            if (Style != (FontStyle)(-1))
            {
                GUI.skin.label.fontStyle = Style;
            }
            var oldAlign = GUI.skin.label.alignment;
            GUI.skin.label.alignment = Align;
            var oldColor = GUI.skin.label.normal.textColor;
            if (TextColor.a > 1e-4)
            {
                GUI.skin.label.normal.textColor = TextColor;
            }

            GUILayout.Label(content, options);

            if (TextColor.a > 1e-4)
            {
                GUI.skin.label.normal.textColor = oldColor;
            }
            GUI.skin.label.alignment = oldAlign;
            if (Style != (FontStyle)(-1))
            {
                GUI.skin.label.fontStyle = oldFontStyle;
            }
        }
Example #19
0
			public MenuItem(GUIContent _content, bool _separator, bool _on, GenericMenu.MenuFunction _func)
			{
				this.content = _content;
				this.separator = _separator;
				this.on = _on;
				this.func = _func;
			}
Example #20
0
File: Masks.cs Project: srndpty/VFW
 public int BunnyMask(GUIContent content, Enum enumValue)
 {
     var enumType = enumValue.GetType();
     var enumNames = Enum.GetNames(enumType);
     var enumValues = Enum.GetValues(enumType) as int[];
     return BunnyMask(content, Convert.ToInt32(enumValue), enumValues, enumNames);
 }
Example #21
0
		public override void OnGUI(Rect _position, SerializedProperty _property, GUIContent _label) {
			string valueStr;
			switch (_property.propertyType) {
				case SerializedPropertyType.Integer:
					valueStr = _property.intValue.ToString();
					break;
				case SerializedPropertyType.Boolean:
					valueStr = _property.boolValue.ToString();
					break;
				case SerializedPropertyType.Float:
					valueStr = _property.floatValue.ToString("0.00000");
					break;
				case SerializedPropertyType.String:
					valueStr = _property.stringValue;
					break;
				case SerializedPropertyType.Enum:
					valueStr = _property.enumDisplayNames[_property.enumValueIndex];
					break;
				case SerializedPropertyType.Vector2:
					valueStr = _property.vector2Value.ToString();
					break;
				case SerializedPropertyType.Vector3:
					valueStr = _property.vector3Value.ToString();
					break;
				default:
					valueStr = "(not supported)";
					break;
			}

			EditorGUI.LabelField(_position, _label.text + ":", valueStr);
		}
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     var valueProp = property.FindPropertyRelative("_value");
     var value = EditorGUI.FloatField(position, label, valueProp.floatValue);
     //if the value increased ever so much, ceil the value, good for the mouse scroll
     valueProp.floatValue = NormalizeValue(valueProp.floatValue, value);
 }
        public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
        {
            Rect position = rect;
            position.height = EditorGUIUtility.singleLineHeight;
            SerializedProperty property = prop.FindPropertyRelative("m_NormalTrigger");
            SerializedProperty property2 = prop.FindPropertyRelative("m_HighlightedTrigger");
            SerializedProperty property3 = prop.FindPropertyRelative("m_PressedTrigger");
            SerializedProperty property4 = prop.FindPropertyRelative("m_ActiveTrigger");
            SerializedProperty property5 = prop.FindPropertyRelative("m_ActiveHighlightedTrigger");
            SerializedProperty property6 = prop.FindPropertyRelative("m_ActivePressedTrigger");
            SerializedProperty property7 = prop.FindPropertyRelative("m_DisabledTrigger");

            EditorGUI.PropertyField(position, property);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property2);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property3);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property4);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property5);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property6);
            position.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
            EditorGUI.PropertyField(position, property7);
        }
 public void SplitArea(GUIContent content, GUIStyle style)
 {
     GUIStyle borderStyle = new GUIStyle();
     GUILayout.EndArea();
     if(_horizontal)
     {
         borderStyle.normal.background = EditorGUIUtility.LoadRequired("AreaHBorder.png") as Texture2D;
         _auxRect.Set(_used, 0f, 4f, Screen.height);
         GUILayout.BeginArea(_auxRect, borderStyle);
         _auxRect.x = 0f;
         EditorGUIUtility.AddCursorRect(_auxRect, MouseCursor.SplitResizeLeftRight);
     }
     else
     {
         borderStyle.normal.background = EditorGUIUtility.LoadRequired("AreaVBorder.png") as Texture2D;
         _auxRect.Set(0f, _used, Screen.width, 4f);
         GUILayout.BeginArea(_auxRect, borderStyle);
         _auxRect.y = 0f;
         EditorGUIUtility.AddCursorRect(_auxRect, MouseCursor.SplitResizeUpDown);
     }
     _used += 4f;
     ProcessInputMouse();
     GUILayout.EndArea();
     GUILayout.BeginArea(NextRect, content, style);
 }
Example #25
0
 public override UnityObject Object(GUIContent content, UnityObject value, System.Type type, bool allowSceneObjects, Layout option)
 {
     // If we pass an empty content, ObjectField will still reserve space for an empty label ~__~
     return string.IsNullOrEmpty(content.text) ?
         EditorGUILayout.ObjectField(value, type, allowSceneObjects, option) :
         EditorGUILayout.ObjectField(content, value, type, allowSceneObjects, option);
 }
Example #26
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            drawPrefixLabel = false;

            Begin(position, property, label);

            float min = ((SliderAttribute)attribute).min;
            float max = ((SliderAttribute)attribute).max;

            EditorGUI.BeginChangeCheck();

            currentPosition.height = 16;
            object value = property.GetValue();

            if (value is int) {
                property.SetValue(EditorGUI.IntSlider(currentPosition, label, (int)value, (int)min, (int)max));
            }
            else if (value is float) {
                property.SetValue(EditorGUI.Slider(currentPosition, label, (float)value, min, max));
            }
            else if (value is double) {
                property.SetValue(EditorGUI.Slider(currentPosition, label, (float)(double)value, min, max));
            }
            else {
                EditorGUI.HelpBox(currentPosition, "The type of the field must be numerical.", MessageType.Error);
            }

            if (EditorGUI.EndChangeCheck()) {
                property.Clamp(min, max);
            }

            End();
        }
		public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
			
			EditorGUI.PropertyField(position, property, label, includeChildren: true);

			var attribute = PropertyExtensions.GetAttribute<BeginGroupAttribute>(this);
			var otherProp = PropertyExtensions.GetRelativeProperty(property, property.propertyPath, attribute.otherFieldName);

			var isNull = false;
			if (property.propertyType == SerializedPropertyType.ObjectReference) {

				isNull = (property.objectReferenceValue == null);

			}

			if (isNull == true && otherProp != null) {

				if (otherProp.propertyType == SerializedPropertyType.ObjectReference) {

					isNull = (otherProp.objectReferenceValue == null);

				}

			}

			++EditorGUI.indentLevel;
			EditorGUI.BeginDisabledGroup(isNull);

			CustomGUI.Splitter();

		}
        public override void Initialize(SerializedProperty property, GUIContent label)
        {
            base.Initialize(property, label);

            if (groupData == null)
                InitializeGroups();
        }
Example #29
0
        public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) 
        {
            float value = 0f;
            if (property.propertyType == SerializedPropertyType.Float)
            {
                value = property.floatValue;
                isNumericValue = true;
            }
            else
            if (property.propertyType == SerializedPropertyType.Integer)
            {
                value = (float)property.intValue;
                isNumericValue = true;
            }
            else
            {
                isNumericValue = false;
            }

            if (isNumericValue)
            {
                ProgressBarAttribute barAttribute = (ProgressBarAttribute)attribute;
                EditorGUI.BeginProperty(position, label, property);
                EditorGUI.ProgressBar(position, (value / barAttribute.max), label.text);
                EditorGUI.EndProperty();
            }
            else
            {
                EditorGUI.BeginProperty(position, label, property);
                EditorGUI.PropertyField(position, property);
                EditorGUI.EndProperty();
            }
        }
		private void DrawExtraFeatures() {
			if (icon == null) {
				string iconFilename = EditorGUIUtility.isProSkin ? DarkSkinIconFilename : LightSkinIconFilename;
				icon = AssetDatabase.LoadAssetAtPath(iconFilename, typeof(Texture2D)) as Texture2D;
			}
			if (dialogueSystemController == null || icon == null) return;
			if (iconButtonStyle == null) {
				iconButtonStyle = new GUIStyle(EditorStyles.label);
				iconButtonStyle.normal.background = icon;
				iconButtonStyle.active.background = icon;
			}
			if (iconButtonContent == null) {
				iconButtonContent = new GUIContent(string.Empty, "Click to open Dialogue Editor.");
			}
			GUILayout.BeginHorizontal();
			if (GUILayout.Button(iconButtonContent, iconButtonStyle, GUILayout.Width(icon.width), GUILayout.Height(icon.height))) {
				Selection.activeObject = dialogueSystemController.initialDatabase;
				PixelCrushers.DialogueSystem.DialogueEditor.DialogueEditorWindow.OpenDialogueEditorWindow();
			}
			GUILayout.FlexibleSpace();
			if (GUILayout.Button("Wizard...", GUILayout.Width(64))) {
				DialogueManagerWizard.Init();
			}
			GUILayout.EndHorizontal();
			EditorWindowTools.DrawHorizontalLine();
		}