{"record":{"id":"208ad609b62b5a23","repo":"Unity-Technologies/UnityCsReference","slug":"hierarchyproperty-is-deprecated-use-hierarchyiter","errorCode":null,"errorMessage":"HierarchyProperty is deprecated. Use HierarchyIterator instead.","messagePattern":"HierarchyProperty is deprecated\\. Use HierarchyIterator instead\\.","errorType":"exception","errorClass":"NotImplementedException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/HierarchyProperty.bindings.cs","lineNumber":133,"sourceCode":"            Dispose(true);\n            GC.SuppressFinalize(this);\n        }\n\n#pragma warning disable UA5000 // The Avoid Finalizer Analyzer produces compile errors for any new finalizers. This pre-existing finalizer declaration has been suppressed, but should be rewritten if possible.\n        ~HierarchyProperty() { Dispose(false); }\n#pragma warning restore UA5000\n\n        extern EntityId entityId { get; }\n        public int instanceID => entityId;\n        public extern Object pptrValue { [FreeFunction(\"HierarchyPropertyBindings::PPtrValue\", HasExplicitThis = true)] get; }\n        public extern string name { get; }\n\n        [FreeFunction(\"HierarchyPropertyBindings::GetScene\", HasExplicitThis = true, ThrowsException = true)]\n        public extern Scene GetScene();\n\n        public extern bool hasChildren { [NativeName(\"HasChildren\")] get; }\n        public extern int depth { get; }\n        public int[] ancestors { get { throw new System.NotImplementedException(\"HierarchyProperty is deprecated. Use HierarchyIterator instead.\"); } }\n        public extern int row { get; }\n        public extern int colorCode { get; }\n\n        public bool IsExpanded(int[] expanded) => throw new System.NotImplementedException(\"HierarchyProperty is deprecated. Use HierarchyIterator instead.\");\n\n        public extern string guid { [FreeFunction(\"HierarchyPropertyBindings::GetGuid\", HasExplicitThis = true)] get; }\n        public extern GUID assetGUID { [FreeFunction(\"HierarchyPropertyBindings::GetAssetGUID\", HasExplicitThis = true)] get; }\n        public extern bool alphaSorted { [NativeName(\"IsAlphaSorted\")] get; set; }\n        public extern bool showSceneHeaders { [NativeName(\"IsShowingSceneHeaders\")] get; [NativeName(\"SetShowingSceneHeaders\")] set; }\n        public extern bool isSceneHeader { [NativeName(\"IsSceneHeader\")] get; }\n        public extern bool isValid { [NativeName(\"IsValid\")] get; }\n        public extern bool isMainRepresentation { [NativeName(\"IsMainAssetRepresentation\")] get; }\n        public extern bool hasFullPreviewImage { [NativeName(\"HasFullPreviewImage\")] get; }\n        public extern IconDrawStyle iconDrawStyle { get; }\n        public extern bool isFolder { [NativeName(\"IsFolder\")] get; }\n        public extern GUID[] dynamicDependencies { get; }\n\n        public bool Next(int[] expanded) => throw new System.NotImplementedException(\"HierarchyProperty is deprecated. Use HierarchyIterator instead.\");","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/HierarchyProperty.bindings.cs#L115-L151","documentation":"The HierarchyProperty.ancestors property getter unconditionally throws NotImplementedException. HierarchyProperty is being deprecated in favor of HierarchyIterator; the ancestors member was not migrated and is a dead stub that always fails at runtime.","triggerScenarios":"Reading the HierarchyProperty.ancestors property on any HierarchyProperty instance.","commonSituations":"Existing editor extensions or hierarchy-traversal code that reads the ancestors array after a Unity upgrade that introduced HierarchyIterator.","solutions":["Replace HierarchyProperty traversal with HierarchyIterator, which provides equivalent ancestor and depth APIs.","If only ancestor IDs are needed, compute them from HierarchyIterator by walking Parent() calls."],"exampleFix":"// before\nint[] ancestors = prop.ancestors;\n// after\nusing var iter = new HierarchyIterator(...);\nvar ancestors = new List<int>();\nwhile (iter.Parent()) ancestors.Add(iter.instanceID);","handlingStrategy":"validation","validationCode":"// Do not access HierarchyProperty.ancestors — it always throws.\n// Migrate to HierarchyIterator for ancestor information.","typeGuard":null,"tryCatchPattern":null,"preventionTips":["After Unity upgrades, grep for .ancestors on HierarchyProperty instances and migrate to HierarchyIterator.","Do not rely on HierarchyProperty for hierarchy traversal; it is a deprecated stub."],"tags":["obsolete","api-migration","hierarchy","not-implemented","unity-editor"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}