I have four classes:

  • class A, which is abstract and partial extending from singleton class C.
  • class A1, which is partial and extending from class A .
  • class B, extending from class A.
  • class C, a singleton which has code to throw an exception if the instance is null, and otherwise uses DoNotDestroyOnLoad().

In scene view, I add class B to the scene. It works, but throws a null instance exception for class A, as it's instance is not present in scene. I think this is because class A extends from a singleton class, and it has ability to throw exceptions when the instance is null. I can not add the class A to the scene because it is abstract.

What can I do to in order to add the class A component to the scene, or otherwise not to get this error?

  • \$\begingroup\$ Class 'A' and class 'A Manager' are separate classes, or the same class? Maybe you can draw a diagram or include some example code. And are A and A1 two halves of your partial class A? \$\endgroup\$ – MichaelHouse Jan 27 '17 at 6:21
  • \$\begingroup\$ I have edited the question for clarity, class A and class A1 are two halves \$\endgroup\$ – m_kiani Jan 27 '17 at 6:30
  • \$\begingroup\$ Don't make class A extend from class C if you don't want the error. \$\endgroup\$ – MichaelHouse Jan 27 '17 at 18:07
  • \$\begingroup\$ Note that I am reimplementing the c# tag. This is a programming question (complete with an un-complete programming answer). The language tag is especially relevant. \$\endgroup\$ – Gnemlock Feb 2 '17 at 11:16
  • 1
    \$\begingroup\$ @Gnemlock Well if the language is not relevant, why put the tag? \$\endgroup\$ – Vaillancourt Feb 2 '17 at 11:25

Yes I had to do exception handling on every point throwing null exception. Done.!!

|improve this answer|||||
  • \$\begingroup\$ could you provide better detail? \$\endgroup\$ – Gnemlock Feb 2 '17 at 9:59
  • \$\begingroup\$ Editing your question for grammar and such, it appears best if you simply provide the excerpt of where you do your exception handling. \$\endgroup\$ – Gnemlock Feb 2 '17 at 11:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.