Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug ContextMenuItem on array field add command to the element but not the property itself

Discussion in 'Editor & General Support' started by Thaina, Dec 26, 2021.

  1. Thaina

    Thaina

    Joined:
    Jul 13, 2012
    Posts:
    1,137
    Create this script

    Code (CSharp):
    1.  
    2. using UnityEngine;
    3.  
    4. public class TestArrayContext : MonoBehaviour
    5. {
    6.     [SerializeField]
    7.     [ContextMenuItem("ResetText","ResetText")]
    8.     string[] textList;
    9.  
    10.     public void ResetText()
    11.     {
    12.         textList = new[] { "0","1","2","3" };
    13.     }
    14. }
    15.  
    Try to use it

    upload_2021-12-26_12-45-20.png

    I expect that the ContextMenuItem would always have that command when I right click on the name of that thing, not just the element of it. This should be considered as a bug

    Especially when the list is empty, right clicking on the empty panel don't have any context menu at all