Fix Child OnClicks
This commit is contained in:
@@ -271,14 +271,40 @@ public class ModelBehaviour : MonoBehaviour, IResettable
|
||||
//model clicked
|
||||
void OnSelect()
|
||||
{
|
||||
Debug.Log($"Selected portIndex {Index}");
|
||||
Debug.Log($"OnClick model {name} {Index}");
|
||||
if (Index == -1)
|
||||
{
|
||||
Debug.LogWarning($"Clicked on Initialized");
|
||||
Debug.LogWarning($"Clicked on Initialized/BaseModel, doing nothing");
|
||||
return;
|
||||
}
|
||||
if (this is ChildModelBehaviour cmb)
|
||||
{
|
||||
if (cmb.Parent is BaseModelBehaviour)
|
||||
{
|
||||
PortSelector.mapPSB[Index].OnClick();
|
||||
}
|
||||
else //subchild
|
||||
{
|
||||
var parent = cmb;
|
||||
while (parent)
|
||||
{
|
||||
if (parent.Parent is BaseModelBehaviour)
|
||||
{
|
||||
Debug.Log($"Parent {parent.name} is root, clicking on him");
|
||||
PortSelector.mapPSB[parent.Index].OnClick();
|
||||
return;
|
||||
}
|
||||
if (parent.Parent is ChildModelBehaviour cmbParent)
|
||||
{
|
||||
parent = cmbParent;
|
||||
continue;
|
||||
}
|
||||
Debug.LogWarning($"Skipping {parent.name}, weird");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetThis()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user