{"record":{"id":"9578566afdabb87d","repo":"EllanJiang/GameFramework","slug":"entity-helper-is-invalid","errorCode":null,"errorMessage":"Entity helper is invalid.","messagePattern":"Entity helper is invalid\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Entity/EntityManager.EntityInstanceObject.cs","lineNumber":37,"sourceCode":"            private object m_EntityAsset;\n            private IEntityHelper m_EntityHelper;\n\n            public EntityInstanceObject()\n            {\n                m_EntityAsset = null;\n                m_EntityHelper = null;\n            }\n\n            public static EntityInstanceObject Create(string name, object entityAsset, object entityInstance, IEntityHelper entityHelper)\n            {\n                if (entityAsset == null)\n                {\n                    throw new GameFrameworkException(\"Entity asset is invalid.\");\n                }\n\n                if (entityHelper == null)\n                {\n                    throw new GameFrameworkException(\"Entity helper is invalid.\");\n                }\n\n                EntityInstanceObject entityInstanceObject = ReferencePool.Acquire<EntityInstanceObject>();\n                entityInstanceObject.Initialize(name, entityInstance);\n                entityInstanceObject.m_EntityAsset = entityAsset;\n                entityInstanceObject.m_EntityHelper = entityHelper;\n                return entityInstanceObject;\n            }\n\n            public override void Clear()\n            {\n                base.Clear();\n                m_EntityAsset = null;\n                m_EntityHelper = null;\n            }\n\n            protected internal override void Release(bool isShutdown)\n            {","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Entity/EntityManager.EntityInstanceObject.cs#L19-L55","documentation":"EntityInstanceObject.Create also validates the IEntityHelper argument and throws GameFrameworkException when it is null. The helper drives init/show/hide/release of the entity instance, so without it the pooled object cannot function. Usually means the entity component's helper was never assigned.","triggerScenarios":"Calling EntityInstanceObject.Create with a null entityHelper, or using an EntityManager/EntityComponent whose EntityHelper property was not set before ShowEntity.","commonSituations":"Forgetting to add/assign a class deriving from EntityHelper to the Unity EntityComponent in the Inspector; helper assigned only in code that did not run (early init order issue); refactoring removed the helper registration.","solutions":["Assign a non-null EntityHelper implementation to the EntityComponent (Inspector or code) before showing entities.","If calling Create manually, pass the same helper the entity manager uses.","Add an init-order check that the helper is configured before any ShowEntity call."],"exampleFix":"// before\nentityComponent.EntityHelper = null; // or never set\nentityManager.ShowEntity(id);\n// after\nentityComponent.EntityHelper = new MyEntityHelper();\nentityManager.ShowEntity(id);","handlingStrategy":"validation","validationCode":"if (entityHelper == null) throw new InvalidOperationException(\"EntityHelper not assigned\");\nvar obj = EntityInstanceObject.Create(name, entityAsset, entityInstance, entityHelper);","typeGuard":"bool HasHelper(IEntityHelper helper) => helper != null;","tryCatchPattern":"try { var obj = EntityInstanceObject.Create(name, entityAsset, instance, helper); }\ncatch (GameFrameworkException ex) { Log.Error(\"Instance object create failed: {0}\", ex.Message); }","preventionTips":["Assign an EntityHelper implementation to EntityComponent before ShowEntity","Assert helper configuration during initialization","Don't reorder init so helper assignment runs after entity usage"],"tags":["csharp","gameframework","null-argument","helper"],"backgroundTag":"null-argument","analyzedSha":"d0c010b05167c58e92350449d04864a91ca13fd2","analyzedAt":"2026-09-15T13:37:15.352Z","contentChangedAt":"2026-09-15T13:37:15.352Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}