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. Dismiss Notice

Default references will be applied in edit mode

Discussion in 'Scripting' started by max4112, Apr 2, 2017.

  1. max4112

    max4112

    Joined:
    Apr 2, 2017
    Posts:
    1
    There is this problem in all my projects. How to fix it?
     
    SuleimanAbdullah likes this.
  2. Vectorbox

    Vectorbox

    Joined:
    Jan 27, 2014
    Posts:
    232
    Do you have the parent gameobject (in the hierarchy pane) selected or the script itself (in the project pane) ?
     
    Last edited: Apr 2, 2017
  3. TayyabShaheen

    TayyabShaheen

    Joined:
    Jul 8, 2017
    Posts:
    4
    same problem and I have the script selected
     
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    It's not a problem. You don't normally set references on the script. Instead set them on the GameObject the script is attached too.
     
  5. TayyabShaheen

    TayyabShaheen

    Joined:
    Jul 8, 2017
    Posts:
    4
    But there still seems to be a problem so if you could tell me how to fix this it would be very helpful
     
  6. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    I'm not psychic. You need to tell me what the problem is before I can solve it.
     
    sankeeth and mateofon79 like this.
  7. TayyabShaheen

    TayyabShaheen

    Joined:
    Jul 8, 2017
    Posts:
    4
    So I am a complete noob when it comes to unity.I was watching this tutorial of an endless runner game on youtube(gamesplusjames).I finished making the game and everything worked fine.But then stupidly I tried to make a character select screen and I deleted the player that the game was being played with to make new ones.I made new characters and followed the steps again but now my player is completely messed up.The playe is now jumping even when hes not on the ground even tho groundcheck is in place.Player is also not collecting coins.I deleted everything related to the character select thing but its still not working.Any help would be appreciated.I am dyinga,ahhhh.
     
  8. TayyabShaheen

    TayyabShaheen

    Joined:
    Jul 8, 2017
    Posts:
    4
    Someone help please
     
  9. SirLogray

    SirLogray

    Joined:
    Mar 31, 2016
    Posts:
    1
    The Inspector exposes these public fields two places: the script's Inspector page AND the GameObject's Inspector page.
    SELECT the GameObject that you want to assign to in the Hierarchy and then drag your Prefab to the field exposed in the Inspector.
     
    Flasterblat and mclaze like this.
  10. Sang496

    Sang496

    Joined:
    Jan 3, 2019
    Posts:
    1
    It happened to me aslo.You can try not to change the references in Script,instead changing on object. Add component Script (C# or java) on your object, and see what will happen .then try to change it in object`s Inspector .
     
    ZaKAmiar likes this.
  11. mateofon79

    mateofon79

    Joined:
    May 26, 2019
    Posts:
    1
    93/5000
    I have two scripts and it says there is an instantiation error, this GridSpace and GameController
     
  12. developersohaib0011

    developersohaib0011

    Joined:
    Mar 29, 2019
    Posts:
    2
    you need to select your Game_object in Hierarchy than drag the script in this Game_Object your problem will be solve
     

    Attached Files:

    • solution.JPG
      solution.JPG
      File size:
      62.4 KB
      Views:
      2,723
    • 2.JPG
      2.JPG
      File size:
      69.8 KB
      Views:
      2,737
    • 3.JPG
      3.JPG
      File size:
      35.4 KB
      Views:
      2,347
    Samgatt and rlf_unique like this.
  13. Deleted User

    Deleted User

    Guest

    Hi, I'm using Unity 5.6 and need to set references to shaders on scripts, as those scripts use them as 'caches'.

    Is it possible to disable this to allow the script to reference the shaders? Thanks in advance!
     
  14. kingstone426

    kingstone426

    Joined:
    Jun 21, 2013
    Posts:
    43
    I am also curious if it is possible to access script-references in play mode.

    In my case, I have a custom EditorWindow that references a .guiskin-file in the project. Because EditorWindows are not in the Hierarchy (or instantiated from prefabs) there is no obvious GameObject where I can set the reference.

    Setting the .guiskin-file reference on the script directly works if I open the window while in edit mode, but if I try to open the window in play mode I get a null reference for the guiskin.
     
  15. SUfIaNAHMAD_

    SUfIaNAHMAD_

    Joined:
    Jun 19, 2019
    Posts:
    18
    I have a problem!! That If I use simply a scrip and reference it prefab it works nearly perfect but whenever i tries to add same scrip on prefeb as a reference it hang up and dont let it done....... More over i am still not clear about Default reference will be applied only in edit mode?? Is it mean that whenever i will play,, this will erase the reference.... I am done i can't visualize more plzz if you have stamina so help me out plzzzzzzzzzzzzzzzzzzz
     
  16. ZaKAmiar

    ZaKAmiar

    Joined:
    Apr 24, 2020
    Posts:
    3
    Thanks
     
  17. Jawad_b

    Jawad_b

    Joined:
    Jan 14, 2020
    Posts:
    1
    Hi, I had the same problem, the solution is to create an empty game object in the hierarchy then drag and drop the script on that game object, thus you can solve the problem.
    the cause of the problem that you are not able to edit the script in the game assets.
     
    ghoshsankar516 likes this.
  18. caffeinenyc

    caffeinenyc

    Joined:
    Feb 11, 2020
    Posts:
    1
    Thank you! This was killing me!
     
  19. ghoshsankar516

    ghoshsankar516

    Joined:
    Jan 2, 2022
    Posts:
    1
    Thank you so much bro I have been browsing the internet for almost 3 hours. Thank you so much