Esempio n. 1
0
    static void DrawObjectNote(Transform transform, GizmoType gizmoType, bool selected)
    {
        ObjectNote ognote = transform.GetComponent <ObjectNoteInGame>();
        ObjectNote onote  = transform.GetComponent <ObjectNote>();

        if (onote != null && ognote == null && onote.enabled)
        {
            if (onote.Style == null || onote.Size.x == 0f)
            {
                onote.SetStyle();
            }

            if ((selected && onote.ShowWhenSelected) || (!selected && onote.ShowWhenUnselected))
            {
                Handles.BeginGUI();
                GUI.backgroundColor = onote.Color;
                Vector2 guiPosition = HandleUtility.WorldToGUIPoint(transform.position - onote.AnchorOffset);
                if (!string.IsNullOrEmpty(onote.NoteText))
                {
                    GUI.Label(new Rect(guiPosition.x, guiPosition.y, onote.Size.x, onote.Size.y), onote.NoteText, onote.Style);
                }
                guiPosition         = HandleUtility.WorldToGUIPoint(transform.position);
                GUI.backgroundColor = Color.white;
                if (onote.Image != null)
                {
                    GUI.Label(new Rect(guiPosition.x - onote.Image.width * onote.ImageScale.x / 2 + onote.ImageOffset.x, guiPosition.y - 38f - onote.Image.height * onote.ImageScale.y / 2 + onote.ImageOffset.y, onote.Image.width * onote.ImageScale.x, onote.Image.height * onote.ImageScale.y), "", onote.ImgStyle);
                }
                Handles.EndGUI();
            }
        }
    }
Esempio n. 2
0
 public void OnEnable()
 {
     note = (ObjectNote)target;
     if (note.IsNew)
     {
         note.Text = target.name;
         int comps = note.gameObject.GetComponents <Component>().Length;
         for (int i = 0; i < comps; i++)
         {
             UnityEditorInternal.ComponentUtility.MoveComponentUp(note);
         }
         note.IsNew = false;
     }
 }
Esempio n. 3
0
    static void DrawObjectNote(Transform transform, GizmoType gizmoType, bool selected)
    {
        ObjectNote onote = transform.GetComponent <ObjectNote>();

        if (onote != null)
        {
            if (onote.Style == null)
            {
                onote.SetStyle();
            }

            if ((selected && onote.ShowWhenSelected) || (!selected && onote.ShowWhenUnselected))
            {
                float dist = HandleUtility.GetHandleSize(transform.position);
                GUI.backgroundColor = onote.Color;
                Handles.Label(transform.position + new Vector3(0f, -onote.Offset * dist, 0f), onote.Text, onote.Style);
            }
        }
    }