Add IResettable, fix ReturnButtonBehaviour logic
This commit is contained in:
@@ -5123,6 +5123,50 @@ Transform:
|
|||||||
- {fileID: 2139722053}
|
- {fileID: 2139722053}
|
||||||
m_Father: {fileID: 2107447216}
|
m_Father: {fileID: 2107447216}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
--- !u!1 &317678348
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 317678350}
|
||||||
|
- component: {fileID: 317678349}
|
||||||
|
m_Layer: 0
|
||||||
|
m_Name: StateManagerGO
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!114 &317678349
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 317678348}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 35b25439a4a74eaa92122e7fae78561b, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!4 &317678350
|
||||||
|
Transform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 317678348}
|
||||||
|
serializedVersion: 2
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0.28093836, y: 0.72670066, z: 2.560518}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 0}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
--- !u!1 &318658192
|
--- !u!1 &318658192
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -9007,6 +9051,7 @@ GameObject:
|
|||||||
- component: {fileID: 525196401}
|
- component: {fileID: 525196401}
|
||||||
- component: {fileID: 525196408}
|
- component: {fileID: 525196408}
|
||||||
- component: {fileID: 525196407}
|
- component: {fileID: 525196407}
|
||||||
|
- component: {fileID: 525196409}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: CanvasButtons
|
m_Name: CanvasButtons
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -9161,6 +9206,18 @@ Rigidbody:
|
|||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
|
--- !u!114 &525196409
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 525196400}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: aa9b103044004bcea119061f22ab49fa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &527859712
|
--- !u!1 &527859712
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -10344,11 +10401,7 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 6090c3d0202faa84bb7bbf94c1cceec8, type: 3}
|
m_Script: {fileID: 11500000, guid: 6090c3d0202faa84bb7bbf94c1cceec8, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
bms: {fileID: 624025131}
|
StateManager: {fileID: 317678349}
|
||||||
mm: {fileID: 1519836175}
|
|
||||||
buttonCanvas: {fileID: 525196400}
|
|
||||||
explodeButton: {fileID: 465093186}
|
|
||||||
cmsCanvas: {fileID: 1509914124}
|
|
||||||
--- !u!224 &576843183
|
--- !u!224 &576843183
|
||||||
RectTransform:
|
RectTransform:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -25795,6 +25848,7 @@ GameObject:
|
|||||||
- component: {fileID: 1509914125}
|
- component: {fileID: 1509914125}
|
||||||
- component: {fileID: 1509914131}
|
- component: {fileID: 1509914131}
|
||||||
- component: {fileID: 1509914130}
|
- component: {fileID: 1509914130}
|
||||||
|
- component: {fileID: 1509914132}
|
||||||
m_Layer: 0
|
m_Layer: 0
|
||||||
m_Name: CanvasChildModelSelector
|
m_Name: CanvasChildModelSelector
|
||||||
m_TagString: Untagged
|
m_TagString: Untagged
|
||||||
@@ -25946,6 +26000,18 @@ Rigidbody:
|
|||||||
m_Interpolate: 0
|
m_Interpolate: 0
|
||||||
m_Constraints: 0
|
m_Constraints: 0
|
||||||
m_CollisionDetection: 0
|
m_CollisionDetection: 0
|
||||||
|
--- !u!114 &1509914132
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1509914124}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: aa9b103044004bcea119061f22ab49fa, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1514041112
|
--- !u!1 &1514041112
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
@@ -27319,7 +27385,7 @@ MonoBehaviour:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1591058970}
|
m_GameObject: {fileID: 1591058970}
|
||||||
m_Enabled: 0
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
m_Script: {fileID: 11500000, guid: 01614664b831546d2ae94a42149d80ac, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
@@ -27380,7 +27446,7 @@ MonoBehaviour:
|
|||||||
m_PrefabInstance: {fileID: 0}
|
m_PrefabInstance: {fileID: 0}
|
||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 1591058970}
|
m_GameObject: {fileID: 1591058970}
|
||||||
m_Enabled: 1
|
m_Enabled: 0
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 2518c50cb3fc6a6458d4b743c2f69c7d, type: 3}
|
m_Script: {fileID: 11500000, guid: 2518c50cb3fc6a6458d4b743c2f69c7d, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
@@ -181153,3 +181219,4 @@ SceneRoots:
|
|||||||
- {fileID: 548570670}
|
- {fileID: 548570670}
|
||||||
- {fileID: 540709790}
|
- {fileID: 540709790}
|
||||||
- {fileID: 1275794569}
|
- {fileID: 1275794569}
|
||||||
|
- {fileID: 317678350}
|
||||||
|
|||||||
3
vr-configurator/Assets/Scripts/Managing.meta
Normal file
3
vr-configurator/Assets/Scripts/Managing.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c746a9ffc9ef4ec899ec5d95b8bbb1eb
|
||||||
|
timeCreated: 1751913636
|
||||||
8
vr-configurator/Assets/Scripts/Managing/IResettable.cs
Normal file
8
vr-configurator/Assets/Scripts/Managing/IResettable.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
// This interface manages Resetting Elements that have to be resetted (UI elements, Model etc.)
|
||||||
|
// Managed by StateManager
|
||||||
|
public interface IResettable
|
||||||
|
{
|
||||||
|
public void ResetThis();
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5cc676a40183456aa13e1a8d7acf805f
|
||||||
|
timeCreated: 1751913656
|
||||||
33
vr-configurator/Assets/Scripts/Managing/StateManager.cs
Normal file
33
vr-configurator/Assets/Scripts/Managing/StateManager.cs
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.SceneManagement;
|
||||||
|
|
||||||
|
public class StateManager : MonoBehaviour
|
||||||
|
{
|
||||||
|
public List<IResettable> Resettables;
|
||||||
|
|
||||||
|
private void populateResettables()
|
||||||
|
{
|
||||||
|
Resettables ??= new List<IResettable>();
|
||||||
|
Resettables.Clear();
|
||||||
|
foreach (var goot in SceneManager.GetActiveScene().GetRootGameObjects())
|
||||||
|
{
|
||||||
|
Resettables.AddRange(goot.GetComponentsInChildren<IResettable>());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
populateResettables();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ResetAll()
|
||||||
|
{
|
||||||
|
foreach (var resettable in Resettables)
|
||||||
|
{
|
||||||
|
resettable.ResetThis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 35b25439a4a74eaa92122e7fae78561b
|
||||||
|
timeCreated: 1751914506
|
||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public class ModelManager : MonoBehaviour
|
public class ModelManager : MonoBehaviour, IResettable
|
||||||
{
|
{
|
||||||
private Dictionary<string, HashSet<ChildModel>> _portDict; //port mapped on
|
private Dictionary<string, HashSet<ChildModel>> _portDict; //port mapped on
|
||||||
private Dictionary<string, ChildModel> _childModelDict; //childModels by their ID
|
private Dictionary<string, ChildModel> _childModelDict; //childModels by their ID
|
||||||
@@ -164,5 +164,10 @@ public class ModelManager : MonoBehaviour
|
|||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetThis()
|
||||||
|
{
|
||||||
|
OpenSelector();
|
||||||
|
BaseModelBehaviour.ClearChildren();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,12 @@ using UnityEngine;
|
|||||||
using UnityEngine.Serialization;
|
using UnityEngine.Serialization;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class ExplodeModel : MonoBehaviour
|
public class ExplodeModel : MonoBehaviour, IResettable
|
||||||
{
|
{
|
||||||
|
|
||||||
public ModelManager mm;
|
public ModelManager mm;
|
||||||
public GameObject baseModel;
|
public GameObject baseModel;
|
||||||
public TextMeshProUGUI text;
|
public TextMeshProUGUI text;
|
||||||
public GameObject cms;
|
public GameObject cms;
|
||||||
|
|
||||||
|
|
||||||
List<Vector3> goalPos = new List<Vector3>();
|
List<Vector3> goalPos = new List<Vector3>();
|
||||||
List<Vector3> initialPos = new List<Vector3>();
|
List<Vector3> initialPos = new List<Vector3>();
|
||||||
@@ -35,7 +33,6 @@ public class ExplodeModel : MonoBehaviour
|
|||||||
if(explode)
|
if(explode)
|
||||||
for (int i = 0; i < baseModel.transform.childCount; i++)
|
for (int i = 0; i < baseModel.transform.childCount; i++)
|
||||||
{
|
{
|
||||||
Debug.Log($"Child {baseModel.transform.GetChild(i).transform.name} : {baseModel.transform.GetChild(i).transform.localPosition} : {goalPos[i]} : {initialPos[i]}");
|
|
||||||
baseModel.transform.GetChild(i).transform.localPosition =
|
baseModel.transform.GetChild(i).transform.localPosition =
|
||||||
MathUtil.EaseBoth(initialPos[i], goalPos[i],
|
MathUtil.EaseBoth(initialPos[i], goalPos[i],
|
||||||
(tick + 0f) / finalTick); //0f for floating point div
|
(tick + 0f) / finalTick); //0f for floating point div
|
||||||
@@ -47,7 +44,6 @@ public class ExplodeModel : MonoBehaviour
|
|||||||
MathUtil.EaseBoth(goalPos[i], initialPos[i],
|
MathUtil.EaseBoth(goalPos[i], initialPos[i],
|
||||||
(tick + 0f) / finalTick); //0f for floating point div
|
(tick + 0f) / finalTick); //0f for floating point div
|
||||||
}
|
}
|
||||||
|
|
||||||
tick++;
|
tick++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,4 +72,27 @@ public class ExplodeModel : MonoBehaviour
|
|||||||
explode = !explode;
|
explode = !explode;
|
||||||
tick = 0;
|
tick = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetThis()
|
||||||
|
{
|
||||||
|
if (explode)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < baseModel.transform.childCount; i++)
|
||||||
|
{
|
||||||
|
var tf = baseModel.transform.GetChild(i);
|
||||||
|
if (tf == null)
|
||||||
|
{
|
||||||
|
Debug.LogWarning($"Skipping ChildModel {i}");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tf.transform.localPosition = initialPos[i]; //reset all
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pressed = false;
|
||||||
|
explode = false;
|
||||||
|
text.text = explode ? "Explode" : "Unexplode";
|
||||||
|
tick = finalTick + 1;
|
||||||
|
initialPos.Clear();
|
||||||
|
goalPos.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
11
vr-configurator/Assets/Scripts/UI/CanvasBehaviour.cs
Normal file
11
vr-configurator/Assets/Scripts/UI/CanvasBehaviour.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
//this disables buttonCanvas and CMS Canvas
|
||||||
|
public class CanvasBehaviour : MonoBehaviour, IResettable
|
||||||
|
{
|
||||||
|
public void ResetThis()
|
||||||
|
{
|
||||||
|
Debug.Log($"Disabling {this.name}");
|
||||||
|
gameObject.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aa9b103044004bcea119061f22ab49fa
|
||||||
|
timeCreated: 1751918415
|
||||||
@@ -7,7 +7,7 @@ using Unity.XR.CoreUtils;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Button = UnityEngine.UI.Button;
|
using Button = UnityEngine.UI.Button;
|
||||||
|
|
||||||
public class ChildModelSelector : MonoBehaviour
|
public class ChildModelSelector : MonoBehaviour, IResettable
|
||||||
{
|
{
|
||||||
private List<GameObject> Models = new List<GameObject>();
|
private List<GameObject> Models = new List<GameObject>();
|
||||||
public ModelManager modelManager;
|
public ModelManager modelManager;
|
||||||
@@ -28,25 +28,10 @@ public class ChildModelSelector : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public int PortIndex { set; get; }
|
public int PortIndex { set; get; }
|
||||||
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AssignButtons()
|
public void AssignButtons()
|
||||||
{
|
{
|
||||||
Debug.Log($"Destroying Old CMS Pickers: {Models.Count}");
|
ResetThis();
|
||||||
foreach (var go in Models)
|
|
||||||
{
|
|
||||||
if (go == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Debug.Log($"Destroying {go.name}");
|
|
||||||
Destroy(go);
|
|
||||||
}
|
|
||||||
Models.Clear();
|
|
||||||
|
|
||||||
var childModels = modelManager.GetChildModelsForPort(PortID);
|
var childModels = modelManager.GetChildModelsForPort(PortID);
|
||||||
foreach (var childModel in childModels)
|
foreach (var childModel in childModels)
|
||||||
@@ -72,5 +57,20 @@ public class ChildModelSelector : MonoBehaviour
|
|||||||
|
|
||||||
colorSelector.GenerateButtons(model, PortIndex);
|
colorSelector.GenerateButtons(model, PortIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetThis()
|
||||||
|
{
|
||||||
|
Debug.Log($"Destroying Old CMS Pickers: {Models.Count}");
|
||||||
|
foreach (var go in Models)
|
||||||
|
{
|
||||||
|
if (go == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Debug.Log($"Destroying {go.name}");
|
||||||
|
Destroy(go);
|
||||||
|
}
|
||||||
|
Models.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ using System.Collections.Generic;
|
|||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class ColorSelector : MonoBehaviour
|
public class ColorSelector : MonoBehaviour, IResettable
|
||||||
{
|
{
|
||||||
public GameObject prefab;
|
public GameObject prefab;
|
||||||
readonly Vector3 offset = new Vector3(0, 45, 0);
|
readonly Vector3 offset = new Vector3(0, 45, 0);
|
||||||
@@ -12,13 +12,9 @@ public class ColorSelector : MonoBehaviour
|
|||||||
get { return gameObject.transform.parent.gameObject; }
|
get { return gameObject.transform.parent.gameObject; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GenerateButtons(ChildModel model , int portIndex)
|
public void GenerateButtons(ChildModel model, int portIndex)
|
||||||
{
|
{
|
||||||
foreach (var color in buttons)
|
ResetThis();
|
||||||
{
|
|
||||||
Destroy(color);
|
|
||||||
}
|
|
||||||
buttons.Clear();
|
|
||||||
|
|
||||||
if (!model.HasColor())
|
if (!model.HasColor())
|
||||||
{
|
{
|
||||||
@@ -40,4 +36,20 @@ public class ColorSelector : MonoBehaviour
|
|||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ResetThis()
|
||||||
|
{
|
||||||
|
Parent.SetActive(false);
|
||||||
|
|
||||||
|
Debug.Log($"Destroying Old Color Buttons: {buttons.Count}");
|
||||||
|
foreach (var go in buttons)
|
||||||
|
{
|
||||||
|
if (go == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Destroy(go);
|
||||||
|
}
|
||||||
|
buttons.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Util;
|
using Util;
|
||||||
|
|
||||||
public class PortSelector : MonoBehaviour
|
public class PortSelector : MonoBehaviour, IResettable
|
||||||
{
|
{
|
||||||
public ModelManager modelManager;
|
public ModelManager modelManager;
|
||||||
|
|
||||||
@@ -16,16 +16,8 @@ public class PortSelector : MonoBehaviour
|
|||||||
//Gets called from BaseModelSelector
|
//Gets called from BaseModelSelector
|
||||||
public void GenerateButtons()
|
public void GenerateButtons()
|
||||||
{
|
{
|
||||||
foreach (var port in portGOs)
|
ResetThis();
|
||||||
{
|
|
||||||
Debug.Log($"Destroying {port}");
|
|
||||||
Destroy(port);
|
|
||||||
}
|
|
||||||
foreach (var psb in listPSB)
|
|
||||||
{
|
|
||||||
Debug.Log($"Destroying {psb}");
|
|
||||||
Destroy(psb);
|
|
||||||
}
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
foreach (Port port in modelManager.BaseModel.Ports)
|
foreach (Port port in modelManager.BaseModel.Ports)
|
||||||
@@ -52,18 +44,36 @@ public class PortSelector : MonoBehaviour
|
|||||||
psb.PortID = port.PortID;
|
psb.PortID = port.PortID;
|
||||||
psb.PortIndex = index;
|
psb.PortIndex = index;
|
||||||
psb.marker = go.GetComponentInChildren<Marker>(true).gameObject;
|
psb.marker = go.GetComponentInChildren<Marker>(true).gameObject;
|
||||||
psb.ResetOtherButtons = ResetOtherButtons;
|
psb.RemoveOtherMarkers = RemoveOtherMarkers;
|
||||||
listPSB.Add(psb);
|
listPSB.Add(psb);
|
||||||
index++;
|
index++;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ResetOtherButtons()
|
private void RemoveOtherMarkers()
|
||||||
{
|
{
|
||||||
foreach (var psb in listPSB)
|
foreach (var psb in listPSB)
|
||||||
{
|
{
|
||||||
psb.marker.SetActive(false);
|
psb.marker.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void ResetThis()
|
||||||
|
{
|
||||||
|
Debug.Log($"Resetting {this.name}");
|
||||||
|
foreach (var port in portGOs)
|
||||||
|
{
|
||||||
|
Debug.Log($"Destroying {port}");
|
||||||
|
Destroy(port);
|
||||||
|
}
|
||||||
|
portGOs.Clear();
|
||||||
|
foreach (var psb in listPSB)
|
||||||
|
{
|
||||||
|
Debug.Log($"Destroying {psb}");
|
||||||
|
Destroy(psb);
|
||||||
|
}
|
||||||
|
listPSB.Clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ public class PortSelectorButton : MonoBehaviour
|
|||||||
{
|
{
|
||||||
public ChildModelSelector cms;
|
public ChildModelSelector cms;
|
||||||
public GameObject marker;
|
public GameObject marker;
|
||||||
public Action ResetOtherButtons;
|
public Action RemoveOtherMarkers;
|
||||||
public string PortID { get; set; }
|
public string PortID { get; set; }
|
||||||
public int PortIndex { set; get; }
|
public int PortIndex { set; get; }
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ public class PortSelectorButton : MonoBehaviour
|
|||||||
cms.PortIndex = PortIndex;
|
cms.PortIndex = PortIndex;
|
||||||
cms.AssignButtons(); // rebuilds GUI
|
cms.AssignButtons(); // rebuilds GUI
|
||||||
cms.gameObject.SetActive(true);
|
cms.gameObject.SetActive(true);
|
||||||
ResetOtherButtons();
|
RemoveOtherMarkers();
|
||||||
marker.SetActive(true);
|
marker.SetActive(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
public class ReturnButtonBehaviour : MonoBehaviour
|
public class ReturnButtonBehaviour : MonoBehaviour
|
||||||
{
|
{
|
||||||
public BaseModelSelector bms;
|
public StateManager StateManager;
|
||||||
public ModelManager mm;
|
|
||||||
public GameObject buttonCanvas;
|
|
||||||
public GameObject explodeButton;
|
|
||||||
public GameObject cmsCanvas;
|
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
@@ -17,11 +14,7 @@ public class ReturnButtonBehaviour : MonoBehaviour
|
|||||||
void OnClick()
|
void OnClick()
|
||||||
{
|
{
|
||||||
Debug.Log("Return to Menu clicked");
|
Debug.Log("Return to Menu clicked");
|
||||||
mm.OpenSelector();
|
StateManager.ResetAll();
|
||||||
mm.BaseModelBehaviour.ClearChildren();
|
|
||||||
explodeButton.SetActive(true);
|
|
||||||
buttonCanvas.SetActive(false);
|
|
||||||
cmsCanvas.SetActive(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user