Adds "Move to Top" and "Move to Bottom" items to the inspector context menu of components.
✓ Published0🌍 Public
FFrozenfire92
Last edited Aug 4, 2015
Created on Aug 4, 2015
This example adds “Move to Top” and “Move to Bottom” commands to Unity’s inspector context menu for any Component. It shows how editor scripting can reorder components on a GameObject using SerializedObject and SerializedProperty, specifically via the `m_Component` array and the `MoveArrayElement` method. The code locates the target component by iterating over array elements and comparing object references, then applies the modification with `ApplyModifiedProperties`. It relies on UnityEditor’s MenuItem attribute to attach the commands to the Component context menu.
AI-generated description