// CSComponents can be instantiated from a serialized scene or from within managed code protected CSComponent() { if (nativeLoadOverrideValidate != IntPtr.Zero) { // When loading CSComponents from a scene, many issues circumvented by not allowing additional components // to be created (on the Node) during serialization, so this is an error state throw new InvalidOperationException($"CSComponent() - Recursive CSComponent instantiation in default constructor during load type: { GetType().Name} "); } if (nativeLoadOverride == IntPtr.Zero) { // We are being "new'd" in script nativeInstance = csi_Atomic_CSComponent_Constructor(); } else { // We are loading from a serialized CSComponent nativeInstance = nativeLoadOverride; // validation bookkeeping nativeLoadOverrideValidate = nativeLoadOverride; nativeLoadOverride = IntPtr.Zero; } NativeCore.RegisterNative(nativeInstance, this); }
public ScriptObject() { nativeInstance = NativeCore.RegisterNative(csb_Atomic_CSScriptObject_Constructor(), this); }