| 2452 | } |
| 2453 | |
| 2454 | ScriptInstance *CSharpScript::instance_create(Object *p_this) { |
| 2455 | #ifdef DEBUG_ENABLED |
| 2456 | CRASH_COND(!valid); |
| 2457 | #endif // DEBUG_ENABLED |
| 2458 | |
| 2459 | StringName native_name; |
| 2460 | GDMonoCache::managed_callbacks.ScriptManagerBridge_GetScriptNativeName(this, &native_name); |
| 2461 | |
| 2462 | ERR_FAIL_COND_V(native_name == StringName(), nullptr); |
| 2463 | |
| 2464 | if (!ClassDB::is_parent_class(p_this->get_class_name(), native_name)) { |
| 2465 | if (EngineDebugger::is_active()) { |
| 2466 | CSharpLanguage::get_singleton()->debug_break_parse(get_path(), 0, |
| 2467 | "Script inherits from native type '" + String(native_name) + |
| 2468 | "', so it can't be assigned to an object of type: '" + p_this->get_class() + "'"); |
| 2469 | } |
| 2470 | ERR_FAIL_V_MSG(nullptr, "Script inherits from native type '" + String(native_name) + "', so it can't be assigned to an object of type: '" + p_this->get_class() + "'."); |
| 2471 | } |
| 2472 | |
| 2473 | Callable::CallError unchecked_error; |
| 2474 | return _create_instance(nullptr, 0, p_this, Object::cast_to<RefCounted>(p_this) != nullptr, unchecked_error); |
| 2475 | } |
| 2476 | |
| 2477 | PlaceHolderScriptInstance *CSharpScript::placeholder_instance_create(Object *p_this) { |
| 2478 | #ifdef TOOLS_ENABLED |
no test coverage detected