egametang/ET · error · Exception
iScene cant set null: {this.GetType().FullName}
Error message
iScene cant set null: {this.GetType().FullName} What it means
Thrown by the Entity.IScene setter when assigning null. Every entity must belong to exactly one scene; null is never valid. Removing an entity from its scene is done by Dispose, not by clearing IScene.
Source
Thrown at Packages/cn.etetet.core/Scripts/Core/Share/Entity/Entity.cs:327
[BsonId]
public long Id { get; protected set; }
[BsonIgnore]
protected IScene iScene;
[MemoryPackIgnore]
[BsonIgnore]
public IScene IScene
{
get
{
return this.iScene;
}
protected set
{
if (value == null)
{
throw new Exception($"iScene cant set null: {this.GetType().FullName}");
}
if (this.iScene == value)
{
return;
}
if (this.iScene != null)
{
this.iScene = value;
return;
}
this.iScene = value;
if (this.InstanceId == 0)
{
this.InstanceId = iScene.Fiber.NewInstanceId();View on GitHub (pinned to 5cab01f7a8)
Solutions
- Never assign null to IScene; remove the entity via Dispose() instead.
- Null-check any candidate scene before assigning.
- Confirm the target scene object is constructed and valid before binding.
Example fix
// before
entity.IScene = newScene; // newScene may be null
// after
if (newScene == null) throw new InvalidOperationException("scene required");
entity.IScene = newScene; Defensive patterns
Strategy: validation
Validate before calling
if (newScene != null)
{
entity.IScene = newScene;
} Prevention
- Never assign null to IScene; dispose to remove.
- Validate the scene object before binding.
- Tear scenes down via Dispose, not by clearing references.
When it happens
Trigger: Directly assigning `entity.IScene = null`; a rebind routine that nulls the scene reference on cleanup; deserialization encountering a null scene reference.
Common situations: Tearing down a scene but nulling the property instead of disposing entities; reparent helper that resets scene to null as a reset step.
Related errors
- cant set parent because parent iSence is null: {this.GetType
- cant set parent null: {this.GetType().FullName}
- cant set parent self: {this.GetType().FullName}
- entity already has component: {type.FullName}
- entity is disposed, instanceid == 0!
AI-assisted analysis of egametang/ET@5cab01f7a8 (2026-08-13).
Data as JSON: /api/errors/175796f285b15fd8.
Report an issue: GitHub.