コード例 #1
0
	public override void OnGUI( Rect position )
	{
		InspectorNoteAttribute note = attribute as InspectorNoteAttribute:

		// our header is always present
		Rect posLabel = position:
		posLabel.y += 13:
		posLabel.x -= 2:
		posLabel.height += 13:
		EditorGUI.LabelField(posLabel, note.header, EditorStyles.whiteLargeLabel):

		// do we have a message too?
		if (!string.IsNullOrEmpty(note.message))
		{
			Color color = GUI.color:
			Color faded = color:
			faded.a = 0.6f:

			Rect posExplain = posLabel:
			posExplain.y += 15:
			GUI.color = faded:
			EditorGUI.LabelField(posExplain, note.message, EditorStyles.whiteMiniLabel):
			GUI.color = color:
		}

		Rect posLine = position:
		posLine.y += string.IsNullOrEmpty(note.message) ? 30 : 42:
		posLine.height = 1f:
		GUI.Box(posLine, ""):
	}
コード例 #2
0
ファイル: DrawerInspectorNote.cs プロジェクト: boadle/CCTV-VR
    public override void OnGUI(Rect position)
    {
        InspectorNoteAttribute note = attribute as InspectorNoteAttribute;

        // our header is always present
        Rect posLabel = position;

        posLabel.y      += 13;
        posLabel.x      -= 2;
        posLabel.height += 13;
        EditorGUI.LabelField(posLabel, note.header, EditorStyles.whiteLargeLabel);

        // do we have a message too?
        if (!string.IsNullOrEmpty(note.message))
        {
            Color color = GUI.color;
            Color faded = color;
            faded.a = 0.6f;

            Rect posExplain = posLabel;
            posExplain.y += 15;
            GUI.color     = faded;
            EditorGUI.LabelField(posExplain, note.message, EditorStyles.whiteMiniLabel);
            GUI.color = color;
        }

        Rect posLine = position;

        posLine.y     += string.IsNullOrEmpty(note.message) ? 30 : 42;
        posLine.height = 1f;
        GUI.Box(posLine, "");
    }
コード例 #3
0
    /// <summary>
    /// Draw our editor
    /// </summary>
    /// <param name="position"></param>
    /// <param name="property"></param>
    /// <param name="label"></param>
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        InspectorNoteAttribute note = attribute as InspectorNoteAttribute;

        var isBool = property.type == "bool";

        Color color = GUI.color;
        Color faded = note.color;

        GUI.color = faded;

        // our header is always present
        Rect posLabel = position;

        posLabel.y      += 13;
        posLabel.x      += 2;
        posLabel.height += 13;
        EditorGUI.LabelField(posLabel, note.header, EditorStyles.whiteLargeLabel);

        if (!isBool)
        {
            var height = string.IsNullOrEmpty(note.message) ? 38f : 50f;

            var labelHeight = EditorGUI.GetPropertyHeight(property, label, false);

            var propPos = new Rect(position);
            propPos.y += height - labelHeight;

            EditorGUI.PropertyField(propPos, property, GUIContent.none, true);
        }

        GUI.color = color;
        // do we have a message too?
        if (!string.IsNullOrEmpty(note.message))
        {
            Rect posExplain = posLabel;
            posExplain.y += 15;
            GUI.color     = faded;
            EditorGUI.LabelField(posExplain, note.message, EditorStyles.whiteMiniLabel);
            GUI.color = color;
        }

        Rect posLine = position;

        posLine.y += string.IsNullOrEmpty(note.message) ? 34 : 45;
        //posLine.x += 15;;
        posLine.height = 2;

        GUI.Box(posLine, "");

        GUI.color  = Color.black;
        posLine.y += 2;
        GUI.Box(posLine, "");
        GUI.color = color;
    }
コード例 #4
0
        public override float GetHeight()
        {
            EditorSettings         editorResource     = EditorSingleton.Get <EditorSettings>();
            GUISkin                inspectorNoteStyle = editorResource.inspectorNoteSkin;
            InspectorNoteAttribute noteAttribute      = attribute as InspectorNoteAttribute;

            float headerHeight = inspectorNoteStyle.customStyles[0].CalcHeight(new GUIContent(noteAttribute.header), EditorGUIUtility.currentViewWidth - 33f) +
                                 inspectorNoteStyle.customStyles[0].fontSize;
            float messageHeight = inspectorNoteStyle.customStyles[1].CalcHeight(new GUIContent(noteAttribute.message), EditorGUIUtility.currentViewWidth - 33f) +
                                  inspectorNoteStyle.customStyles[1].fontSize;

            return((string.IsNullOrEmpty(noteAttribute.message) ? 0 : 0 + messageHeight) + headerHeight);
        }
コード例 #5
0
    /// <summary>
    /// Override height in case of error
    /// </summary>
    /// <param name="prop"></param>
    /// <param name="label"></param>
    /// <returns></returns>
    public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
    {
        InspectorNoteAttribute note = attribute as InspectorNoteAttribute;

        var height = string.IsNullOrEmpty(note.message) ? 38f : 50f;

        if (property.isExpanded)
        {
            height += EditorGUI.GetPropertyHeight(property, GUIContent.none, true);
            height -= EditorGUI.GetPropertyHeight(property, label, false);
        }

        return(height);
    }
コード例 #6
0
        public override void OnGUI(Rect position)
        {
            EditorSettings         editorResource     = EditorSingleton.Get <EditorSettings>();
            GUISkin                inspectorNoteStyle = editorResource.inspectorNoteSkin;
            InspectorNoteAttribute noteAttribute      = attribute as InspectorNoteAttribute;

            // Background box
            Rect backgroundBoxPos = position;

            backgroundBoxPos.height -= 5f;
            backgroundBoxPos.y      += 5f;
            GUI.Box(backgroundBoxPos, "", inspectorNoteStyle.customStyles[2]);

            float headerHeight = inspectorNoteStyle.customStyles[0].CalcHeight(new GUIContent(noteAttribute.header), position.width);
            //float messageHeight = inspectorNoteStyle.customStyles[1].CalcHeight(new GUIContent(note.Message), position.width); // not used

            // our header is always present
            Rect posLabel = position;

            posLabel.y      += 13;
            posLabel.x      += 5f;
            posLabel.height += 13;
            EditorGUI.LabelField(posLabel, noteAttribute.header, inspectorNoteStyle.customStyles[0]);

            // do we have a message too?
            if (!string.IsNullOrEmpty(noteAttribute.message))
            {
                //Color color = GUI.color;
                //Color faded = color;
                //faded.a = 0.5f;

                Rect posExplain = posLabel;
                posExplain.y     += headerHeight;
                posExplain.width -= 13f;

                //GUI.color = faded;
                EditorGUI.LabelField(posExplain, noteAttribute.message, inspectorNoteStyle.customStyles[1]);
                //GUI.color = color;
            }

            //Rect posLine = position;
            //posLine.y += (string.IsNullOrEmpty(note.message) ? 17 : 17 + messageHeight) + headerHeight;
            //posLine.x += 0;
            //posLine.height = 2;
            //GUI.Box(posLine, "");

            // Draw the field
            base.OnGUI(position);
        }
コード例 #7
0
ファイル: DrawerInspectorNote.cs プロジェクト: boadle/CCTV-VR
    public override float GetHeight()
    {
        InspectorNoteAttribute note = attribute as InspectorNoteAttribute;

        return(string.IsNullOrEmpty(note.message) ? 38 : 50);
    }