Search Unity

Selection.activeObject to Selection.objects changes MonoBehaviours into GameObjects?

Discussion in 'Immediate Mode GUI (IMGUI)' started by junglemason, Jun 30, 2017.

  1. junglemason

    junglemason

    Joined:
    Dec 30, 2010
    Posts:
    69
    I'm selecting a MonoBehaviour instance by assigning it to Selection.activeObject...

    Code (CSharp):
    1. Selection.activeObject = someBehaviourInstance;
    Later on I add another instance of that MonoBehaviour to Selection.objects...

    Code (CSharp):
    1. List<Object> selectedObjects = new List<Object>(Selection.objects);
    2. selectedObjects.Add(someOtherBehaviourInstance);
    3. Selection.objects = selectedObjects.ToArray();
    ...and now the Editor says that I have selected 1 MonoBehaviour and 1 GameObject (same if I read Selection.objects). MonoBehaviour inherits from Object, so I don't see a reason to change into a GameObject. Is it a bug, or am I doing something wrong? (Unity 5.6.2f1)