Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

I cannot set a script to a public value

Discussion in 'Editor & General Support' started by noatom, Apr 10, 2014.

  1. noatom

    noatom

    Joined:
    Apr 9, 2014
    Posts:
    21
    To make it more clear, here is some code:

    public class WeaponScript : MonoBehaviour
    {

    public Transform shotPrefab;
    ..............................................

    I basically see this in the inspector, but my shot prefab field is empty: http://pixelnest.io/tutorials/2d-game-unity/shooting-1/-img/dnd_prefab.png

    I'm supposed to select a script from my Prefabs folder in the Project, but when I select the field and go to Assets, the windows is empty!
     
    Last edited: Apr 10, 2014
  2. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    It is not empty! You already assigned it!
     
  3. noatom

    noatom

    Joined:
    Apr 9, 2014
    Posts:
    21
    That image is how it should look like, its not a screenshot of mine. Mine simply is empty.
     
  4. DanielQuick

    DanielQuick

    Joined:
    Dec 31, 2010
    Posts:
    3,137
    You can either lock the inspector or drag the prefab to the slot without deselecting the player object.
     
  5. noatom

    noatom

    Joined:
    Apr 9, 2014
    Posts:
    21
    the player is selected, when i drag the prefab the block sign appears
    and with the inspector locked, when i draw the prefab, the block sign appears again

    Fixed it with a restart, now it works.
     
    Last edited: Apr 10, 2014
  6. Dantus

    Dantus

    Joined:
    Oct 21, 2009
    Posts:
    5,667
    Could you show us a screenshot of your screen?