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

        if (onote != 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 - 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 = (ObjectNoteInGame)target;
     if (note != null && note.IsNew)
     {
         note.NoteText = target.name;
         int comps = note.gameObject.GetComponents <Component>().Length;
         for (int i = 0; i < comps; i++)
         {
             UnityEditorInternal.ComponentUtility.MoveComponentUp(note);
         }
         note.IsNew = false;
     }
 }