Skip to content

Commit

Permalink
#103 use activeInHierarchy than activeSelf, so it's the same behavior…
Browse files Browse the repository at this point in the history
… of Unity's built-in ones
  • Loading branch information
TylerTemp committed Nov 26, 2024
1 parent 70df66f commit 36c3fba
Show file tree
Hide file tree
Showing 6 changed files with 321 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Runtime/GetComponentInChildrenAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public GetComponentInChildrenAttribute(EXP config, bool includeInactive = false,
private void ParseArguments(bool includeInactive, Type compType, bool excludeSelf)
{
string compFilter = GetComponentFilter(compType);
string activeFilter = includeInactive ? "" : "[@{gameObject.activeSelf}]";
string activeFilter = includeInactive ? "" : "[@{gameObject.activeInHierarchy}]";

IEnumerable<string> andXPaths = (excludeSelf? new[]{"//*"}: new[]{"", "//*"})
.Select(each => $"{each}{activeFilter}{compFilter}");
Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetComponentInParentsAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public GetComponentInParentsAttribute(EXP config, bool includeInactive = false,
private void ParseArguments(bool includeInactive, Type compType, bool excludeSelf)
{
string compFilter = GetComponentFilter(compType);
string activeFilter = includeInactive ? "" : "[@{gameObject.activeSelf}]";
string activeFilter = includeInactive ? "" : "[@{gameObject.activeInHierarchy}]";
string allFilter = $"{activeFilter}{compFilter}";
string sepFilter = allFilter == ""? "": $"/{allFilter}";

Expand Down
2 changes: 1 addition & 1 deletion Runtime/GetComponentInSceneAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public GetComponentInSceneAttribute(bool includeInactive = false, Type compType
private void ParseArguments(bool includeInactive, Type compType)
{
string compFilter = GetComponentFilter(compType);
string activeFilter = includeInactive ? "" : "[@{gameObject.activeSelf}]";
string activeFilter = includeInactive ? "" : "[@{gameObject.activeInHierarchy}]";
string allFilter = $"{activeFilter}{compFilter}";
// string sepFilter = allFilter == ""? "": $"/{allFilter}";

Expand Down
288 changes: 288 additions & 0 deletions Samples~/Example.unity
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,39 @@ MonoBehaviour:
m_EditorClassIdentifier:
comment: gcp1
targetTransform: {fileID: 0}
--- !u!1 &74166027
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 74166028}
m_Layer: 0
m_Name: Disable2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &74166028
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 74166027}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1336164598}
- {fileID: 98296082}
m_Father: {fileID: 1794407094}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &87718772
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -771,6 +804,37 @@ MonoBehaviour:
m_EditorClassIdentifier:
withAttr:
value: []
--- !u!1 &98296081
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 98296082}
m_Layer: 0
m_Name: Disable2Disable
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &98296082
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 98296081}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 74166028}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &164392812
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -979,6 +1043,37 @@ MonoBehaviour:
structInt: 0
structBool: 0
spriteRenderer: {fileID: 0}
--- !u!1 &196619744
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 196619745}
m_Layer: 0
m_Name: Disable1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &196619745
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 196619744}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1794407094}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &206032195
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -8925,6 +9020,37 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 392d9a7937043ea409001876f61b8cfc, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1 &684715477
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 684715478}
m_Layer: 0
m_Name: Enable2Disable
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
--- !u!4 &684715478
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 684715477}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1743019391}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &698893325
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -9603,6 +9729,37 @@ MonoBehaviour:
- {fileID: 662400908}
mainCamera: {fileID: 0}
ignoreRaycast: {fileID: 0}
--- !u!1 &815846798
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 815846799}
m_Layer: 0
m_Name: Enable2Enable
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &815846799
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 815846798}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1743019391}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &822337502
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -13790,6 +13947,37 @@ MonoBehaviour:
showIf1OrNot2:
showIf1234:
hideIf1234:
--- !u!1 &1336164597
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1336164598}
m_Layer: 0
m_Name: Disable2Enable
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1336164598
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1336164597}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 74166028}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1336575394
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -15307,6 +15495,7 @@ Transform:
- {fileID: 822337503}
- {fileID: 1000795637}
- {fileID: 1020264000}
- {fileID: 1794407094}
m_Father: {fileID: 0}
m_RootOrder: 38
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
Expand Down Expand Up @@ -15866,6 +16055,37 @@ Transform:
m_Father: {fileID: 655414025}
m_RootOrder: -2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1557059591
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1557059592}
m_Layer: 0
m_Name: Enable1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1557059592
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1557059591}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 1794407094}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1564447538
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -17107,6 +17327,39 @@ MonoBehaviour:
_image: {fileID: 1742714858}
_onColor2: {r: 0, g: 0.92941177, b: 1, a: 1}
_offColor2: {r: 0.11764706, g: 0, b: 1, a: 1}
--- !u!1 &1743019390
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1743019391}
m_Layer: 0
m_Name: Enable2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1743019391
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1743019390}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 815846799}
- {fileID: 684715478}
m_Father: {fileID: 1794407094}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1755597643
GameObject:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -17302,6 +17555,41 @@ MonoBehaviour:
m_EditorClassIdentifier:
go: {fileID: 1780858642}
component: {fileID: 1780858644}
--- !u!1 &1794407093
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1794407094}
m_Layer: 0
m_Name: Issue103
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1794407094
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1794407093}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 1557059592}
- {fileID: 196619745}
- {fileID: 1743019391}
- {fileID: 74166028}
m_Father: {fileID: 1486592967}
m_RootOrder: -1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1795259472
GameObject:
m_ObjectHideFlags: 0
Expand Down
Loading

0 comments on commit 36c3fba

Please sign in to comment.