// Draw the property inside the given rect
    public override void OnGUI( Rect position, SerializedProperty property, GUIContent label )
    {
        // Now draw the property as a Slider or an IntSlider based on whether it’s a float or integer.
        if ( property.type != "MinMaxRange" )
            Debug.LogWarning( "Use only with MinMaxRange type" );
        else
        {
            var range = attribute as MinMaxRangeAttribute;
            var minValue = property.FindPropertyRelative( "rangeStart" );
            var maxValue = property.FindPropertyRelative( "rangeEnd" );
            var newMin = minValue.floatValue;
            var newMax = maxValue.floatValue;

            var xDivision = position.width * 0.33f;
            var yDivision = position.height * 0.5f;
            EditorGUI.LabelField( new Rect( position.x, position.y, xDivision, yDivision ), label );

            EditorGUI.LabelField( new Rect( position.x, position.y + yDivision, position.width, yDivision ), range.minLimit.ToString( "0.##" ) );
            EditorGUI.LabelField( new Rect( position.x + position.width - 28f, position.y + yDivision, position.width, yDivision ), range.maxLimit.ToString( "0.##" ) );
            EditorGUI.MinMaxSlider( new Rect( position.x + 24f, position.y + yDivision, position.width - 48f, yDivision ), ref newMin, ref newMax, range.minLimit, range.maxLimit );

            EditorGUI.LabelField( new Rect( position.x + xDivision, position.y, xDivision, yDivision ), "From: " );
            newMin = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision + 30, position.y, xDivision - 30, yDivision ), newMin ), range.minLimit, newMax );
            EditorGUI.LabelField( new Rect( position.x + xDivision * 2f, position.y, xDivision, yDivision ), "To: " );
            newMax = Mathf.Clamp( EditorGUI.FloatField( new Rect( position.x + xDivision * 2f + 24, position.y, xDivision - 24, yDivision ), newMax ), newMin, range.maxLimit );

            minValue.floatValue = newMin;
            maxValue.floatValue = newMax;
        }
    }
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        var propText = property.FindPropertyRelative("text");
        var propTurnHead = property.FindPropertyRelative("turnHead");

        return EditorGUI.GetPropertyHeight(propText) + EditorGUI.GetPropertyHeight(propTurnHead);
    }
示例#3
0
   public void In(
      [FriendlyName("Text", "The text you want to display.")]
      string Text,
      
      [FriendlyName("Position", "The position and size of the label.")]
      Rect Position,
      
      [FriendlyName("Texture", "The background image to use for the label.")]
      Texture2D Texture,
      
      [FriendlyName("Tool Tip", "The tool tip to display when the label is being hovered over.")]
      [DefaultValue(""), SocketState(false, false)]
      string ToolTip,
      
      [FriendlyName("GUI Style", "The name of a custom GUI style to use when displaying this box.")]
      [DefaultValue(""), SocketState(false, false)]
      string guiStyle
      )
   {
      GUIContent content = new GUIContent(Text, Texture, ToolTip);

      if (string.IsNullOrEmpty(guiStyle))
      {
         GUI.Box(Position, content);
      }
      else
      {
         GUI.Box(Position, content, GUI.skin.GetStyle(guiStyle));
      }
   }
示例#4
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty(position, label, property);

        MinMax minMax = attribute as MinMax;

        if (property.propertyType != SerializedPropertyType.Vector2) {
            EditorGUI.PropertyField(position, property);
            Debug.LogWarning("The MinMax property can only be used on Vector2!");
            return;
        }

        Vector2 value = property.vector2Value;

        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        float w = position.width * PERCENT_NUM;

        Rect leftNum = new Rect(position.x, position.y, w, position.height);
        Rect slider = new Rect(position.x + w + SPACING, position.y, position.width - 2 * w - SPACING * 2, position.height);
        Rect rightNum = new Rect(position.x + position.width - w, position.y, w, position.height);

        float newMin = EditorGUI.FloatField(leftNum, value.x);
        float newMax = EditorGUI.FloatField(rightNum, value.y);

        value.x = Mathf.Clamp(newMin, minMax.min, value.y);
        value.y = Mathf.Clamp(newMax, value.x, minMax.max);

        EditorGUI.MinMaxSlider(slider, ref value.x, ref value.y, minMax.min, minMax.max);

        property.vector2Value = value;

        EditorGUI.EndProperty();
    }
示例#5
0
    void OnGUI()
    {
        if (showStartingScreen) {
            int height = (int)(Screen.height * .2f);
            GUI.Box(new Rect(0, Screen.height / 2 - height / 2, Screen.width, height),"");

            GUIContent text = new GUIContent("" + ((num == 0) ? "GO" : num + ""));

            GUIStyle watStyle = new GUIStyle(textStyle);
            int x = 0;
            if (currTime < .2f) {
                x = (int)(currTime / .2f * Screen.width / 2 - watStyle.CalcSize(text).x / 2);
            } else if (currTime >= .2f && currTime <= .8f) {
                watStyle.fontSize += (int)(20 - 20*((Mathf.Abs(.5f - currTime))/.3f));
                x = (int)(Screen.width / 2 - watStyle.CalcSize(text).x / 2);
            } else if (currTime > .8f) {
                x = (int)((currTime - .8f) / .2f * Screen.width/2 - watStyle.CalcSize(text).x / 2 + Screen.width /2);
            }
            GUI.Label(new Rect(x, Screen.height / 2 - watStyle.CalcSize(text).y / 2, 100, 100),text, watStyle);

            currTime += Time.realtimeSinceStartup - lastTime;
            lastTime = Time.realtimeSinceStartup;
            if (currTime >= 1f) {
                currTime = 0f;
                num--;
            }

            if (num < 0) {
                showStartingScreen = false;
                Time.timeScale = 1;
            }
        }
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {
        WritableAttribute attr = attribute as WritableAttribute;
        GUI.enabled = attr.Result(DrawerUtil.GetTarget(property));
        DrawerUtil.OnGUI(position, property, label);
        GUI.enabled = true;

    }
示例#7
0
    public static bool List(Rect position, ref bool showList, ref int listEntry, GUIContent buttonContent, GUIContent[] listContent,
	                         GUIStyle buttonStyle, GUIStyle boxStyle, GUIStyle listStyle)
    {
        int controlID = GUIUtility.GetControlID (popupListHash, FocusType.Passive);
                bool done = false;
                switch (Event.current.GetTypeForControl (controlID)) {
                case EventType.mouseDown:
                        if (position.Contains (Event.current.mousePosition)) {
                                GUIUtility.hotControl = controlID;
                                showList = true;
                        }
                        break;
                case EventType.mouseUp:
                        if (showList) {
                                done = true;
                        }
                        break;
                }

                GUI.Label (position, buttonContent, buttonStyle);
                if (showList) {
                        Rect listRect = new Rect (position.x, position.y, position.width, listStyle.CalcHeight (listContent [0], 1.0f) * listContent.Length);
                        GUI.Box (listRect, "", boxStyle);
                        listEntry = GUI.SelectionGrid (listRect, listEntry, listContent, 1, listStyle);
                }
                if (done) {
                        showList = false;
                }
                return done;
    }
    /// <summary>
    /// Show the RequiredField inspector. Changes depending on the field being
    /// empty or not.
    /// </summary>
    public override void OnGUI(Rect a_position, SerializedProperty a_property, GUIContent a_label)
    {
        // Split the widget position rectangle horizontally.
        Rect bottom = new Rect();
        Rect top = new Rect();
        SplitRect(a_position, ref top, ref bottom);

        // Save the default GUI color for later.
        Color defaultColor = GUI.color;

        // If the object pointed by the property is null, then show the error
        // message, and set the GUI color to red to display the PropertyField in
        // red.
        if(a_property.objectReferenceValue == null) {
            EditorGUI.HelpBox(top, "The field below is required and can't be empty.", MessageType.Error);
            GUI.color = Color.red;
        }

        // Draw the default property field, this drawer does not alter the GUI.
        if(a_property.objectReferenceValue == null) {
            EditorGUI.PropertyField(bottom, a_property, a_label);
        }
        else {
            EditorGUI.PropertyField(a_position, a_property, a_label);
        }

        // Restore the original colors.
        GUI.color = defaultColor;
    }
	public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
	{
		position.height = 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("Room"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("RoomHigh"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("RoomLow"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("DecayTime"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("DecayHighRatio"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("Reflections"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("ReflectionsDelay"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("Reverb"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("ReverbDelay"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("HFReference"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("LFReference"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("RoomRolloff"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("Diffusion"));
		position.y += 16f;
		EditorGUI.PropertyField(position, property.FindPropertyRelative("Density"));
	}
    void DrawLights(Light[] lights, ref int i)
    {
        GUIContent tooltip = new GUIContent("", "Is the game object active in hierarchy and the light component enabled.");
        foreach (Light light in lights)
        {
            if (light == null)
                continue;

            EditorGUI.BeginDisabledGroup(light.shadows == LightShadows.None);

            EditorGUILayout.BeginHorizontal();

            string controlName = "ObjectField-" + i;
            GUI.SetNextControlName(controlName);
            EditorGUILayout.ObjectField(light, typeof(Light), true);

            if (GUILayout.Button("Select"))
            {
                Selection.activeGameObject = light.gameObject;
                SceneView.lastActiveSceneView.FrameSelected();
                GUI.FocusControl(controlName);
            }
            if (GUILayout.Button("Disable shadows"))
            {
                light.shadows = LightShadows.None;
            }
            GUILayout.Toggle(light.gameObject.activeInHierarchy && light.enabled, tooltip, GUILayout.ExpandWidth (false));
            EditorGUILayout.EndHorizontal();

            EditorGUI.EndDisabledGroup();
        }
    }
	public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) {

		var attribute = this.attribute as ReadOnlyAttribute;
		if (string.IsNullOrEmpty(attribute.header) == true) {
			
			var oldState = GUI.enabled;
			GUI.enabled = false;
			EditorGUI.PropertyField(position, property, label, true);
			GUI.enabled = oldState;

		} else {

			var posHeader = position;
			var posContent = new Rect(posHeader.x, posHeader.y + posHeader.height * 0.5f, posHeader.width, posHeader.height * 0.5f);

			var oldValue = new GUIContent(label);
			EditorGUI.LabelField(posHeader, attribute.header, EditorStyles.boldLabel);

			if (attribute.drawHeaderOnly == false) {

				var oldState = GUI.enabled;
				GUI.enabled = false;
				EditorGUI.PropertyField(posContent, property, oldValue, true);
				GUI.enabled = oldState;

			}

		}

	}
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        //EditorGUI.BeginProperty(position, GUIContent.none, property);
        //SerializedProperty memberProperty = property.FindPropertyRelative("PropertyName");
        //SerializedProperty typeProperty = property.FindPropertyRelative("Type");
        SerializedProperty propertyProperty = property.FindPropertyRelative("PropertyType");
        PropertyTypeInfo propertyTypeInfo = (PropertyTypeInfo) propertyProperty.enumValueIndex;
        SerializedProperty curve1Property = property.FindPropertyRelative("Curve1");
        SerializedProperty curve2Property = property.FindPropertyRelative("Curve2");
        SerializedProperty curve3Property = property.FindPropertyRelative("Curve3");
        SerializedProperty curve4Property = property.FindPropertyRelative("Curve4");

        int count = UnityPropertyTypeInfo.GetCurveCount(propertyTypeInfo);

        EditorGUI.indentLevel++;
            if(count > 0)
            EditorGUILayout.PropertyField(curve1Property);
            if (count > 1)
            EditorGUILayout.PropertyField(curve2Property);
            if (count > 2)
            EditorGUILayout.PropertyField(curve3Property);
            if (count > 3)
            EditorGUILayout.PropertyField(curve4Property);
        EditorGUI.indentLevel--;

        //EditorGUI.EndProperty();
    }
   public void In(
      [FriendlyName("Text", "Text to display on the label.")]
      string Text,

      [FriendlyName("Texture", "Texture to display on the label.")]
      [SocketState(false, false)]
      Texture Texture,
      
      [FriendlyName("Tooltip", "The tooltip associated with this control.")]
      [DefaultValue(""), SocketState(false, false)]
      string Tooltip,

      [FriendlyName("Style", "The style to use. If left out, the \"label\" style from the current GUISkin is used.")]
      [DefaultValue(""), SocketState(false, false)]
      string Style,

      [FriendlyName("Options", "An optional list of layout parameters.  Any values passed in here will override settings defined by the style.")]
      [SocketState(false, false)]
      GUILayoutOption[] Options
      )
   {
      GUIContent content = new GUIContent(Text, Texture, Tooltip);
      GUIStyle style = (string.IsNullOrEmpty(Style) ? GUI.skin.label : GUI.skin.GetStyle(Style));

      GUILayout.Label(content, style, Options);
   }
示例#14
0
    /** Draws an integer field */
    public int IntField(GUIContent label, int value, int offset, int adjust, out Rect r, out bool selected)
    {
        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;
        selected = on;

        if (Event.current.type == EventType.Repaint) {
            intStyle.Draw (r1,label,false,false,false,on);
        }

        return value;
    }
 public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
 {
     //SerializedProperty me = prop.FindPropertyRelative("this");
     //SerializedProperty scale = prop.FindPropertyRelative("scale");
     //SerializedProperty curve = prop.FindPropertyRelative("curve");
     //EditorGUI.LabelField(pos, "hi" + resources);
     var rowRect = new Rect(pos.x, pos.y, pos.width, base.GetPropertyHeight(prop, label));
     isFoldedOut = EditorGUI.Foldout(new Rect(rowRect.x, rowRect.y, rowRect.width - 20, rowRect.height), isFoldedOut, "Resources");
     if (isFoldedOut) {
         var resources = prop.FindPropertyRelative("Resources");
         if (GUI.Button(new Rect(rowRect.x + rowRect.width - 22, rowRect.y + 1, 22, rowRect.height - 2), "+")) {
             resources.InsertArrayElementAtIndex(resources.arraySize);
         }
         rowRect.y += rowRect.height;
         for (int i = 0; i < resources.arraySize; ++i) {
             var item = resources.GetArrayElementAtIndex(i);
             var minusClick = GUI.Button(new Rect(rowRect.x, rowRect.y, 22, rowRect.height), "-");
             EditorGUI.PropertyField(new Rect(rowRect.x + 20, rowRect.y, rowRect.width - 21, rowRect.height), item);
             if (minusClick) {
                 if (Event.current.button == 1) {
                     // Now create the menu, add items and show it
                     var menu = new GenericMenu();
                     if (i > 0)
                         menu.AddItem(new GUIContent("Move Up"), false, (itm) => { resources.MoveArrayElement((int)itm, (int)itm - 1); }, i);
                     if (i < resources.arraySize - 1)
                         menu.AddItem(new GUIContent("Move Down"), false, (itm) => { resources.MoveArrayElement((int)itm, (int)itm + 1); }, i);
                     menu.ShowAsContext();
                 } else {
                     resources.DeleteArrayElementAtIndex(i--);
                 }
             }
             rowRect.y += rowRect.height;
         }
     }
 }
 public static void ShowWindow()
 {
     GUIContent newWindowContent = new GUIContent("PlatformGenerator", (Texture)AssetDatabase.LoadAssetAtPath("Assets/Art/PlatformTiles/tile5.png", typeof(Texture)), "Tool to generate new platforms with width and height");
     _window = EditorWindow.GetWindow(typeof(PlatformGenerateEditor));
     _platformGenerator = new PlatformGenerator();
     _window.titleContent = newWindowContent;
 }
 public override void OnGUI(Rect position, SerializedProperty prop, GUIContent label)
 {
     var typeAttr = attribute as BitMaskAttribute;
      // Add the actual int value behind the field name
      label.text = label.text + "("+prop.intValue+")";
      prop.intValue = DrawBitMaskField(position, prop.intValue, typeAttr.propType, label);
 }
 public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
 {
     var resources = prop.FindPropertyRelative("Resources");
     //return prop.FindPropertyRelative("Resources").serializedObject * base.GetPropertyHeight(prop, label);
     return base.GetPropertyHeight(prop, label) +
         (isFoldedOut ? resources.arraySize * base.GetPropertyHeight(prop, label) : 0);
 }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        SerializedProperty direction = property.FindPropertyRelative ("direction");
        SerializedProperty accuracy = property.FindPropertyRelative ("accuracy");
        EditorGUI.BeginProperty (position, label, property);
        Rect contentPosition = EditorGUI.PrefixLabel (position, label);
        int indent = EditorGUI.indentLevel;
        EditorGUI.indentLevel = 0;

        float fullWidth = contentPosition.width;

        contentPosition.width = fullWidth * 0.2f;
        float x = contentPosition.x;

        contentPosition.x = x;
        EditorGUIUtility.labelWidth = 20f;
        EditorGUI.PropertyField (contentPosition, direction, new GUIContent ("Dir"));

        x += contentPosition.width;
        contentPosition.width = fullWidth * .4f;
        contentPosition.x = x;
        EditorGUIUtility.labelWidth = 50f;
        EditorGUI.PropertyField (contentPosition, accuracy);

        EditorGUI.indentLevel = indent;
        EditorGUI.EndProperty ();
    }
示例#20
0
文件: PopTest.cs 项目: ylyking/lynea
    // Use this for initialization
    void Start()
    {
        // Make some content for the popup list
        list = new GUIContent[5];
        list[0] = new GUIContent("Foo");
        list[1] = new GUIContent("Bar");
        list[2] = new GUIContent("Thing1");
        list[3] = new GUIContent("Thing2");
        list[4] = new GUIContent("Thing3");

        // Make a GUIStyle that has a solid white hover/onHover background to indicate highlighted items
        listStyle = new GUIStyle();
        listStyle.normal.textColor = Color.white;
        Texture2D texture = new Texture2D(1, 1);

        // Fill the texture
        texture.SetPixel(0, 0, Color.grey);

        // Apply all SetPixel calls
        texture.Apply();

        listStyle.hover.background = texture;
        listStyle.onHover.background = texture;
        listStyle.padding.left = listStyle.padding.right = 4;
        listStyle.padding.top = listStyle.padding.bottom = 2;
    }
示例#21
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        position.height = 16f;
        foldout = EditorGUI.Foldout(position, foldout, label);
        if (foldout)
        {
            //EditorGUI.BeginChangeCheck();
            //{
            //    Rect rect = EditorGUI.IndentedRect(position);
            //    int size = property.arraySize;
            //    size = EditorGUI.IntField(rect, size);
            //}
            //if (EditorGUI.EndChangeCheck())
            //{
            //    property.
            //}

            string[] names = Enum.GetNames(nameListAttribute.enumType);
            Rect rect = EditorGUI.IndentedRect(position);
            //rect.height = GetPropertyHeight()
            for (int i = 0; i < names.Length; i++)
            {

                rect.y += rect.height;
                //rect.height = 15f;
                EditorGUI.PropertyField(rect, property.GetArrayElementAtIndex(i), new GUIContent(i >= names.Length ? "" : names[i]));
            }
        }
    }
   public void In(
      [FriendlyName("Text", "Text to display on group.")]
      [SocketState(false, false)]
      string Text,

      [FriendlyName("Texture", "Texture to display on group.")]
      [SocketState(false, false)]
      Texture Texture,

      [FriendlyName("Tooltip", "The tooltip associated with this control.")]
      [DefaultValue(""), SocketState(false, false)]
      string Tooltip,

      [FriendlyName("Style", "The style to use. If left out, none will be used.")]
      [DefaultValue(""), SocketState(false, false)]
      string Style,

      [FriendlyName("Options", "An optional list of layout parameters.  Any values passed in here will override settings defined by the style.")]
      [SocketState(false, false)]
      GUILayoutOption[] Options
      )
   {
      GUIContent content = GUIContent.none;
      if (string.IsNullOrEmpty(Text) == false
         || string.IsNullOrEmpty(Tooltip) == false
         || Texture != null)
      {
         content = new GUIContent(Text, Texture, Tooltip);
      }

      GUIStyle style = (string.IsNullOrEmpty(Style) ? GUIStyle.none : GUI.skin.GetStyle(Style));

      GUILayout.BeginHorizontal(content, style, Options);
   }
示例#23
0
 public static GUIContent[] GetHcEffectControls_Rotate()
 {
     GUIContent[]	cons = new GUIContent[2];
     cons[0]	= new GUIContent("Rot"	, "");
     cons[1]	= new GUIContent("Fix"	, "");
     return cons;
 }
示例#24
0
 public GUIContent GetContent()
 {
     GUIContent gc = new GUIContent("");
     if(this.IsWeapon()) gc = DataHolder.Weapons().GetContent(this.equipID);
     else if(this.IsArmor()) gc = DataHolder.Armors().GetContent(this.equipID);
     return gc;
 }
    void Initialize(SerializedProperty property)
    {
        if (listedScenes != null && listedScenes.Length > 0)
            return;

        var scenes = EditorBuildSettings.scenes;
        var selectableScenes = new System.Collections.Generic.List<EditorBuildSettingsScene>();

        SceneSelectionAttribute attr = (SceneSelectionAttribute)attribute;

        for (int i = 0; i < scenes.Length; i++)
        {
            if (scenes[i].enabled || attr.allowDisabledScenes)
                selectableScenes.Add(scenes[i]);
        }
        listedScenes = new GUIContent[selectableScenes.Count];

        for (int i = 0; i < listedScenes.Length; i++)
        {
            var path = selectableScenes[i].path;
            int lastSeparator = path.LastIndexOf("/") + 1;
            var sceneName = path.Substring(lastSeparator, path.LastIndexOf(".") - lastSeparator);
            listedScenes[i] = new GUIContent(sceneName, selectableScenes[i].enabled ? "Enabled" : "Disabled");
            if (listedScenes[i].text.Equals(property.stringValue))
                selectedIndex = i;
        }
    }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        EditorGUI.BeginProperty (position, label, property);

        // Draw label
        position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);

        // Get properties
        var clipProp = property.FindPropertyRelative("clip");
        var volumeProp = property.FindPropertyRelative("volume");
        var vLabelContent = new GUIContent("Volume");

        // Calc rects
        var clipRect = new Rect(position.x, position.y, position.width, EditorGUIUtility.singleLineHeight);

        var volumeRect = new Rect(position.x, position.y + clipRect.height, position.width, EditorGUIUtility.singleLineHeight);
        var vLabelRect = new Rect(volumeRect.x, volumeRect.y, 50, volumeRect.height);
        var vSliderRect = new Rect(volumeRect.x + vLabelRect.width, volumeRect.y, volumeRect.width - vLabelRect.width, volumeRect.height);

        // Create labels
        var clipLabel = new GUIContent("clip");
        var volumeLabel = new GUIContent("volume");

        // Draw fields
        EditorGUI.BeginProperty(clipRect, clipLabel, clipProp);
            EditorGUI.PropertyField(clipRect, clipProp, GUIContent.none);
        EditorGUI.EndProperty();
        EditorGUI.BeginProperty(volumeRect, volumeLabel, volumeProp);
            EditorGUI.LabelField(vLabelRect, vLabelContent);
            EditorGUI.PropertyField(vSliderRect, volumeProp, GUIContent.none);
        EditorGUI.EndProperty();

        EditorGUI.EndProperty();
    }
示例#27
0
    // This function is ran inside of OnGUI()
    // For usage, see http://wiki.unity3d.com/index.php/PopupList#Javascript_-_PopupListUsageExample.js
    public int List(Rect box, GUIContent[] items, GUIStyle boxStyle, GUIStyle listStyle)
    {
        // If the instance's popup selection is visible
        if(isVisible) {

            // Draw a Box
            Rect listRect = new Rect( box.x, box.y + box.height, box.width, box.height * items.Length);
            GUI.Box( listRect, "", boxStyle );

            // Draw a SelectionGrid and listen for user selection
            selectedItemIndex = GUI.SelectionGrid( listRect, selectedItemIndex, items, 1, listStyle );

            // If the user makes a selection, make the popup list disappear
            if(GUI.changed) {
                current = null;
            }
        }

        // Get the control ID
        int controlID = GUIUtility.GetControlID( FocusType.Passive );

        // Listen for controls
        switch( Event.current.GetTypeForControl(controlID) )
        {
            // If mouse button is clicked, set all Popup selections to be retracted
            case EventType.mouseUp:
            {
                current = null;
                break;
            }
        }

        // Draw a button. If the button is clicked
        if(GUI.Button(new Rect(box.x,box.y,box.width,box.height),items[selectedItemIndex])) {

            // If the button was not clicked before, set the current instance to be the active instance
            if(!isClicked) {
                current = this;
                isClicked = true;
            }
            // If the button was clicked before (it was the active instance), reset the isClicked boolean
            else {
                isClicked = false;
            }
        }

        // If the instance is the active instance, set its popup selections to be visible
        if(current == this) {
            isVisible = true;
        }

        // These resets are here to do some cleanup work for OnGUI() updates
        else {
            isVisible = false;
            isClicked = false;
        }

        // Return the selected item's index
        return selectedItemIndex;
    }
示例#28
0
    public void unlocksMenu(int id)
    {
        GUILayout.FlexibleSpace();
        GUILayout.BeginHorizontal();

        UnlockData[] unlocks = FindObjectsOfType<UnlockData>();
        for (int i = 0; i < unlocks.Length; i++ ) {
            UnlockData unlock = unlocks[i];
            GUIContent content = new GUIContent();
            content.text = unlock.name;
            content.image = unlock.texture;
            content.tooltip = unlock.description;

            if (i != 0 && i % 2 == 0) {
                GUILayout.EndHorizontal();
                GUILayout.BeginHorizontal();
            }

            GUI.enabled = unlock.isUnlocked;
            unlock.isActivated = GUILayout.Toggle(unlock.isActivated, content);
            GUI.enabled = true;
        }

        GUILayout.EndHorizontal();
        GUILayout.FlexibleSpace();
        printButton("Back", () => currentMenu = 0);
    }
    /// <summary>
    /// 覆盖OnGUI方式,将使得BoolVector3的默认Inspector显示方式失效,采用自定义的显示方式
    /// </summary>
    /// <param name="position"></param>
    /// <param name="property"></param>
    /// <param name="label"></param>
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // 默认显示方式
        // base.OnGUI(position, property, label);

        // 自定义
        {
            // 1.获得自定义属性类中,我们需要绘制的属性
            SerializedProperty x = property.FindPropertyRelative("x");
            SerializedProperty y = property.FindPropertyRelative("y");
            SerializedProperty z = property.FindPropertyRelative("z");

            float propWidth = position.width / 6.0f;

            // 2.创建对应属性的文本描述
            EditorGUI.LabelField(new Rect(position.x, position.y, propWidth, position.height), "X");
            // 3.创建对应属性的实际控制组件(如 bool,我们使用Toggle)
            x.boolValue = EditorGUI.Toggle(new Rect(position.x + propWidth * 1, position.y, propWidth, position.height), x.boolValue);

            EditorGUI.LabelField(new Rect(position.x + propWidth * 2, position.y, propWidth, position.height), "Y");
            y.boolValue = EditorGUI.Toggle(new Rect(position.x + propWidth * 3, position.y, propWidth, position.height), y.boolValue);

            EditorGUI.LabelField(new Rect(position.x + propWidth * 4, position.y, propWidth, position.height), "Z");
            z.boolValue = EditorGUI.Toggle(new Rect(position.x + propWidth * 5, position.y, propWidth, position.height), z.boolValue);
        }
    }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Button"/> class.
 /// </summary>
 /// <param name='bounds'>
 /// Bounds.
 /// </param>
 /// <param name='content'>
 /// Content.
 /// </param>
 /// <param name='style'>
 /// Style.
 /// </param>
 public Button(Rectangle bounds, GUIContent content, GUISkin skin)
     : this()
 {
     this.Bounds = bounds;
     this.Content = content;
     this.Skin = skin;
 }
示例#31
0
        protected virtual void OnEnable()
        {
#if NEW_PREFAB_SYSTEM
            isInspectingPrefab = false;
#else
            isInspectingPrefab = (PrefabUtility.GetPrefabType(target) == PrefabType.Prefab);
#endif
            SpineEditorUtilities.ConfirmInitialization();
            loadingFailed = false;

            // Labels
            SkeletonDataAssetLabel       = new GUIContent("SkeletonData Asset", Icons.spine);
            SkeletonUtilityButtonContent = new GUIContent("Add Skeleton Utility", Icons.skeletonUtility);
            ImmubleTrianglesLabel        = new GUIContent("Immutable Triangles", "Enable to optimize rendering for skeletons that never change attachment visbility");
            PMAVertexColorsLabel         = new GUIContent("PMA Vertex Colors", "Use this if you are using the default Spine/Skeleton shader or any premultiply-alpha shader.");
            ClearStateOnDisableLabel     = new GUIContent("Clear State On Disable", "Use this if you are pooling or enabling/disabling your Spine GameObject.");
            ZSpacingLabel                       = new GUIContent("Z Spacing", "A value other than 0 adds a space between each rendered attachment to prevent Z Fighting when using shaders that read or write to the depth buffer. Large values may cause unwanted parallax and spaces depending on camera setup.");
            NormalsLabel                        = new GUIContent("Add Normals", "Use this if your shader requires vertex normals. A more efficient solution for 2D setups is to modify the shader to assume a single normal value for the whole mesh.");
            TangentsLabel                       = new GUIContent("Solve Tangents", "Calculates the tangents per frame. Use this if you are using lit shaders (usually with normal maps) that require vertex tangents.");
            TintBlackLabel                      = new GUIContent("Tint Black (!)", "Adds black tint vertex data to the mesh as UV2 and UV3. Black tinting requires that the shader interpret UV2 and UV3 as black tint colors for this effect to work. You may also use the default [Spine/Skeleton Tint Black] shader.\n\nIf you only need to tint the whole skeleton and not individual parts, the [Spine/Skeleton Tint] shader is recommended for better efficiency and changing/animating the _Black material property via MaterialPropertyBlock.");
            SingleSubmeshLabel                  = new GUIContent("Use Single Submesh", "Simplifies submesh generation by assuming you are only using one Material and need only one submesh. This is will disable multiple materials, render separation, and custom slot materials.");
            UpdateWhenInvisibleLabel            = new GUIContent("Update When Invisible", "Update mode used when the MeshRenderer becomes invisible. Update mode is automatically reset to UpdateMode.FullUpdate when the mesh becomes visible again.");
            FixDrawOrderLabel                   = new GUIContent("Fix Draw Order", "Applies only when 3+ submeshes are used (2+ materials with alternating order, e.g. \"A B A\"). If true, GPU instancing will be disabled at all materials and MaterialPropertyBlocks are assigned at each material to prevent aggressive batching of submeshes by e.g. the LWRP renderer, leading to incorrect draw order (e.g. \"A1 B A2\" changed to \"A1A2 B\"). You can disable this parameter when everything is drawn correctly to save the additional performance cost. Note: the GPU instancing setting will remain disabled at affected material assets after exiting play mode, you have to enable it manually if you accidentally enabled this parameter.");
            FixPrefabOverrideViaMeshFilterLabel = new GUIContent("Fix Prefab Overr. MeshFilter", "Fixes the prefab always being marked as changed (sets the MeshFilter's hide flags to DontSaveInEditor), but at the cost of references to the MeshFilter by other components being lost.");
            MaskInteractionLabel                = new GUIContent("Mask Interaction", "SkeletonRenderer's interaction with a Sprite Mask.");
            MaskMaterialsHeadingLabel           = new GUIContent("Mask Interaction Materials", "Materials used for different interaction with sprite masks.");
            MaskMaterialsNoneLabel              = new GUIContent("Normal Materials", "Normal materials used when Mask Interaction is set to None.");
            MaskMaterialsInsideLabel            = new GUIContent("Inside Mask", "Materials used when Mask Interaction is set to Inside Mask.");
            MaskMaterialsOutsideLabel           = new GUIContent("Outside Mask", "Materials used when Mask Interaction is set to Outside Mask.");
            SetMaterialButtonLabel              = new GUIContent("Set", "Prepares material references for switching to the corresponding Mask Interaction mode at runtime. Creates the required materials if they do not exist.");
            ClearMaterialButtonLabel            = new GUIContent("Clear", "Clears unused material references. Note: when switching to the corresponding Mask Interaction mode at runtime, a new material is generated on the fly.");
            DeleteMaterialButtonLabel           = new GUIContent("Delete", "Clears unused material references and deletes the corresponding assets. Note: when switching to the corresponding Mask Interaction mode at runtime, a new material is generated on the fly.");

            var so = this.serializedObject;
            skeletonDataAsset              = so.FindProperty("skeletonDataAsset");
            initialSkinName                = so.FindProperty("initialSkinName");
            initialFlipX                   = so.FindProperty("initialFlipX");
            initialFlipY                   = so.FindProperty("initialFlipY");
            normals                        = so.FindProperty("addNormals");
            tangents                       = so.FindProperty("calculateTangents");
            immutableTriangles             = so.FindProperty("immutableTriangles");
            pmaVertexColors                = so.FindProperty("pmaVertexColors");
            clearStateOnDisable            = so.FindProperty("clearStateOnDisable");
            tintBlack                      = so.FindProperty("tintBlack");
            updateWhenInvisible            = so.FindProperty("updateWhenInvisible");
            singleSubmesh                  = so.FindProperty("singleSubmesh");
            fixDrawOrder                   = so.FindProperty("fixDrawOrder");
            fixPrefabOverrideViaMeshFilter = so.FindProperty("fixPrefabOverrideViaMeshFilter");
            maskInteraction                = so.FindProperty("maskInteraction");
            maskMaterialsNone              = so.FindProperty("maskMaterials.materialsMaskDisabled");
            maskMaterialsInside            = so.FindProperty("maskMaterials.materialsInsideMask");
            maskMaterialsOutside           = so.FindProperty("maskMaterials.materialsOutsideMask");

            separatorSlotNames            = so.FindProperty("separatorSlotNames");
            separatorSlotNames.isExpanded = true;

            zSpacing = so.FindProperty("zSpacing");

            SerializedObject renderersSerializedObject = SpineInspectorUtility.GetRenderersSerializedObject(serializedObject);             // Allows proper multi-edit behavior.
            sortingProperties = new SpineInspectorUtility.SerializedSortingProperties(renderersSerializedObject);
        }
示例#32
0
        /// <summary>
        /// Sets up the drawer so that it is ready to be used.
        /// LateSetup should be called right after this.
        /// </summary>
        /// <param name="keyType"> They key type of the elements that can be added to the collection. </param>
        /// <param name="setMemberInfo"> LinkedMemberInfo for the field or property that these drawers represent. </param>
        /// <param name="setParent"> Drawer whose member these Drawer are. Can be null. </param>
        /// <param name="setLabel"> The label (name) of the field. Can be null. </param>
        /// <param name="setReadOnly"> True if Drawer should be read only. </param>
        public static CollectionAddFieldDrawer Create([NotNull] Type keyType, [CanBeNull] Func <object[], bool> validateKey, [CanBeNull] Action onAddButtonClicked, [CanBeNull] LinkedMemberInfo memberInfo, [CanBeNull] IParentDrawer parent, [CanBeNull] GUIContent label, bool setReadOnly)
        {
            CollectionAddFieldDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new CollectionAddFieldDrawer();
            }
            result.Setup(keyType, validateKey, onAddButtonClicked, memberInfo, parent, label, setReadOnly);
            result.LateSetup();
            return(result);
        }
示例#33
0
        private void DrawVector3(Rect position, SerializedProperty property, GUIContent label)
        {
            position = EditorGUI.PrefixLabel(position, label);

            float btnw = Mathf.Min(position.width, BTN_WIDTH);
            var   rbtn = new Rect(position.xMax - btnw, position.yMin, btnw, EditorGUIUtility.singleLineHeight);

            var v = property.vector3Value;

            if (v == Vector3.zero)
            {
                v = Vector3.forward;
                property.vector3Value = Vector3.forward;
            }

            Vector3Directions i = Vector3Directions.Configure;

            if (v == Vector3.up)
            {
                i = Vector3Directions.Up;
            }
            else if (v == Vector3.down)
            {
                i = Vector3Directions.Down;
            }
            else if (v == Vector3.right)
            {
                i = Vector3Directions.Right;
            }
            else if (v == Vector3.left)
            {
                i = Vector3Directions.Left;
            }
            else if (v == Vector3.forward)
            {
                i = Vector3Directions.Forward;
            }
            else if (v == Vector3.back)
            {
                i = Vector3Directions.Backward;
            }
            else
            {
                i = Vector3Directions.Configure;
            }

            EditorGUI.BeginChangeCheck();
            i = (Vector3Directions)EditorGUI.EnumPopup(rbtn, i);
            if (EditorGUI.EndChangeCheck())
            {
                switch (i)
                {
                case Vector3Directions.Up:
                    property.vector3Value = Vector3.up;
                    break;

                case Vector3Directions.Down:
                    property.vector3Value = Vector3.down;
                    break;

                case Vector3Directions.Right:
                    property.vector3Value = Vector3.right;
                    break;

                case Vector3Directions.Left:
                    property.vector3Value = Vector3.left;
                    break;

                case Vector3Directions.Forward:
                    property.vector3Value = Vector3.forward;
                    break;

                case Vector3Directions.Backward:
                    property.vector3Value = Vector3.back;
                    break;
                }
            }

            if (i < Vector3Directions.Configure)
            {
                float w  = (position.width - btnw) / 3f;
                var   r1 = new Rect(position.xMin, position.yMin, w, EditorGUIUtility.singleLineHeight);
                var   r2 = new Rect(r1.xMax, position.yMin, w, EditorGUIUtility.singleLineHeight);
                var   r3 = new Rect(r2.xMax, position.yMin, w, EditorGUIUtility.singleLineHeight);

                EditorGUI.LabelField(r1, "X: " + v.x.ToString("0.#######"));
                EditorGUI.LabelField(r2, "Y: " + v.y.ToString("0.#######"));
                EditorGUI.LabelField(r3, "Z: " + v.z.ToString("0.#######"));
            }
            else
            {
                //TODO - need way to make this work effectively
                var r = new Rect(position.xMin, position.yMin, position.width - btnw, EditorGUIUtility.singleLineHeight);
                EditorGUI.BeginChangeCheck();
                v = SPEditorGUI.DelayedVector3Field(r, GUIContent.none, v);
                if (EditorGUI.EndChangeCheck())
                {
                    property.vector3Value = v.normalized;
                }
            }
        }
示例#34
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return(property.isExpanded ? 18 * 3 : 16);
 }
        /// <summary>
        /// Draws the property.
        /// </summary>
		protected override void DrawPropertyLayout(GUIContent label)
        {
            GUIHelper.PushGUIEnabled(!Application.isPlaying && GUI.enabled);
            this.CallNextDrawer(label);
            GUIHelper.PopGUIEnabled();
        }
示例#36
0
 public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
 {
     // One line of  oxygen free code.
     property.intValue = EditorGUI.LayerField(position, label, property.intValue);
 }
示例#37
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return(base.GetPropertyHeight(property, label));
 }
示例#38
0
 /// <inheritdoc/>
 protected sealed override void Setup(object setValue, Type setValueType, LinkedMemberInfo setMemberInfo, IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
 {
     throw new NotSupportedException("Please use the Create method");
 }
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     InitTreeIfNeeded(property);
     return GetOrCreateViewData(property).TreeView.totalHeight;
 }
示例#40
0
 /// <summary>
 /// Sets up the drawer so that it is ready to be used.
 /// LateSetup should be called right after this.
 /// </summary>
 /// <param name="setKeyType"> The type of the key used in the dictionary. Can not be null. </param>
 /// <param name="setValidateKey"> Function used for validating the current key value set up in the add button. Can be null. </param>
 /// <param name="setOnAddButtonClicked"> Delegate called when the add button is clicked. Can be null. </param>
 /// <param name="setMemberInfo"> LinkedMemberInfo for the field or property that these drawers represent. </param>
 /// <param name="setParent"> Drawer whose member these Drawer are. Can not be null. </param>
 /// <param name="setLabel"> The label (name) of the field. Can be null. </param>
 /// <param name="setReadOnly"> True if Drawer should be read only. </param>
 private void Setup([NotNull] Type setKeyType, [CanBeNull] Func <object[], bool> setValidateKey, [CanBeNull] Action setOnAddButtonClicked, [CanBeNull] LinkedMemberInfo setMemberInfo, [NotNull] IParentDrawer setParent, GUIContent setLabel, bool setReadOnly)
 {
     keyType            = setKeyType;
     drawInSingleRow    = DrawerUtility.CanDrawMultipleControlsOfTypeInSingleRow(keyType);
     validateKey        = setValidateKey;
     onAddButtonClicked = setOnAddButtonClicked;
     base.Setup(keyType.DefaultValue(), keyType, setMemberInfo, setParent, setLabel, setReadOnly);
 }
示例#41
0
        //----- method -----

        public RegisterScrollView()
        {
            toolbarPlusIcon  = EditorGUIUtility.IconContent("Toolbar Plus");
            toolbarMinusIcon = EditorGUIUtility.IconContent("Toolbar Minus");
        }
        public void DrawDirectly(SerializedProperty property, CyberAttrribute cyberAttribute, GUIContent content, GUIStyle style, FieldInfo field)
        {
            MinMaxSliderAttribute atr = cyberAttribute as MinMaxSliderAttribute;

            EditorGUILayout.BeginHorizontal();
            TheEditor.DrawPrefix(content, field, style);
            float min, max;
            SerializedProperty pVect = null;

            if (property.propertyType == SerializedPropertyType.Generic)
            {
                pVect = property.FindPropertyRelative("val");

                min = pVect.vector2Value.x;
                max = pVect.vector2Value.y;
            }


            else if (property.propertyType == SerializedPropertyType.Vector2)
            {
                min = property.vector2Value.x;
                max = property.vector2Value.y;
            }
            else
            {
                min = property.vector2IntValue.x;
                max = property.vector2IntValue.y;
            }


            min = EditorGUILayout.FloatField(min, GUILayout.MinWidth(15), GUILayout.MaxWidth(70));
            EditorGUILayout.MinMaxSlider(ref min, ref max, atr.Min, atr.Max);
            max = EditorGUILayout.FloatField(max, GUILayout.MinWidth(15), GUILayout.MaxWidth(70));
            if (property.propertyType == SerializedPropertyType.Vector2)
            {
                property.vector2Value = new Vector2(min, max);
            }
            else if (property.propertyType == SerializedPropertyType.Vector2Int)
            {
                property.vector2IntValue = new Vector2Int((int)min, (int)max);
            }
            else if (property.propertyType == SerializedPropertyType.Generic)
            {
                pVect.vector2Value = new Vector2(min, max);
            }
            EditorGUILayout.EndHorizontal();
        }
示例#43
0
 public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
 {
     return(CommentStyle.CalcHeight(CommentAttribute.content, Screen.width - 19) + EditorGUIUtility.singleLineHeight);
 }
示例#44
0
        void OnGUI()
        {
            if (window == null)
            {
                Init();
            }

            float startX = 5;
            float startY = 5;
            float spaceX = 70;
            float spaceY = 18;
            float width  = 230;
            float height = 17;

            GUIStyle style = new GUIStyle("Label");

            style.fontSize  = 16;
            style.fontStyle = FontStyle.Bold;

            GUIContent cont = new GUIContent("Top-Down Shooter ToolKit (TDSTK)");

            EditorGUI.LabelField(new Rect(startX, startY, 340, 30), cont, style);

            EditorGUI.LabelField(new Rect(startX, startY + 8, 300, height), "__________________________________");

            startY += 30;
            EditorGUI.LabelField(new Rect(startX, startY, width, height), " - Version:");
            EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "1.2 f3");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Release:");
            EditorGUI.LabelField(new Rect(startX + spaceX, startY, width, height), "29 July 2016");

            startY += 15;

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), "Developed by K.Song Tan");

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Email:");
            EditorGUI.TextField(new Rect(startX + spaceX, startY, width, height), "*****@*****.**");
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Twitter:");
            EditorGUI.TextField(new Rect(startX + spaceX, startY, width, height), "SongTan@SongGameDev");

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Website:");
            EditorGUI.TextField(new Rect(startX + spaceX, startY, width, height), "http://www.songgamedev.com/");
            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, 50, height), "Open"))
            {
                Application.OpenURL("http://www.songgamedev.com");
            }

            EditorGUI.LabelField(new Rect(startX, startY += spaceY, width, height), " - Support:");
            EditorGUI.TextField(new Rect(startX + spaceX, startY, width, height), "http://forum.unity3d.com/threads/topdownshooter-toolkit");
            if (GUI.Button(new Rect(startX + spaceX + width + 10, startY, 50, height), "Open"))
            {
                Application.OpenURL("http://bit.ly/1NlxMJC");
            }

            startY += spaceY;
            EditorGUI.LabelField(new Rect(startX, startY += spaceY, 300, height), "        Your feedback are much appreciated!");
            if (GUI.Button(new Rect(startX, startY += spaceY, 300, height), "Please Rate TDSTK!"))
            {
                Application.OpenURL("http://bit.ly/1NDRqCM");
            }
        }
示例#45
0
        private static void DrawObjectFieldLargeThumb(Rect position, int id, Object obj, GUIContent content)
        {
            GUIStyle thumbStyle = EditorStyles.objectFieldThumb;

            thumbStyle.Draw(position, GUIContent.none, id, DragAndDrop.activeControlID == id, position.Contains(Event.current.mousePosition));

            if (obj != null && !showMixedValue)
            {
                bool isCubemap = obj is Cubemap;
                bool isSprite  = obj is Sprite;
                Rect thumbRect = thumbStyle.padding.Remove(position);

                if (isCubemap || isSprite)
                {
                    Texture2D t2d = AssetPreview.GetAssetPreview(obj);
                    if (t2d != null)
                    {
                        if (isSprite || t2d.alphaIsTransparency)
                        {
                            DrawTextureTransparent(thumbRect, t2d);
                        }
                        else
                        {
                            DrawPreviewTexture(thumbRect, t2d);
                        }
                    }
                    else
                    {
                        // Preview not loaded -> Draw icon
                        thumbRect.x += (thumbRect.width - content.image.width) / 2f;
                        thumbRect.y += (thumbRect.height - content.image.width) / 2f;
                        GUIStyle.none.Draw(thumbRect, content.image, false, false, false, false);

                        // Keep repaint until the object field has a proper preview
                        HandleUtility.Repaint();
                    }
                }
                else
                {
                    // Draw texture
                    Texture2D t2d = content.image as Texture2D;
                    if (t2d != null && t2d.alphaIsTransparency)
                    {
                        DrawTextureTransparent(thumbRect, t2d);
                    }
                    else
                    {
                        DrawPreviewTexture(thumbRect, content.image);
                    }
                }
            }
            else
            {
                GUIStyle s2 = thumbStyle.name + "Overlay";
                BeginHandleMixedValueContentColor();

                s2.Draw(position, content, id);
                EndHandleMixedValueContentColor();
            }
            GUIStyle s3 = thumbStyle.name + "Overlay2";

            s3.Draw(position, s_Select, id);
        }
示例#46
0
        private static void DrawObjectFieldMiniThumb(Rect position, int id, Object obj, GUIContent content)
        {
            GUIStyle thumbStyle = EditorStyles.objectFieldMiniThumb;

            position.width = EditorGUI.kObjectFieldMiniThumbnailWidth;
            BeginHandleMixedValueContentColor();
            bool hover    = obj != null; // we use hover texture for enhancing the border if we have a reference
            bool on       = DragAndDrop.activeControlID == id;
            bool keyFocus = GUIUtility.keyboardControl == id;

            thumbStyle.Draw(position, hover, false, on, keyFocus);
            EndHandleMixedValueContentColor();

            if (obj != null && !showMixedValue)
            {
                Rect      thumbRect = new Rect(position.x + 1, position.y + 1, position.height - 2, position.height - 2); // subtract 1 px border
                Texture2D t2d       = content.image as Texture2D;
                if (t2d != null && t2d.alphaIsTransparency)
                {
                    DrawTextureTransparent(thumbRect, t2d);
                }
                else
                {
                    DrawPreviewTexture(thumbRect, content.image);
                }

                // Tooltip
                if (thumbRect.Contains(Event.current.mousePosition))
                {
                    GUI.Label(thumbRect, GUIContent.Temp(string.Empty, "Ctrl + Click to show preview"));
                }
            }
        }
示例#47
0
 public static void Label(GUIContent label, params GUILayoutOption[] options)
 {
     Label(label, null, options);
 }
示例#48
0
 public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
 {
     return(6 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing);
 }
示例#49
0
 public void ShowNotification(GUIContent content, float timeout)
 {
     notificationClearTime = timeout < DefaultNotificationTimeout ? EditorApplication.timeSinceStartup + timeout : -1f;
     base.ShowNotification(content);
 }
示例#50
0
 public static bool Button(GUIContent label, params GUILayoutOption[] options)
 {
     return(Button(label, null, options));
 }
示例#51
0
        private void MaybeUpdateData()
        {
            if (firstOnGUI)
            {
                titleContent = new GUIContent(Title, Styles.SmallLogo);
            }
            firstOnGUI = false;

            if (HasRepository && !string.IsNullOrEmpty(Repository.CloneUrl))
            {
                var host = Repository.CloneUrl
                                     .ToRepositoryUri()
                                     .GetComponents(UriComponents.Host, UriFormat.SafeUnescaped);

                connections = Platform.Keychain.Connections.OrderByDescending(x => x.Host == host).ToArray();
            }
            else
            {
                connections = Platform.Keychain.Connections.OrderByDescending(HostAddress.IsGitHubDotCom).ToArray();
            }

            var connectionCount = connections.Length;
            if (connectionCount > 1)
            {
                var connection = connections.First();
                var isGitHubDotCom = HostAddress.IsGitHubDotCom(connection);

                if (isGitHubDotCom)
                {
                    primaryConnectionUsername = "******" + connection.Username;
                }
                else
                {
                    primaryConnectionUsername = connection.Host + ": " + connection.Username;
                }
            }
            else if(connectionCount == 1)
            {
                primaryConnectionUsername = connections.First().Username;
            }
            else
            {
                primaryConnectionUsername = null;
            }


            if (repositoryProgressHasUpdate)
            {
                if (repositoryProgress != null)
                {
                    repositoryProgressMessage = repositoryProgress.Message;
                    repositoryProgressValue = repositoryProgress.Percentage;
                    if (progressMessageClearTime == -1f || progressMessageClearTime < EditorApplication.timeSinceStartup + DefaultNotificationTimeout)
                        progressMessageClearTime = EditorApplication.timeSinceStartup + DefaultNotificationTimeout;
                }
                else
                {
                    repositoryProgressMessage = "";
                    repositoryProgressValue = 0;
                    progressMessageClearTime = -1f;
                }
                repositoryProgressHasUpdate = false;
            }

            if (appManagerProgressHasUpdate)
            {
                if (appManagerProgress != null)
                {
                    appManagerProgressValue = appManagerProgress.Percentage;
                    appManagerProgressMessage = appManagerProgress.Message;
                }
                else
                {
                    appManagerProgressValue = 0;
                    appManagerProgressMessage = "";
                }
                appManagerProgressHasUpdate = false;
            }

            string updatedRepoRemote = null;
            string updatedRepoUrl = Localization.DefaultRepoUrl;

            var shouldUpdateContentFields = false;

            if (currentTrackingStatusHasUpdate)
            {
                currentTrackingStatusHasUpdate = false;
                statusAhead = Repository.CurrentAhead;
                statusBehind = Repository.CurrentBehind;
            }

            if (currentStatusEntriesHasUpdate)
            {
                currentStatusEntriesHasUpdate = false;
                var currentChanges = Repository.CurrentChanges;
                hasItemsToCommit = currentChanges != null &&
                    currentChanges.Any(entry => entry.Status != GitFileStatus.Ignored && !entry.Staged);
            }

            if (currentBranchAndRemoteHasUpdate)
            {
                hasRemote = false;
            }

            if (Repository != null)
            {
                if (currentBranch == null || currentRemoteName == null || currentBranchAndRemoteHasUpdate)
                {
                    currentBranchAndRemoteHasUpdate = false;

                    var repositoryCurrentBranch = Repository.CurrentBranch;
                    string updatedRepoBranch;
                    if (repositoryCurrentBranch.HasValue)
                    {
                        updatedRepoBranch = repositoryCurrentBranch.Value.Name;
                        isTrackingRemoteBranch = !string.IsNullOrEmpty(repositoryCurrentBranch.Value.Tracking);
                    }
                    else
                    {
                        updatedRepoBranch = null;
                        isTrackingRemoteBranch = false;
                    }

                    var repositoryCurrentRemote = Repository.CurrentRemote;
                    if (repositoryCurrentRemote.HasValue)
                    {
                        hasRemote = true;
                        updatedRepoRemote = repositoryCurrentRemote.Value.Name;
                        if (!string.IsNullOrEmpty(repositoryCurrentRemote.Value.Url))
                        {
                            updatedRepoUrl = repositoryCurrentRemote.Value.Url;
                        }
                    }

                    if (currentRemoteName != updatedRepoRemote)
                    {
                        currentRemoteName = updatedRepoRemote;
                        shouldUpdateContentFields = true;
                    }

                    if (currentBranch != updatedRepoBranch)
                    {
                        currentBranch = updatedRepoBranch;
                        shouldUpdateContentFields = true;
                    }

                    if (currentRemoteUrl != updatedRepoUrl)
                    {
                        currentRemoteUrl = updatedRepoUrl;
                        shouldUpdateContentFields = true;
                    }
                }
            }
            else
            {
                isTrackingRemoteBranch = false;

                if (currentRemoteName != null)
                {
                    currentRemoteName = null;
                    shouldUpdateContentFields = true;
                }

                if (currentBranch != null)
                {
                    currentBranch = null;
                    shouldUpdateContentFields = true;
                }

                if (currentRemoteUrl != Localization.DefaultRepoUrl)
                {
                    currentRemoteUrl = Localization.DefaultRepoUrl;
                    shouldUpdateContentFields = true;
                }
            }

            if (shouldUpdateContentFields || currentBranchContent == null || currentRemoteUrlContent == null)
            {
                currentBranchContent = new GUIContent(currentBranch, Localization.Window_RepoBranchTooltip);

                if (currentRemoteName != null)
                {
                    currentRemoteUrlContent = new GUIContent(currentRemoteUrl, string.Format(Localization.Window_RepoUrlTooltip, currentRemoteName));
                }
                else
                {
                    currentRemoteUrlContent = new GUIContent(currentRemoteUrl, Localization.Window_RepoNoUrlTooltip);
                }
            }
        }
示例#52
0
 public new void ShowNotification(GUIContent content)
 {
     ShowNotification(content, DefaultNotificationTimeout);
 }
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     FindMembers(property);
     return(membersToDraw?.Count * EditorGUIUtility.singleLineHeight ?? 0);
 }
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent _)
    {
        if (membersToDraw == null)
        {
            return;
        }

        if (error != null)
        {
            EditorGUI.HelpBox(position, error, MessageType.Error);
            return;
        }

        // var debugText = string.Join(", ", membersToDraw.Select(m => m.Name));

        var instance = property.serializedObject.targetObject;

        using (new EditorGUI.DisabledScope(true))
        {
            for (var index = 0; index < membersToDraw.Count; index++)
            {
                var mem  = membersToDraw[index];
                var rect = new Rect(position.x, position.y + EditorGUIUtility.singleLineHeight * index, position.width, EditorGUIUtility.singleLineHeight);

                var prefix = mem.Name;
                prefix = ObjectNames.NicifyVariableName(prefix);

                GUI.Label(rect, new GUIContent(prefix));
                rect = EditorGUI.PrefixLabel(rect, new GUIContent(prefix));

                GUIContent?label = null;

                // first check cache if previous access did cause exception
                if (guiContentCache.Count > index)
                {
                    if (guiContentCache[index].wasError)
                    {
                        // previous access did cause exception
                        // so dont call GetValue again to avoid internal exception spam
                        // this CAN happen e.g in edit time when reading a property getter
                        // that expects a certain setup
                        label = guiContentCache[index].label;
                    }
                }

                if (label == null)
                {
                    try
                    {
                        label = new GUIContent(GetValue(instance, mem)?.ToString() ?? "null");
                        // put in cache so we can lookup by index, every member should have one label in the cache at least
                        if (index >= guiContentCache.Count)
                        {
                            guiContentCache.Add((label, false));
                        }
                    }
                    catch (Exception e)
                    {
                        // cache that exception the first time it happens
                        if (index >= guiContentCache.Count)
                        {
                            var errorLabel = label = new GUIContent(e.GetType().Name, e.ToString());
                            guiContentCache.Add((errorLabel, true));
                        }
                        else
                        {
                            label = guiContentCache[index].label;
                        }
                    }
                }

                GUI.Label(rect, label);
            }
        }
    }
示例#55
0
 public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
 {
     return(EditorGUIUtility.singleLineHeight);
 }
示例#56
0
        protected override void DrawWindowContents(int windowID)
        {
            GUILayout.BeginVertical( );

            if (_filter.CurrentSituation != null && _parent.Science.CurrentVesselScience != null)
            {
                var desc = _filter.CurrentSituation.Description;
                GUILayout.Box
                (
                    new GUIContent
                    (
                        char.ToUpper(desc[0]) + desc.Substring(1),
                        MakeSituationToolTip( )
                    ),
                    _situationStyle,
                    GUILayout.Width(wScale(250))
                );
            }
            int Top = wScale(65);

            if (_filter.DisplayScienceInstances != null)
            {
                for (var i = 0; i < _filter.DisplayScienceInstances.Count; i++)
                {
                    var rect       = new Rect(wScale(5), Top, wScale(250), wScale(30));
                    var experiment = _filter.DisplayScienceInstances[i];
                    DrawExperiment(experiment, rect);
                    Top += wScale(35);
                }
            }
            else
            {
                _logger.Trace("DisplayExperiments is null");
            }



            if (_filter.DisplayScienceInstances.Count > 0)
            {
                GUILayout.Space(wScale(_filter.DisplayScienceInstances.Count * 35));                     // Leave space for experiments, as drawn above
            }
            GUILayout.Space(wScale(10));

            GUILayout.BeginHorizontal( );
            GUIContent Content = null;

            if (_parent.Config.StopTimeWarp)
            {
                Content = new GUIContent(_GfxTimeWarp, Localizer.Format("#autoLOC_[x]_Science!_131") /*Time warp will be stopped*/);
            }
            else
            {
                Content = new GUIContent(_GfxTimeWarpOff, Localizer.Format("#autoLOC_[x]_Science!_132") /*Time warp will not be stopped*/);
            }
            if (GUILayout.Button(Content, GUILayout.Width(wScale(36)), GUILayout.Height(wScale(32))))
            {
                _parent.Config.StopTimeWarp = !_parent.Config.StopTimeWarp;
                _parent.Config.Save( );
            }



            if (_parent.Config.PlayNoise)
            {
                Content = new GUIContent(_GfxAudioAlert, Localizer.Format("#autoLOC_[x]_Science!_133") /*Audio alert will sound*/);
            }
            else
            {
                Content = new GUIContent(_GfxAudioAlertOff, Localizer.Format("#autoLOC_[x]_Science!_134") /*No audio alert*/);
            }
            if (GUILayout.Button(Content, GUILayout.Width(wScale(36)), GUILayout.Height(wScale(32))))
            {
                _parent.Config.PlayNoise = !_parent.Config.PlayNoise;
                _parent.Config.Save( );
            }



            if (_parent.Config.ShowResultsWindow)
            {
                Content = new GUIContent(_GfxResultsWindow, Localizer.Format("#autoLOC_[x]_Science!_135") /*Show results window*/);
            }
            else
            {
                Content = new GUIContent(_GfxResultsWindowOff, Localizer.Format("#autoLOC_[x]_Science!_136") /*Supress results window*/);
            }
            if (GUILayout.Button(Content, GUILayout.Width(wScale(36)), GUILayout.Height(wScale(32))))
            {
                _parent.Config.ShowResultsWindow = !_parent.Config.ShowResultsWindow;
                _parent.Config.Save( );
            }
            GUILayout.EndHorizontal( );
            GUILayout.EndVertical( );

            GUILayout.Space(wScale(2));
        }
示例#57
0
 /// <summary>
 ///
 /// </summary>
 public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
 {
     return(0);
 }
示例#58
0
 public ConfirmationWindow(float x, float y, float width, float height)
 {
     m_content = new GUIContent(GUIContent.none);
     m_area    = new Rect(x, y, width, height);
 }
示例#59
0
 static void AppendSupport(StringBuilder builder, SerializedProperty property, GUIContent content)
 {
     if (property.hasMultipleDifferentValues)
     {
         builder.AppendLine().AppendFormat(supportedFormaterMultipleValue, content.text);
     }
     else if (property.boolValue)
     {
         builder.AppendLine().AppendFormat(supportedFormater, content.text, k_SupportDrawbacks[content]);
     }
 }
        protected override void DrawPropertyLayout(GUIContent label)
        {
            if (!(ValueEntry.ValueState == PropertyValueState.NullReference ||
                  ValueEntry.ValueState == PropertyValueState.ReferenceValueConflict))
            {
                CallNextDrawer(label);
                return;
            }

            if (Event.current.type == EventType.Layout)
            {
                isBroken = false;
                var count = ValueEntry.ValueCount;
                for (var i = 0; i < count; i++)
                {
                    var component = ValueEntry.Values[i];

                    if (ComponentIsBroken(component, ref realWrapperInstance))
                    {
                        isBroken = true;
                        break;
                    }
                }

                if (isBroken && autoFix)
                {
                    isBroken = false;

                    for (var i = 0; i < ValueEntry.ValueCount; i++)
                    {
                        T fixedComponent = null;
                        if (ComponentIsBroken(ValueEntry.Values[i], ref fixedComponent) && fixedComponent)
                        {
                            (ValueEntry as IValueEntryActualValueSetter <T>).SetActualValue(i, fixedComponent);
                        }
                    }

                    ValueEntry.Update();
                }
            }

            if (!isBroken)
            {
                CallNextDrawer(label);
                return;
            }

            var rect        = EditorGUILayout.GetControlRect(label != null);
            var btnRect     = rect.AlignRight(20);
            var controlRect = rect.SetXMax(btnRect.xMin - 5);

            object newInstance = null;

            EditorGUI.BeginChangeCheck();
            {
                if (ValueEntry.BaseValueType.IsInterface)
                {
                    newInstance = SirenixEditorFields.PolymorphicObjectField(controlRect,
                                                                             label,
                                                                             realWrapperInstance,
                                                                             ValueEntry.BaseValueType,
                                                                             allowSceneViewObjects);
                }
                else
                {
                    newInstance = SirenixEditorFields.UnityObjectField(
                        controlRect,
                        label,
                        realWrapperInstance,
                        ValueEntry.BaseValueType,
                        allowSceneViewObjects) as Component;
                }
            }
            if (EditorGUI.EndChangeCheck())
            {
                ValueEntry.WeakSmartValue = newInstance;
            }

            if (GUI.Button(btnRect, " ", EditorStyles.miniButton))
            {
                var popup = new FixBrokenUnityObjectWrapperPopup(ValueEntry);
                OdinEditorWindow.InspectObjectInDropDown(popup, 300);
            }

            if (Event.current.type == EventType.Repaint)
            {
                GUI.DrawTexture(btnRect, EditorIcons.ConsoleWarnicon, ScaleMode.ScaleToFit);
            }
        }