Minor Changes (you can switch models now, fixed max code)
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -0,0 +1,117 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 4afe02867fd0c4c498c16d5a5a8da36a
|
||||||
|
TextureImporter:
|
||||||
|
internalIDToNameTable: []
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 13
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
sRGBTexture: 1
|
||||||
|
linearTexture: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapsPreserveCoverage: 0
|
||||||
|
alphaTestReferenceValue: 0.5
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
flipGreenChannel: 0
|
||||||
|
isReadable: 0
|
||||||
|
streamingMipmaps: 0
|
||||||
|
streamingMipmapsPriority: 0
|
||||||
|
vTOnly: 0
|
||||||
|
ignoreMipmapLimit: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 6
|
||||||
|
cubemapConvolution: 0
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: 1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
serializedVersion: 2
|
||||||
|
filterMode: 1
|
||||||
|
aniso: 1
|
||||||
|
mipBias: 0
|
||||||
|
wrapU: 0
|
||||||
|
wrapV: 0
|
||||||
|
wrapW: 0
|
||||||
|
nPOTScale: 1
|
||||||
|
lightmap: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
spriteMode: 0
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spriteGenerateFallbackPhysicsShape: 1
|
||||||
|
alphaUsage: 1
|
||||||
|
alphaIsTransparency: 0
|
||||||
|
spriteTessellationDetail: -1
|
||||||
|
textureType: 0
|
||||||
|
textureShape: 1
|
||||||
|
singleChannelComponent: 0
|
||||||
|
flipbookRows: 1
|
||||||
|
flipbookColumns: 1
|
||||||
|
maxTextureSizeSet: 0
|
||||||
|
compressionQualitySet: 0
|
||||||
|
textureFormatSet: 0
|
||||||
|
ignorePngGamma: 0
|
||||||
|
applyGammaDecoding: 0
|
||||||
|
swizzle: 50462976
|
||||||
|
cookieLightType: 0
|
||||||
|
platformSettings:
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: DefaultTexturePlatform
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 4
|
||||||
|
buildTarget: Standalone
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
ignorePlatformSupport: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
spriteSheet:
|
||||||
|
serializedVersion: 2
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
customData:
|
||||||
|
physicsShape: []
|
||||||
|
bones: []
|
||||||
|
spriteID: 5e97eb03825dee720800000000000000
|
||||||
|
internalID: 0
|
||||||
|
vertices: []
|
||||||
|
indices:
|
||||||
|
edges: []
|
||||||
|
weights: []
|
||||||
|
secondaryTextures: []
|
||||||
|
spriteCustomMetadata:
|
||||||
|
entries: []
|
||||||
|
nameFileIdTable: {}
|
||||||
|
mipmapLimitGroupName:
|
||||||
|
pSDRemoveMatte: 0
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -87,41 +87,7 @@ public class ModelBehaviour : MonoBehaviour
|
|||||||
{
|
{
|
||||||
var newChildModel = FindAnyObjectByType<ModelManager>().GetById(id);
|
var newChildModel = FindAnyObjectByType<ModelManager>().GetById(id);
|
||||||
_children[childNum].GetComponent<ChildModelBehaviour>().UpdateModel(newChildModel);
|
_children[childNum].GetComponent<ChildModelBehaviour>().UpdateModel(newChildModel);
|
||||||
}
|
Model.Ports[childNum].Apply(_children[childNum].transform);
|
||||||
|
|
||||||
public List<int> GetChildrenWithPort(string port)
|
|
||||||
{
|
|
||||||
List<int> list = new List<int>();
|
|
||||||
for (int i = 0; i < _children.Count; i++)
|
|
||||||
{
|
|
||||||
if (_children[i].GetComponent<ChildModelBehaviour>().ChildModel.Port == port)
|
|
||||||
{
|
|
||||||
list.Add(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return list;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool SetFirstWithPort(string port, ChildModel childModel)
|
|
||||||
{
|
|
||||||
Debug.Log($"{this.name}: has {_children.Count} children");
|
|
||||||
for (int i = 0; i < _children.Count; i++)
|
|
||||||
{
|
|
||||||
var cmb = _children[i].GetComponent<ChildModelBehaviour>();
|
|
||||||
Debug.Log($"{this.name}: {i} name {_children[i].name} - port {cmb.ChildModel.Port}");
|
|
||||||
if(cmb.ChildModel.Port == port)
|
|
||||||
{
|
|
||||||
if (childModel == null)
|
|
||||||
{
|
|
||||||
Debug.LogWarning($"{this.name}: Can't replace port {port} with model, model is null");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
cmb.UpdateModel(Model);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Debug.LogWarning($"{this.name}: Didn't find port {port}");
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -135,9 +101,9 @@ public class ModelBehaviour : MonoBehaviour
|
|||||||
for (int i = 0; i < newModel.Ports.Count; i++)
|
for (int i = 0; i < newModel.Ports.Count; i++)
|
||||||
{
|
{
|
||||||
var port = newModel.Ports[i];
|
var port = newModel.Ports[i];
|
||||||
Debug.Log(i + ". Creating port " + port.port);
|
Debug.Log(i + ". Creating port " + port.PortID);
|
||||||
// bike:wheel:num
|
// bike:wheel:num
|
||||||
GameObject child = new GameObject(this.name + ":" + port.port + ":" + i);
|
GameObject child = new GameObject(this.name + ":" + port.PortID + ":" + i);
|
||||||
child.transform.SetParent(this.transform); //makes this an actual child
|
child.transform.SetParent(this.transform); //makes this an actual child
|
||||||
ChildModelBehaviour cmb = child.AddComponent<ChildModelBehaviour>();
|
ChildModelBehaviour cmb = child.AddComponent<ChildModelBehaviour>();
|
||||||
|
|
||||||
|
|||||||
@@ -139,7 +139,7 @@ public class ModelList
|
|||||||
public static readonly List<ChildModel> ChildModels = new List<ChildModel>()
|
public static readonly List<ChildModel> ChildModels = new List<ChildModel>()
|
||||||
{
|
{
|
||||||
new ChildModel(
|
new ChildModel(
|
||||||
"driver",
|
Definitions.PORT_BIKE_DRIVER,
|
||||||
"Bacteria",
|
"Bacteria",
|
||||||
"bacteria",
|
"bacteria",
|
||||||
Resources.Load<Mesh>("Plagues/Mesh/bacteria"),
|
Resources.Load<Mesh>("Plagues/Mesh/bacteria"),
|
||||||
@@ -147,7 +147,7 @@ public class ModelList
|
|||||||
null
|
null
|
||||||
),
|
),
|
||||||
new ChildModel(
|
new ChildModel(
|
||||||
"driver",
|
Definitions.PORT_BIKE_DRIVER,
|
||||||
"ICBM",
|
"ICBM",
|
||||||
"nuke",
|
"nuke",
|
||||||
Resources.Load<Mesh>("Plagues/Mesh/Nuke"),
|
Resources.Load<Mesh>("Plagues/Mesh/Nuke"),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Serialization;
|
||||||
|
|
||||||
public class ModelManager : MonoBehaviour
|
public class ModelManager : MonoBehaviour
|
||||||
{
|
{
|
||||||
@@ -8,8 +9,12 @@ public class ModelManager : MonoBehaviour
|
|||||||
|
|
||||||
private List<BaseModel> _baseModelList; //available BaseModels
|
private List<BaseModel> _baseModelList; //available BaseModels
|
||||||
|
|
||||||
public GameObject baseModel;
|
public GameObject baseModelGO; //GameObject of the BaseModel
|
||||||
public static BaseModel baseModelType;//current baseModel
|
public BaseModel BaseModel //current baseModel Phenotype
|
||||||
|
{
|
||||||
|
get { return baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel; }
|
||||||
|
}
|
||||||
|
public BaseModelBehaviour BaseModelBehaviour;
|
||||||
public BaseModelSelector baseModelSelector;
|
public BaseModelSelector baseModelSelector;
|
||||||
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
@@ -30,7 +35,7 @@ public class ModelManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
RegisterChildModel(childModel);
|
RegisterChildModel(childModel);
|
||||||
}
|
}
|
||||||
if (baseModel == null) //set in the editor
|
if (baseModelGO == null) //set in the editor
|
||||||
{
|
{
|
||||||
//TODO: send into model selection
|
//TODO: send into model selection
|
||||||
Debug.LogError("baseModel is null, fix the configuration");
|
Debug.LogError("baseModel is null, fix the configuration");
|
||||||
@@ -104,23 +109,21 @@ public class ModelManager : MonoBehaviour
|
|||||||
public void LoadSelectedModel(BaseModel baseModel)
|
public void LoadSelectedModel(BaseModel baseModel)
|
||||||
{
|
{
|
||||||
//create if doesn't exist
|
//create if doesn't exist
|
||||||
if (this.baseModel == null)
|
if (this.baseModelGO == null)
|
||||||
{
|
{
|
||||||
// Create new GameObject for the baseModel
|
// Create new GameObject for the baseModel
|
||||||
this.baseModel = new GameObject(baseModel.NameId)
|
this.baseModelGO = new GameObject(baseModel.NameId)
|
||||||
{
|
{
|
||||||
name = baseModel.NameId,
|
name = baseModel.NameId,
|
||||||
};
|
};
|
||||||
this.baseModel.AddComponent<BaseModelBehaviour>();
|
this.baseModelGO.AddComponent<BaseModelBehaviour>();
|
||||||
// Positioning
|
// Positioning
|
||||||
this.baseModel.transform.position = new Vector3(0, 0, 1);
|
this.baseModelGO.transform.position = new Vector3(0, 0, 1);
|
||||||
this.baseModel.transform.rotation = Quaternion.Euler(0, 90, 0);
|
this.baseModelGO.transform.rotation = Quaternion.Euler(0, 90, 0);
|
||||||
this.baseModel.SetActive(true);
|
this.baseModelGO.SetActive(true);
|
||||||
}
|
}
|
||||||
|
this.baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel = baseModel;
|
||||||
baseModelType = baseModel;
|
this.baseModelGO.SetActive(true);
|
||||||
this.baseModel.GetComponent<BaseModelBehaviour>().BaseModel = baseModel;
|
|
||||||
this.baseModel.SetActive(true);
|
|
||||||
Debug.Log($"Model {baseModel.NameHuman} lock and loaded.");
|
Debug.Log($"Model {baseModel.NameHuman} lock and loaded.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +131,7 @@ public class ModelManager : MonoBehaviour
|
|||||||
{
|
{
|
||||||
Debug.Log("Open Selector");
|
Debug.Log("Open Selector");
|
||||||
|
|
||||||
baseModel.SetActive(false);
|
baseModelGO.SetActive(false);
|
||||||
baseModelSelector.Activate();
|
baseModelSelector.Activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,8 +5,9 @@ public class Port
|
|||||||
private readonly Quaternion _rotation;
|
private readonly Quaternion _rotation;
|
||||||
private readonly Vector3 _scale;
|
private readonly Vector3 _scale;
|
||||||
|
|
||||||
public string port { private set; get; } // port name
|
public readonly string PortID; // port name
|
||||||
public string DefaultId { private set; get; }
|
public readonly string DefaultId; //the default ChildModel to apply on initialization
|
||||||
|
public readonly bool Chooseable; //whether the Port will be rendered in GUI
|
||||||
|
|
||||||
|
|
||||||
public void Apply(Transform target)
|
public void Apply(Transform target)
|
||||||
@@ -16,30 +17,33 @@ public class Port
|
|||||||
target.localScale = _scale;
|
target.localScale = _scale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Port(string name, Vector3 position, string defaultId)
|
public Port(string name, Vector3 position, string defaultId, bool chooseable = true)
|
||||||
{
|
{
|
||||||
port = name;
|
PortID = name;
|
||||||
this._position = position;
|
this._position = position;
|
||||||
this._rotation = Quaternion.identity;
|
this._rotation = Quaternion.identity;
|
||||||
this._scale = new Vector3(1f,1f,1f);
|
this._scale = new Vector3(1f,1f,1f);
|
||||||
this.DefaultId = defaultId;
|
this.DefaultId = defaultId;
|
||||||
|
this.Chooseable = chooseable;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Port(string port, Vector3 position, Quaternion rotation, Vector3 scale, string defaultId)
|
public Port(string portID, Vector3 position, Quaternion rotation, Vector3 scale, string defaultId, bool chooseable = true)
|
||||||
{
|
{
|
||||||
this.port = port;
|
this.PortID = portID;
|
||||||
this._position = position;
|
this._position = position;
|
||||||
this._rotation = rotation;
|
this._rotation = rotation;
|
||||||
this._scale = scale;
|
this._scale = scale;
|
||||||
this.DefaultId = defaultId;
|
this.DefaultId = defaultId;
|
||||||
|
this.Chooseable = chooseable;
|
||||||
}
|
}
|
||||||
public Port(string port, Vector3 position, Quaternion rotation, string defaultId)
|
public Port(string portID, Vector3 position, Quaternion rotation, string defaultId, bool chooseable = true)
|
||||||
{
|
{
|
||||||
this.port = port;
|
this.PortID = portID;
|
||||||
this._position = position;
|
this._position = position;
|
||||||
this._rotation = rotation;
|
this._rotation = rotation;
|
||||||
this._scale = new Vector3(1f,1f,1f);
|
this._scale = new Vector3(1f,1f,1f);
|
||||||
this.DefaultId = defaultId;
|
this.DefaultId = defaultId;
|
||||||
|
this.Chooseable = chooseable;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
private Canvas _canvas;
|
private Canvas _canvas;
|
||||||
private GameObject _buttonPrefab;
|
private GameObject _buttonPrefab;
|
||||||
private Button[] _modelButtons;
|
private Button[] _modelButtons;
|
||||||
public VerticalColumn1 verticalColumn1;
|
public PortSelector portSelector;
|
||||||
|
|
||||||
|
|
||||||
public ModelManager modelManager; // <-- to be put in inspector
|
public ModelManager modelManager; // <-- to be put in inspector
|
||||||
@@ -31,11 +31,11 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
|
|
||||||
void SetupEventSystem()
|
void SetupEventSystem()
|
||||||
{
|
{
|
||||||
if (FindObjectOfType<EventSystem>() == null)
|
if (FindFirstObjectByType<EventSystem>() == null)
|
||||||
{
|
{
|
||||||
GameObject eventSystemGo = new GameObject("EventSystem");
|
GameObject eventSystemGo = new GameObject("EventSystem");
|
||||||
eventSystemGo.AddComponent<EventSystem>();
|
eventSystemGo.AddComponent<EventSystem>();
|
||||||
//var inputModule = eventSystemGo.AddComponent<UnityEngine.InputSystem.UI.InputSystemUIInputModule>(); //Put in for keyboard input. Must be commented out on quest
|
eventSystemGo.AddComponent<UnityEngine.InputSystem.UI.InputSystemUIInputModule>(); //Put in for keyboard input. Must be commented out on quest
|
||||||
eventSystemGo.AddComponent<OVRInputModule>();
|
eventSystemGo.AddComponent<OVRInputModule>();
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -107,12 +107,13 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
modelManager.LoadSelectedModel(model);
|
modelManager.LoadSelectedModel(model);
|
||||||
if (verticalColumn1 == null)
|
|
||||||
|
if (portSelector == null)
|
||||||
{
|
{
|
||||||
Debug.LogError("VerticalColumn1 is null!");
|
Debug.LogError("PortSelector is null!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
verticalColumn1.AssignButtons();
|
portSelector.GenerateButtons();
|
||||||
|
|
||||||
if (returnButton == null)
|
if (returnButton == null)
|
||||||
{
|
{
|
||||||
@@ -134,9 +135,6 @@ public class BaseModelSelector : MonoBehaviour
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ContentUi.SetActive(true);
|
ContentUi.SetActive(true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject SetupPrefab(BaseModel model)
|
public static GameObject SetupPrefab(BaseModel model)
|
||||||
|
|||||||
@@ -1,66 +1,73 @@
|
|||||||
using System;
|
using System;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Net.Mime;
|
|
||||||
using Meta.XR.ImmersiveDebugger.UserInterface.Generic;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using Unity.VisualScripting;
|
using Unity.VisualScripting;
|
||||||
using Unity.XR.CoreUtils;
|
using Unity.XR.CoreUtils;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
using Toggle = UnityEngine.UI.Toggle;
|
using Button = UnityEngine.UI.Button;
|
||||||
|
|
||||||
public class ChildModelSelector : MonoBehaviour
|
public class ChildModelSelector : MonoBehaviour
|
||||||
{
|
{
|
||||||
public List<Transform> horizontalGroups;
|
private List<GameObject> Models = new List<GameObject>();
|
||||||
private string _port;
|
public ModelManager modelManager;
|
||||||
public GameObject ports;
|
public GameObject cmpPrefab; //childModelPickerPrefab (the actual button)
|
||||||
public void setPort(string port)
|
public GameObject daddy;
|
||||||
|
|
||||||
|
private string portId { set; get; }
|
||||||
|
public string PortID
|
||||||
{
|
{
|
||||||
_port = port;
|
set
|
||||||
|
{
|
||||||
|
portId = value;
|
||||||
}
|
}
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return portId;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int PortIndex { set; get; }
|
||||||
|
|
||||||
void Start()
|
void Start()
|
||||||
{
|
{
|
||||||
gameObject.SetActive(false);
|
gameObject.SetActive(false);
|
||||||
|
|
||||||
AssignButtons();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AssignButtons()
|
public void AssignButtons()
|
||||||
{
|
{
|
||||||
int i1 = 0;
|
Debug.Log($"Destroying Old CMS Pickers: {Models.Count}");
|
||||||
var childModels = ModelList.ChildModels.Where(m => m.Port == _port).ToList();
|
foreach (var go in Models)
|
||||||
Debug.Log("ChildModels: " + childModels.Count);
|
|
||||||
int modelIndex = 0;
|
|
||||||
foreach (Transform group in horizontalGroups)
|
|
||||||
{
|
{
|
||||||
Toggle[] toggles = group.GetComponentsInChildren<Toggle>(true);
|
if (go == null)
|
||||||
for (i1 = 0; i1 < toggles.Length; i1++)
|
|
||||||
{
|
{
|
||||||
if (modelIndex < childModels.Count)
|
continue;
|
||||||
|
}
|
||||||
|
Debug.Log($"Destroying {go.name}");
|
||||||
|
Destroy(go);
|
||||||
|
}
|
||||||
|
Models.Clear();
|
||||||
|
|
||||||
|
var childModels = modelManager.GetChildModelsForPort(PortID);
|
||||||
|
foreach (var childModel in childModels)
|
||||||
{
|
{
|
||||||
var model = childModels[modelIndex];
|
Debug.Log($"Adding {childModel}");
|
||||||
toggles[i1].gameObject.SetActive(true);
|
GameObject go = Spawn.GO(cmpPrefab, daddy.transform, Vector3.zero, "picker:" + childModel.Port + ":" + childModel.NameId);
|
||||||
TextMeshProUGUI[] label = toggles[i1].GetComponentsInChildren<TextMeshProUGUI>(true);
|
go.GetOrAddComponent<ModelHolder>().Model = childModel;
|
||||||
|
go.SetActive(true);
|
||||||
|
TextMeshProUGUI[] label = go.GetComponentsInChildren<TextMeshProUGUI>();
|
||||||
if (label.Length > 0)
|
if (label.Length > 0)
|
||||||
{
|
{
|
||||||
label[0].text = model.NameHuman;
|
label[0].text = childModel.NameHuman;
|
||||||
label[1].text = "Zweiter Text";
|
label[1].text = "Bottom Text"; //TODO: add Secondary Text?
|
||||||
|
}
|
||||||
|
go.GetComponent<Button>().onClick.AddListener(() => OnClick(childModel));
|
||||||
|
Models.Add(go);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
modelIndex++;
|
public void OnClick(ChildModel model)
|
||||||
Debug.Log(i1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
toggles[i1].gameObject.SetActive(false);
|
modelManager.BaseModelBehaviour.UpdateChild(PortIndex, model.NameId);
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (modelIndex > childModels.Count)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
7
vr-configurator/Assets/Scripts/UI/ModelHolder.cs
Normal file
7
vr-configurator/Assets/Scripts/UI/ModelHolder.cs
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class ModelHolder : MonoBehaviour
|
||||||
|
{
|
||||||
|
public Model Model { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
3
vr-configurator/Assets/Scripts/UI/ModelHolder.cs.meta
Normal file
3
vr-configurator/Assets/Scripts/UI/ModelHolder.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6a546ba7fe7943099995e627d2b78411
|
||||||
|
timeCreated: 1747078233
|
||||||
@@ -1,37 +0,0 @@
|
|||||||
using TMPro;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
public class PortAssigner : MonoBehaviour
|
|
||||||
{
|
|
||||||
public ChildModelSelector options;
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
Toggle toggle = GetComponent<Toggle>();
|
|
||||||
if (toggle != null)
|
|
||||||
{
|
|
||||||
toggle.onValueChanged.AddListener(OnToggleValueChanged);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("Toggle component not found on GameObject.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void OnToggleValueChanged(bool isOn)
|
|
||||||
{
|
|
||||||
var textmesh = GetComponentInChildren<TextMeshProUGUI>(true);
|
|
||||||
if (textmesh != null)
|
|
||||||
{
|
|
||||||
string port = textmesh.text;
|
|
||||||
options.setPort(port);
|
|
||||||
options.AssignButtons();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Debug.LogError("TextMeshProUGUI component not found in children.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
49
vr-configurator/Assets/Scripts/UI/PortSelector.cs
Normal file
49
vr-configurator/Assets/Scripts/UI/PortSelector.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using TMPro;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using Unity.XR.CoreUtils;
|
||||||
|
|
||||||
|
public class PortSelector : MonoBehaviour
|
||||||
|
{
|
||||||
|
public ModelManager modelManager;
|
||||||
|
|
||||||
|
public GameObject prefab;
|
||||||
|
public Vector3 offset = new Vector3(0,48,0);
|
||||||
|
|
||||||
|
public List<GameObject> ports = new List<GameObject>();
|
||||||
|
|
||||||
|
//Gets called from BaseModelSelector
|
||||||
|
public void GenerateButtons()
|
||||||
|
{
|
||||||
|
foreach (var port in ports)
|
||||||
|
{
|
||||||
|
Debug.Log($"Destroying {port}");
|
||||||
|
Destroy(port);
|
||||||
|
}
|
||||||
|
int i = 0;
|
||||||
|
int index = 0;
|
||||||
|
foreach (Port port in modelManager.BaseModel.GetPorts())
|
||||||
|
{
|
||||||
|
if (!port.Chooseable)
|
||||||
|
{
|
||||||
|
Debug.Log($"Skipping port {port.PortID} for Selection...");
|
||||||
|
index++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Vector3 off = i * offset;
|
||||||
|
Debug.Log($"Adding Port {port.PortID} to Selection with {off.x}, {off.y}, {off.z}");
|
||||||
|
var go = Spawn.GO(prefab, transform, off, port.PortID + i);
|
||||||
|
ports.Add(go);
|
||||||
|
go.SetActive(true);
|
||||||
|
var psb = go.GetComponent<PortSelectorButton>();
|
||||||
|
psb.PortID = port.PortID;
|
||||||
|
psb.PortIndex = index;
|
||||||
|
index++;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
vr-configurator/Assets/Scripts/UI/PortSelectorButton.cs
Normal file
34
vr-configurator/Assets/Scripts/UI/PortSelectorButton.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using TMPro;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
public class PortSelectorButton : MonoBehaviour
|
||||||
|
{
|
||||||
|
public ChildModelSelector options;
|
||||||
|
public string PortID { get; set; }
|
||||||
|
public int PortIndex { set; get; }
|
||||||
|
|
||||||
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
Button button = this.GetOrAddComponent<Button>(); //should be in prefab
|
||||||
|
if (button != null)
|
||||||
|
{
|
||||||
|
button.onClick.AddListener(OnToggleValueChanged);
|
||||||
|
Debug.Log($"Added toggle component on {this}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.LogError("Toggle component not found on GameObject.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void OnToggleValueChanged()
|
||||||
|
{
|
||||||
|
Debug.Log($"Opening CMS on {this}");
|
||||||
|
options.PortID = PortID;
|
||||||
|
options.PortIndex = PortIndex;
|
||||||
|
options.AssignButtons(); // rebuilds GUI
|
||||||
|
options.gameObject.SetActive(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,49 +0,0 @@
|
|||||||
using System;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using TMPro;
|
|
||||||
using Unity.VisualScripting;
|
|
||||||
using Unity.XR.CoreUtils;
|
|
||||||
|
|
||||||
public class VerticalColumn1 : MonoBehaviour
|
|
||||||
{
|
|
||||||
public BaseModel baseModel;
|
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
|
||||||
void Start()
|
|
||||||
{
|
|
||||||
AssignButtons();
|
|
||||||
}
|
|
||||||
public void AssignButtons()
|
|
||||||
{
|
|
||||||
baseModel = ModelManager.baseModelType;
|
|
||||||
List<Port> ports = baseModel.GetPorts();
|
|
||||||
Toggle[] toggles = GetComponentsInChildren<Toggle>(true);
|
|
||||||
List<String> portNames = new List<string>();
|
|
||||||
int i1 = 0;
|
|
||||||
foreach (var port in ports)
|
|
||||||
{
|
|
||||||
if (i1 < toggles.Length && Regex.IsMatch(port.port, @"^(?!portErlbach\d{1,2}$).+") && !portNames.Contains(port.port))
|
|
||||||
{
|
|
||||||
Debug.LogWarning(port.port);
|
|
||||||
toggles[i1].gameObject.SetActive(true);
|
|
||||||
TextMeshProUGUI label = toggles[i1].GetComponentInChildren<TextMeshProUGUI>(true);
|
|
||||||
label.text = port.port;
|
|
||||||
i1++;
|
|
||||||
portNames.Add(port.port);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (int j = i1; j < toggles.Length; j++)
|
|
||||||
{
|
|
||||||
toggles[j].gameObject.SetActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
23
vr-configurator/Assets/Scripts/Util/Spawn.cs
Normal file
23
vr-configurator/Assets/Scripts/Util/Spawn.cs
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class Spawn
|
||||||
|
{
|
||||||
|
public static GameObject GO(Object prefab, Transform parent, Vector3 position, string name = null)
|
||||||
|
{
|
||||||
|
GameObject gameObject = (GameObject)Object.Instantiate(prefab, parent);
|
||||||
|
|
||||||
|
//gameObject.transform.localScale = new Vector3(1f, 1f, 1f);
|
||||||
|
|
||||||
|
if (position != null) //dont listen to lies kids
|
||||||
|
{
|
||||||
|
gameObject.transform.localPosition = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (name != null)
|
||||||
|
{
|
||||||
|
gameObject.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
return gameObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
vr-configurator/Assets/Scripts/Util/Spawn.cs.meta
Normal file
3
vr-configurator/Assets/Scripts/Util/Spawn.cs.meta
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 6d467ef3feac43a2924fb159c8733154
|
||||||
|
timeCreated: 1747040950
|
||||||
Reference in New Issue
Block a user