Onclick opens according CMS

This commit is contained in:
Tim
2025-07-09 12:07:11 +02:00
parent d378c45e2a
commit 4dee4d3862
4 changed files with 17 additions and 5 deletions

View File

@@ -12857,6 +12857,7 @@ MonoBehaviour:
colliderSurface: {fileID: 163506087}
interactable: {fileID: 698127119}
rayInteractable: {fileID: 698127110}
PortSelector: {fileID: 1494770816}
--- !u!1 &700047848
GameObject:
m_ObjectHideFlags: 0
@@ -21748,6 +21749,7 @@ MonoBehaviour:
colliderSurface: {fileID: 557957011}
interactable: {fileID: 1272917968}
rayInteractable: {fileID: 1272917969}
PortSelector: {fileID: 1494770816}
--- !u!114 &1272917968
MonoBehaviour:
m_ObjectHideFlags: 0

View File

@@ -34,6 +34,9 @@ public class ModelBehaviour : MonoBehaviour, IResettable
bool lateInited = false;
public PortSelector PortSelector;
public int Index = -1;
Color _color = Color.black;
Color Color
{
@@ -171,6 +174,7 @@ public class ModelBehaviour : MonoBehaviour, IResettable
child.SetActive(true);
ChildModelBehaviour cmb = child.GetComponent<ChildModelBehaviour>();
_children.Add(child);
cmb.Index = i;
var childModel = ModelManager.GetById(port.DefaultId);
if (childModel.Mesh == null)
@@ -180,7 +184,7 @@ public class ModelBehaviour : MonoBehaviour, IResettable
continue;
}
Debug.Log($"POS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.rotation} {child.transform.localScale}");
//Debug.Log($"POS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.rotation} {child.transform.localScale}");
cmb.Parent = this;
cmb.ChildModel = childModel;
port.Apply(child.transform); // move to correct position
@@ -267,8 +271,13 @@ public class ModelBehaviour : MonoBehaviour, IResettable
//model clicked
void OnSelect()
{
Debug.Log($"Selected {name}");
Debug.Log($"Selected portIndex {Index}");
if (Index == -1)
{
Debug.LogWarning($"Clicked on Initialized");
return;
}
PortSelector.mapPSB[Index].OnClick();
}
public void ResetThis()

View File

@@ -12,6 +12,7 @@ public class PortSelector : MonoBehaviour, IResettable
public List<GameObject> portGOs = new List<GameObject>();
public List<PortSelectorButton> listPSB = new List<PortSelectorButton>();
public Dictionary<int, PortSelectorButton> mapPSB = new Dictionary<int, PortSelectorButton>();
//Gets called from BaseModelSelector
public void GenerateButtons()
@@ -34,7 +35,6 @@ public class PortSelector : MonoBehaviour, IResettable
portGOs.Add(go);
go.SetActive(true);
var text = go.GetComponentInChildren<TMPro.TextMeshProUGUI>();
if (text == null)
{
Debug.LogWarning($"No TextMeshProUGUI found in {go.name}, cannot set text.");
@@ -46,6 +46,7 @@ public class PortSelector : MonoBehaviour, IResettable
psb.marker = go.GetComponentInChildren<Marker>(true).gameObject;
psb.RemoveOtherMarkers = RemoveOtherMarkers;
listPSB.Add(psb);
mapPSB.Add(index, psb);
index++;
i++;
}

View File

@@ -16,7 +16,7 @@ public class PortSelectorButton : MonoBehaviour
{
this.GetOrAddComponent<Button>().onClick.AddListener(OnClick);
}
void OnClick()
public void OnClick()
{
Debug.Log($"Changing Port to {this}");
ColorSelector.ResetThis();