{"record":{"id":"9061d732b7c87af2","repo":"EllanJiang/GameFramework","slug":"can-not-find-entity-0","errorCode":null,"errorMessage":"Can not find entity '{0}'.","messagePattern":"Can not find entity '(.+?)'\\.","errorType":"exception","errorClass":"GameFrameworkException","httpStatus":null,"severity":"error","filePath":"GameFramework/Entity/EntityManager.cs","lineNumber":684,"sourceCode":"\n        /// <summary>\n        /// 隐藏实体。\n        /// </summary>\n        /// <param name=\"entityId\">实体编号。</param>\n        /// <param name=\"userData\">用户自定义数据。</param>\n        public void HideEntity(int entityId, object userData)\n        {\n            if (IsLoadingEntity(entityId))\n            {\n                m_EntitiesToReleaseOnLoad.Add(m_EntitiesBeingLoaded[entityId]);\n                m_EntitiesBeingLoaded.Remove(entityId);\n                return;\n            }\n\n            EntityInfo entityInfo = GetEntityInfo(entityId);\n            if (entityInfo == null)\n            {\n                throw new GameFrameworkException(Utility.Text.Format(\"Can not find entity '{0}'.\", entityId));\n            }\n\n            InternalHideEntity(entityInfo, userData);\n        }\n\n        /// <summary>\n        /// 隐藏实体。\n        /// </summary>\n        /// <param name=\"entity\">实体。</param>\n        public void HideEntity(IEntity entity)\n        {\n            HideEntity(entity, null);\n        }\n\n        /// <summary>\n        /// 隐藏实体。\n        /// </summary>\n        /// <param name=\"entity\">实体。</param>","sourceCodeStart":666,"sourceCodeEnd":702,"githubUrl":"https://github.com/EllanJiang/GameFramework/blob/d0c010b05167c58e92350449d04864a91ca13fd2/GameFramework/Entity/EntityManager.cs#L666-L702","documentation":"HideEntity(entityId) looks up the EntityInfo for the given id. If no shown entity with that id exists, GetEntityInfo returns null and this exception is thrown. You can only hide entities that were successfully shown and not yet hidden.","triggerScenarios":"Calling HideEntity with an id never shown, an id already hidden, or an id whose show is still loading (not yet registered).","commonSituations":"Hiding on scene unload with stale ids; double-hide from overlapping teardown paths; hiding an entity whose show failed asynchronously; serial id mismatch after reload.","solutions":["Check HasEntity(entityId) before calling HideEntity","Track shown entity ids and only hide ids you know are alive","Hide via the IEntity reference you received in ShowEntitySuccess instead of a cached id"],"exampleFix":"// before\nm_EntityComponent.HideEntity(id, null); // id may be stale\n// after\nif (m_EntityComponent.HasEntity(id))\n{\n    m_EntityComponent.HideEntity(id, null);\n}","handlingStrategy":"validation","validationCode":"if (!entityManager.HasEntity(entityId)) return;","typeGuard":"bool IsHideable(int id) => entityManager.HasEntity(id);","tryCatchPattern":"try { HideEntity(id, userData); } catch (GameFrameworkException ex) when (ex.Message.Contains(\"Can not find entity\")) { Debug.LogWarning($\"Entity {id} already hidden\"); }","preventionTips":["Remove ids from your tracking set on HideEntitySuccess","Avoid hiding entities whose show has not succeeded yet","Prefer hiding via IEntity references you hold"],"tags":["unity","gameframework","entity","not-found"],"backgroundTag":"entity-not-found","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"}