Search Unity

Get monobehaviour variable from prefab

Discussion in 'Scripting' started by qqqbbb, Apr 4, 2019.

  1. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    113
    I have some prefabs (not referenced in any script) in Assets folder. How can I get monobehaviour variable from them in editor script?
     
    Last edited: Apr 4, 2019
  2. WarmedxMints

    WarmedxMints

    Joined:
    Feb 6, 2017
    Posts:
    1,035
    If you just want data holders, use a scriptable object instead of a prefab/gameobject. Other than that, you can reference the prefabs and just get the component as you normally would or you could load them from resources and get the data that way.

    Why do you need data from an object which isn't being used in the scene?
     
  3. qqqbbb

    qqqbbb

    Joined:
    Jan 13, 2016
    Posts:
    113
    I'm writing custom inspector and I need some data from prefabs.