Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

If someone has a problem with getting null component, even when it's for sure attached to the entity

Discussion in 'Project Tiny' started by Seaqqull, Nov 17, 2020.

  1. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    24
    Hello.
    I had such a problem:
    I have created the component, then attached it to the entity.
    But when I tried to get this component in code it all the time returned me null.

    Here is the solution, I have accidentally found:
    - Press "Dots->ClearEntities"
    After that step by some unknown reason, the editor can begin to emit errors concerning the impossibility of displaying information in [Inspector] or [Animator]
    - Then close editor
    - Delete [GlobalEntitiesDependencies], [SceneDapendencyCache] and internal of [Library] folder.
    - After reopening it helped
    But this error emission can occur again
    - Then after deleting [SceneDapendencyCache] and reopening the project it dissapeared.

    Error and solution were discovered using these packages(1*) and using Unity version: [2020.1.11f1]
    Screenshots of errors(3*) will attach later if they will occur again (forgot to save them).
     

    Attached Files:

    • 1.png
      1.png
      File size:
      40.3 KB
      Views:
      312
    • 3.PNG
      3.PNG
      File size:
      52 KB
      Views:
      316
    Last edited: Nov 17, 2020
  2. kevinmv

    kevinmv

    Unity Technologies

    Joined:
    Nov 15, 2018
    Posts:
    51
    Can you show the code for the component you've added created and added to the type?

    When do you see the error about GetComponent returning null (running in IDE, using playmode play button or something else?) One possible gotcha is that data from the editor isn't converted and deployed to the <project>/Builds/ directory until you press "Build" or "Build and Run" on your game's .buildconfiguration asset. So if you're iterating in your IDE and changing data in the editor, you need to make sure to build from the buildconfiguration asset otherwise the runtime will be using old/previously exported data.
     
  3. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    24
    Here is this component(2*). An error occurred in the [release] build in the browser. Build I use (4*).
    After each build, I clear all cache in the browser.
     

    Attached Files:

    • 2.PNG
      2.PNG
      File size:
      5.6 KB
      Views:
      303
    • 4.PNG
      4.PNG
      File size:
      49.3 KB
      Views:
      320
    Last edited: Nov 17, 2020
  4. Seaqqull

    Seaqqull

    Joined:
    Aug 3, 2018
    Posts:
    24
    Now I finally got this error again(3*). It can occur after reopening the project. But when I close and try to open it again it can help to solve this error. Because of this error I can only see: Scene hirerarchy, Project folders, Scene window, Game window. Other just in flat gray(or black - depending on theme) color.
    So I think the solution, maybe, doesn't depend on this step:
    "- Delete [GlobalEntitiesDependencies], [SceneDapendencyCache] and internal of [Library] folder."
     

    Attached Files:

    • 3.PNG
      3.PNG
      File size:
      52 KB
      Views:
      308