已修复递归寻找组件时只寻找所有第一个对象的问题

This commit is contained in:
2023-11-29 09:24:01 +08:00
parent 1fc8058640
commit 160aff025e
5 changed files with 501 additions and 5 deletions

View File

@@ -141,12 +141,22 @@ namespace XericLibrary.Runtime.MacroLibrary
{
int newRecursion = recursion - 1;
foreach(var item in trans.GetChildren())
//foreach(var item in trans.GetChildren())
//{
// var comp = item.GetComponent<T>();
// if(comp == null && newRecursion > 0)
// comp = item.GetComponentInRecursionChildren<T>(newRecursion);
// yield return comp;
//}
T[] comps;
foreach(var item in trans.GetChildrenRecursion(newRecursion))
{
var comp = item.GetComponent<T>();
if(comp == null && newRecursion > 0)
comp = item.GetComponentInRecursionChildren<T>(newRecursion);
yield return comp;
comps = item.GetComponents<T>();
if(comps != null
&& comps.Length > 0)
foreach (var comp in comps)
yield return comp;
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 73a2b3ee538b9f7438def00d74280abf
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,454 @@
{
"m_SGVersion": 3,
"m_Type": "UnityEditor.ShaderGraph.GraphData",
"m_ObjectId": "d6f420bf56be4372958158ff737681fc",
"m_Properties": [
{
"m_Id": "d5288d6a1d134d6cb5480fe460015857"
}
],
"m_Keywords": [],
"m_Dropdowns": [],
"m_CategoryData": [
{
"m_Id": "01ad679532924fa08f31405fe9f9a720"
}
],
"m_Nodes": [
{
"m_Id": "8c312fb6c6b54587be98bf5d676f53dd"
},
{
"m_Id": "7f51f160c3a64bdfa95d84ec9d007f7f"
},
{
"m_Id": "fe254c9ddc114fa68fceb164790a2b16"
},
{
"m_Id": "c785e43a3e364b0c875b7cdf0f9d43ad"
}
],
"m_GroupDatas": [],
"m_StickyNoteDatas": [],
"m_Edges": [
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "7f51f160c3a64bdfa95d84ec9d007f7f"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "c785e43a3e364b0c875b7cdf0f9d43ad"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "7f51f160c3a64bdfa95d84ec9d007f7f"
},
"m_SlotId": 0
},
"m_InputSlot": {
"m_Node": {
"m_Id": "fe254c9ddc114fa68fceb164790a2b16"
},
"m_SlotId": 0
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "c785e43a3e364b0c875b7cdf0f9d43ad"
},
"m_SlotId": 1
},
"m_InputSlot": {
"m_Node": {
"m_Id": "8c312fb6c6b54587be98bf5d676f53dd"
},
"m_SlotId": 1
}
},
{
"m_OutputSlot": {
"m_Node": {
"m_Id": "fe254c9ddc114fa68fceb164790a2b16"
},
"m_SlotId": 1
},
"m_InputSlot": {
"m_Node": {
"m_Id": "8c312fb6c6b54587be98bf5d676f53dd"
},
"m_SlotId": 2
}
}
],
"m_VertexContext": {
"m_Position": {
"x": 0.0,
"y": 0.0
},
"m_Blocks": []
},
"m_FragmentContext": {
"m_Position": {
"x": 0.0,
"y": 0.0
},
"m_Blocks": []
},
"m_PreviewData": {
"serializedMesh": {
"m_SerializedMesh": "{\"mesh\":{\"instanceID\":0}}",
"m_Guid": ""
},
"preventRotation": false
},
"m_Path": "Sub Graphs",
"m_GraphPrecision": 1,
"m_PreviewMode": 1,
"m_OutputNode": {
"m_Id": "8c312fb6c6b54587be98bf5d676f53dd"
},
"m_ActiveTargets": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.CategoryData",
"m_ObjectId": "01ad679532924fa08f31405fe9f9a720",
"m_Name": "",
"m_ChildObjectList": [
{
"m_Id": "d5288d6a1d134d6cb5480fe460015857"
}
]
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "520fc42b92724ed7ab15eaf895298b34",
"m_Id": 0,
"m_DisplayName": "a",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "a",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "6a37f188f3d04769988a6ca167f0465f",
"m_Id": 1,
"m_DisplayName": "b",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "b",
"m_StageCapability": 3,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "754ca04838f5427e95eaa0d872f1a555",
"m_Id": 2,
"m_DisplayName": "average",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "average",
"m_StageCapability": 3,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.PropertyNode",
"m_ObjectId": "7f51f160c3a64bdfa95d84ec9d007f7f",
"m_Group": {
"m_Id": ""
},
"m_Name": "Property",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -742.0,
"y": 304.0000305175781,
"width": 105.0,
"height": 33.999969482421878
}
},
"m_Slots": [
{
"m_Id": "8df4fc0b915a45f3901751f8f874d6fc"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_Property": {
"m_Id": "d5288d6a1d134d6cb5480fe460015857"
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "82d3883ecfbf498ab212d4d7817b2856",
"m_Id": 0,
"m_DisplayName": "a",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "a",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.SubGraphOutputNode",
"m_ObjectId": "8c312fb6c6b54587be98bf5d676f53dd",
"m_Group": {
"m_Id": ""
},
"m_Name": "Output",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -281.0000305175781,
"y": 236.0000457763672,
"width": 110.00007629394531,
"height": 100.99995422363281
}
},
"m_Slots": [
{
"m_Id": "ec56573ce6bc4dc2ba46ece1cbe73d26"
},
{
"m_Id": "754ca04838f5427e95eaa0d872f1a555"
}
],
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"IsFirstSlotValid": true
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector4MaterialSlot",
"m_ObjectId": "8df4fc0b915a45f3901751f8f874d6fc",
"m_Id": 0,
"m_DisplayName": "Color",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "Out",
"m_StageCapability": 3,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_DefaultValue": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
},
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "c785e43a3e364b0c875b7cdf0f9d43ad",
"m_Group": {
"m_Id": ""
},
"m_Name": "desaturate (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -578.0,
"y": 210.00003051757813,
"width": 216.0,
"height": 94.00003051757813
}
},
"m_Slots": [
{
"m_Id": "82d3883ecfbf498ab212d4d7817b2856"
},
{
"m_Id": "f0e85229f4d4486a9c8adb5555718184"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 1,
"m_FunctionName": "desaturate",
"m_FunctionSource": "",
"m_FunctionBody": "float3 meg = float3(0.299, 0.587, 0.114);\nb = a.x * meg.x + a.y * meg.y + a.z * meg.z;\n"
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.Internal.Vector4ShaderProperty",
"m_ObjectId": "d5288d6a1d134d6cb5480fe460015857",
"m_Guid": {
"m_GuidSerialized": "544dcc6f-9a3a-45eb-979e-21a09650be07"
},
"m_Name": "Color",
"m_DefaultRefNameVersion": 1,
"m_RefNameGeneratedByDisplayName": "Color",
"m_DefaultReferenceName": "_Color",
"m_OverrideReferenceName": "",
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
"m_Hidden": false,
"m_Value": {
"x": 0.0,
"y": 0.0,
"z": 0.0,
"w": 0.0
}
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "ec56573ce6bc4dc2ba46ece1cbe73d26",
"m_Id": 1,
"m_DisplayName": "desaturate",
"m_SlotType": 0,
"m_Hidden": false,
"m_ShaderOutputName": "desaturate",
"m_StageCapability": 3,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": []
}
{
"m_SGVersion": 0,
"m_Type": "UnityEditor.ShaderGraph.Vector1MaterialSlot",
"m_ObjectId": "f0e85229f4d4486a9c8adb5555718184",
"m_Id": 1,
"m_DisplayName": "b",
"m_SlotType": 1,
"m_Hidden": false,
"m_ShaderOutputName": "b",
"m_StageCapability": 3,
"m_Value": 0.0,
"m_DefaultValue": 0.0,
"m_Labels": []
}
{
"m_SGVersion": 1,
"m_Type": "UnityEditor.ShaderGraph.CustomFunctionNode",
"m_ObjectId": "fe254c9ddc114fa68fceb164790a2b16",
"m_Group": {
"m_Id": ""
},
"m_Name": "average (Custom Function)",
"m_DrawState": {
"m_Expanded": true,
"m_Position": {
"serializedVersion": "2",
"x": -578.0,
"y": 304.0,
"width": 201.0,
"height": 94.00003051757813
}
},
"m_Slots": [
{
"m_Id": "520fc42b92724ed7ab15eaf895298b34"
},
{
"m_Id": "6a37f188f3d04769988a6ca167f0465f"
}
],
"synonyms": [
"code",
"HLSL"
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
},
"m_SourceType": 1,
"m_FunctionName": "average",
"m_FunctionSource": "",
"m_FunctionBody": "b = a.x + a.y + a.z;\nb/=3;"
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 6bc53cdcb037a9d4aa4c791c6cfa8dc1
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 60072b568d64c40a485e0fc55012dc9f, type: 3}

View File

@@ -448,6 +448,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -517,6 +518,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -629,6 +631,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -710,6 +713,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -751,6 +755,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -864,6 +869,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -944,6 +950,7 @@
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -1072,6 +1079,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -1131,6 +1139,7 @@
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,
@@ -1182,6 +1191,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": false,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -1394,6 +1404,7 @@
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -1454,6 +1465,7 @@
],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -1511,6 +1523,7 @@
"synonyms": [],
"m_Precision": 0,
"m_PreviewExpanded": true,
"m_DismissedVersion": 0,
"m_PreviewMode": 0,
"m_CustomColors": {
"m_SerializableColors": []
@@ -1581,6 +1594,7 @@
"m_GeneratePropertyBlock": true,
"m_UseCustomSlotLabel": false,
"m_CustomSlotLabel": "",
"m_DismissedVersion": 0,
"m_Precision": 0,
"overrideHLSLDeclaration": false,
"hlslDeclarationOverride": 0,