Hi, this warning:
is being generated on this line of code:
instance = new GameObject("StoreManager").AddComponent<StorePlatformManager>();
Why?
Hi, this warning:
is being generated on this line of code:
instance = new GameObject("StoreManager").AddComponent<StorePlatformManager>();
Why?
try:
instance = (new GameObject(“StoreManager”)).AddComponent();
Not sure how “instance” is defined though.
instance is
public static readonly StoreManager instance;
and
instance = (new GameObject("StoreManager")).AddComponent<StorePlatformManager>();
still gives the same warning
You are trying to assign “StorePlatformManager” to instance which is “StoreManager”.
I’ve just tried:
public sc2 _sc2;
void Start(){
_sc2 = (new GameObject("asd")).AddComponent<sc2>();
}
Works fine.
Sorry, we additionally have conditionals such as
#if UNITY_ANDROID
using StorePlatformManager = StoreManagerGoogle;
#else
...etc...
#endif
where StoreManagerGoogle extends StoreManager which extends MonoBehaviour
So presumably it’s to do with that but still not sure why it would cause that warning?
Is StoreManager a script?
Yes, it ultimately extends MonoBehaviour
Oh, well if it’s a MonoBehaviour you can’t create a game object of a MonoBehaviour. Unless I’m misunderstanding what you’re doing. You could create an empty object and attach StoreManager to it and instantiate that object when you need another StoreManager object. Although it’s quite possible I’m misunderstanding the situation.