Hello Guest

Author Topic: tk2dCamera is null in Start()  (Read 4287 times)

Ultroman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 14
    • View Profile
tk2dCamera is null in Start()
« on: March 20, 2016, 05:32:53 pm »
EDIT: I noobed out on this one. The solution was tragicomical. If you want to know what was wrong, it's in the next post.

Hello.

Any idea why it would say that my MainCamera-variable (a tk2dCamera) is null, when I try to access it in the Start() method of my MainGameScript? (see my attachment)

It works fine inside Unity, but when I build for PC, and run it, it throws nullpointer exceptions at me, for trying to read the position of the camera in Start().

Code: [Select]
NullReferenceException: (null)
UnityEditor.SerializedObject..ctor (UnityEngine.Object[] objs) (at C:/buildslave/unity/build/artifacts/generated/common/editor/SerializedPropertyBindings.gen.cs:74)
UnityEditor.Editor.GetSerializedObjectInternal () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:154)
UnityEditor.Editor.get_serializedObject () (at C:/buildslave/unity/build/artifacts/generated/common/editor/EditorBindings.gen.cs:147)
UnityEditor.MaterialEditor.OnEnable () (at C:/buildslave/unity/build/Editor/Mono/Inspector/MaterialEditor.cs:1544)

It worked fine before, when using a normal Unity camera.

Thanks in advance!
« Last Edit: March 20, 2016, 10:12:50 pm by Ultroman »

Ultroman

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: tk2dCamera is null in Start()
« Reply #1 on: March 20, 2016, 08:37:10 pm »
Sorry, guys. I noobed out on this one.

I had forgotten to change which scene it should build, and I had just created a new gamescene before switching to tk2d.