Search Unity

Convert interface to GameObject?

Discussion in 'Scripting' started by FeastSC2, Nov 10, 2018.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    534
    I would like for debugging purposes to have the names of the monobehaviours on which I set an interface.
    But it won't let me cast an interface to a gameobject. Why is that?

    Code (CSharp):
    1.             var go = (GameObject)_iPausable;
    2.             Debug.LogError(go.name + " has a problem!");
     
  2. GroZZleR

    GroZZleR

    Joined:
    Feb 1, 2015
    Posts:
    1,867
    Your scripts and components aren't GameObjects. They're MonoBehaviours.
     
    FeastSC2 likes this.