minor changes (fix max coding, fix tim coding)
This commit is contained in:
@@ -5,23 +5,15 @@ using UnityEngine;
|
||||
// Data definition of BaseModel
|
||||
public class BaseModel : Model
|
||||
{
|
||||
private List<Port> ports;
|
||||
public BaseModel(string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset,
|
||||
Quaternion rotation, Vector3 scale, List<Port> ports)
|
||||
: base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports)
|
||||
{
|
||||
this.ports = ports;
|
||||
}
|
||||
public BaseModel(string nameHuman, string nameId, Mesh mesh, Material material, List<Port> ports)
|
||||
: base(nameHuman, nameId, mesh, material, ports)
|
||||
Quaternion rotation, Vector3 scale, List<Port> ports, List<Color> colors = null)
|
||||
: base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports, colors)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public List<Port> GetPorts()
|
||||
public BaseModel(string nameHuman, string nameId, Mesh mesh, Material material, List<Port> ports, List<Color> colors = null)
|
||||
: base(nameHuman, nameId, mesh, material, ports, colors)
|
||||
{
|
||||
return ports;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -6,23 +6,19 @@ using UnityEngine;
|
||||
public class ChildModel : Model
|
||||
{
|
||||
public string Port { get; private set; }
|
||||
public List<String> color{ get; set; } // color of the model, used for coloring the model in the editor
|
||||
|
||||
public ChildModel(string port, string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset,
|
||||
Quaternion rotation, Vector3 scale, List<Port> ports = null,List<String> color = null)
|
||||
: base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports)
|
||||
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> colors = null)
|
||||
: base(nameHuman, nameId, mesh, material, offset, rotation, scale, ports, colors)
|
||||
{
|
||||
this.Port = port;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public ChildModel(string port, string nameHuman, string nameId, Mesh mesh,
|
||||
Material material, List<Port> ports = null, List<String> color = null)
|
||||
: base(nameHuman, nameId, mesh, material, ports)
|
||||
Material material, List<Port> ports = null, List<Color> color = null)
|
||||
: base(nameHuman, nameId, mesh, material, ports, color)
|
||||
{
|
||||
this.Port = port;
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ public class Model
|
||||
public Mesh Mesh { get; internal set; } // obj/fbx
|
||||
public Material Material { get; internal set; } // skin
|
||||
|
||||
public List<Color> Color { get; set; } // koleur
|
||||
|
||||
public readonly List<Port> Ports;
|
||||
|
||||
public readonly Vector3 Offset;
|
||||
@@ -15,7 +17,7 @@ public class Model
|
||||
public readonly Vector3 Scale;
|
||||
|
||||
public Model(string nameHuman, string nameId, Mesh mesh, Material material, Vector3 offset,
|
||||
Quaternion rotation, Vector3 scale, List<Port> ports = null)
|
||||
Quaternion rotation, Vector3 scale, List<Port> ports = null, List<Color> color = null)
|
||||
{
|
||||
this.NameHuman = nameHuman;
|
||||
this.NameId = nameId;
|
||||
@@ -25,8 +27,9 @@ public class Model
|
||||
this.Offset = offset;
|
||||
this.Rotation = rotation;
|
||||
this.Scale = scale;
|
||||
this.Color = color;
|
||||
}
|
||||
public Model(string nameHuman, string nameId, Mesh mesh, Material material, List<Port> ports = null)
|
||||
public Model(string nameHuman, string nameId, Mesh mesh, Material material, List<Port> ports = null, List<Color> color = null)
|
||||
{
|
||||
this.NameHuman = nameHuman;
|
||||
this.NameId = nameId;
|
||||
@@ -36,6 +39,12 @@ public class Model
|
||||
this.Offset = Vector3.zero;
|
||||
this.Rotation = Quaternion.identity;
|
||||
this.Scale = Vector3.one;
|
||||
this.Color = color;
|
||||
}
|
||||
|
||||
public bool HasColor()
|
||||
{
|
||||
return Color != null && Color.Count > 0;
|
||||
}
|
||||
|
||||
public bool HasPorts()
|
||||
|
||||
@@ -7,6 +7,7 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
public class ModelBehaviour : MonoBehaviour
|
||||
{
|
||||
public ModelManager ModelManager;
|
||||
private Model _model;
|
||||
|
||||
internal Model Model
|
||||
@@ -36,26 +37,32 @@ public class ModelBehaviour : MonoBehaviour
|
||||
_meshFilter = gameObject.GetOrAddComponent<MeshFilter>();
|
||||
if(_meshRenderer == null)
|
||||
_meshRenderer = gameObject.GetOrAddComponent<MeshRenderer>();
|
||||
if (ModelManager == null)
|
||||
ModelManager = FindFirstObjectByType<ModelManager>();
|
||||
}
|
||||
|
||||
private void UpdateModel(Model newModel)
|
||||
void UpdateModel(Model newModel)
|
||||
{
|
||||
Init(); // I love race conditions
|
||||
if (newModel is BaseModel)
|
||||
{
|
||||
this.name = "BaseModel:" + newModel.NameId;
|
||||
} else if (newModel is ChildModel cModel)
|
||||
}
|
||||
else if (newModel is ChildModel cModel)
|
||||
{
|
||||
this.name = cModel.Port + ":" + newModel.NameId;
|
||||
}
|
||||
Init();
|
||||
Debug.Log($"Model {name} update to new {newModel} Model.");
|
||||
//unapply model offset
|
||||
//unapply previous model offset
|
||||
if (Model != null)
|
||||
{
|
||||
Debug.Log($"Model {name} reset old {Model} offsets.");
|
||||
transform.localPosition -= Model.Offset;
|
||||
//rotation + scale is set, not modified
|
||||
transform.localRotation *= Quaternion.Inverse(Model.Rotation);
|
||||
transform.localScale -= Model.Scale;
|
||||
}
|
||||
|
||||
Debug.Log($"Model {name} update to new {newModel} Model.");
|
||||
|
||||
//kill old children
|
||||
foreach (var compo in GetComponentsInChildren<ChildModelBehaviour>())
|
||||
{
|
||||
@@ -78,18 +85,23 @@ public class ModelBehaviour : MonoBehaviour
|
||||
_meshFilter.sharedMesh = newModel.Mesh;
|
||||
_meshRenderer.material = newModel.Material;
|
||||
_meshRenderer.sharedMaterial = newModel.Material;
|
||||
transform.rotation = newModel.Rotation;
|
||||
transform.localRotation = newModel.Rotation;
|
||||
transform.localScale = newModel.Scale;
|
||||
transform.localPosition += newModel.Offset;
|
||||
}
|
||||
|
||||
public void UpdateChild(int childNum, string id)
|
||||
{
|
||||
var newChildModel = FindAnyObjectByType<ModelManager>().GetById(id);
|
||||
_children[childNum].GetComponent<ChildModelBehaviour>().UpdateModel(newChildModel);
|
||||
Model.Ports[childNum].ApplySoft(_children[childNum].transform);
|
||||
if (childNum >= _children.Count)
|
||||
{
|
||||
Debug.LogWarning($"Index {childNum} out of bounds {_children.Count}");
|
||||
}
|
||||
Model.Ports[childNum].Unapply(_children[childNum].transform);
|
||||
//set new
|
||||
_children[childNum].GetComponent<ChildModelBehaviour>().ChildModel = ModelManager.GetById(id);
|
||||
Model.Ports[childNum].Apply(_children[childNum].transform);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Spawns all Port-GO's, should be called only on Model Switch <b>after</b> cleanup
|
||||
/// </summary>
|
||||
@@ -97,7 +109,12 @@ public class ModelBehaviour : MonoBehaviour
|
||||
private void SpawnChildPorts(Model newModel)
|
||||
{
|
||||
Debug.Log($"{newModel.NameId}: Spawning {this.name} count of {newModel.Ports.Count} Ports");
|
||||
|
||||
if (ModelManager == null)
|
||||
{
|
||||
Debug.LogError("ModelManager not found");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < newModel.Ports.Count; i++)
|
||||
{
|
||||
var port = newModel.Ports[i];
|
||||
@@ -105,24 +122,21 @@ public class ModelBehaviour : MonoBehaviour
|
||||
// bike:wheel:num
|
||||
GameObject child = new GameObject(this.name + ":" + port.PortID + ":" + i);
|
||||
child.transform.SetParent(this.transform); //makes this an actual child
|
||||
child.transform.localPosition = Vector3.zero; //i love unity
|
||||
ChildModelBehaviour cmb = child.AddComponent<ChildModelBehaviour>();
|
||||
|
||||
var mm = FindAnyObjectByType<ModelManager>();
|
||||
if (mm == null)
|
||||
{
|
||||
Debug.LogError("ModelManager not found");
|
||||
}
|
||||
|
||||
var childModel = mm.GetById(port.DefaultId);
|
||||
_children.Add(child);
|
||||
|
||||
var childModel = ModelManager.GetById(port.DefaultId);
|
||||
if (childModel.Mesh == null)
|
||||
{
|
||||
Debug.LogError("Default Mesh Not Found, destroying child");
|
||||
Destroy(child);
|
||||
continue;
|
||||
}
|
||||
|
||||
Debug.Log($"POSS {child.transform.gameObject.name} pos {child.transform.localPosition} {child.transform.localRotation} {child.transform.localScale}");
|
||||
cmb.ChildModel = childModel;
|
||||
port.Apply(child.transform); // move to correct position
|
||||
_children.Add(child);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -175,32 +189,31 @@ public class ModelBehaviour : MonoBehaviour
|
||||
{
|
||||
return "{" + ExportJsonBase() + "}";
|
||||
}
|
||||
public void UpdateChildColor(int portIndex, Color iconImageColor)
|
||||
|
||||
public void UpdateChildColor(int portIndex, Color color)
|
||||
{
|
||||
if (portIndex < 0 || portIndex >= _children.Count)
|
||||
{
|
||||
Debug.LogWarning($"Ungültiger PortIndex: {portIndex}. Es gibt {_children.Count} Kinder.");
|
||||
Debug.LogWarning($"PortIndex {portIndex} invalid: there are {_children.Count} children.");
|
||||
return;
|
||||
}
|
||||
|
||||
var child = _children[portIndex];
|
||||
var meshRenderer = child.GetComponent<MeshRenderer>();
|
||||
if (meshRenderer != null)
|
||||
if (meshRenderer == null)
|
||||
{
|
||||
// Klonen des Materials und Setzen der Farbe
|
||||
var clonedMaterial = new Material(meshRenderer.material);
|
||||
clonedMaterial.color = iconImageColor;
|
||||
meshRenderer.material = clonedMaterial; // Setzt den MeshRenderer auf den Klon
|
||||
Debug.Log($"Materialfarbe des ChildModels mit PortIndex {portIndex} auf {iconImageColor} gesetzt.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"MeshRenderer für ChildModel mit PortIndex {portIndex} nicht gefunden.");
|
||||
Debug.LogWarning($"MeshRenderer for {portIndex} is null, skipping color set");
|
||||
return;
|
||||
}
|
||||
// Klonen des Materials und Setzen der Farbe
|
||||
var clonedMaterial = new Material(meshRenderer.material);
|
||||
clonedMaterial.color = color;
|
||||
meshRenderer.material = clonedMaterial; // Setzt den MeshRenderer auf den Klon
|
||||
Debug.Log($"PortNum {portIndex}: Cloned Material and Set color to {color}");
|
||||
}
|
||||
public void ClearChildren()
|
||||
{
|
||||
Debug.Log("Lösche alle Kinder in der _children-Liste.");
|
||||
Debug.Log("Removing Children...");
|
||||
foreach (var child in _children)
|
||||
{
|
||||
if (child != null)
|
||||
@@ -209,7 +222,7 @@ public class ModelBehaviour : MonoBehaviour
|
||||
}
|
||||
}
|
||||
_children.Clear();
|
||||
Debug.Log("Alle Kinder wurden gelöscht.");
|
||||
Debug.Log("Removed.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@@ -8,74 +7,8 @@ using UnityEngine;
|
||||
/// </summary>
|
||||
public class ModelList
|
||||
{
|
||||
public static readonly List<ChildModel> ChildModels = new List<ChildModel>()
|
||||
{
|
||||
new ChildModel(
|
||||
Definitions.PORT_BIKE_DRIVER,
|
||||
"Bacteria",
|
||||
"bacteria",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/bacteria"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
Definitions.PORT_BIKE_DRIVER,
|
||||
"ICBM",
|
||||
"nuke",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Nuke"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
Definitions.PORT_BIKE_WHEEL,
|
||||
"30\" Rim",
|
||||
"bike30inchAlloy",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Hex"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
"bikePedalR",
|
||||
"Pedal (right)",
|
||||
"bikePedalR",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Hex"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
"bikePedalL",
|
||||
"Pedal (left)",
|
||||
"bikePedalL",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Hex"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel( //das modell hat im modell selbst n offset, das ist hier das probem, deswegen machst du das unten auch bei den childmodels auc mit dem offset, du musst das kdann auch hier adden
|
||||
Definitions.PORT_ERLBACH_Wheel,
|
||||
"Wheel",
|
||||
"rad20",
|
||||
Resources.Load<Mesh>($"Model/ERLbach/02.01.05.0000-Rad_5Speichen"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
new Vector3(60f, 65f, -15f), // offset to the port
|
||||
Quaternion.Euler(0, 0, 0),
|
||||
new Vector3(1f, 1f, 1f),
|
||||
null,
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
}
|
||||
),
|
||||
|
||||
};
|
||||
|
||||
public static List<Color> DefaultColors;
|
||||
|
||||
public static readonly List<BaseModel> BaseModels = new List<BaseModel>()
|
||||
{
|
||||
new BaseModel(
|
||||
@@ -205,9 +138,82 @@ public class ModelList
|
||||
}
|
||||
)
|
||||
};
|
||||
public static readonly List<ChildModel> ChildModels = new List<ChildModel>()
|
||||
{
|
||||
new ChildModel(
|
||||
Definitions.PORT_BIKE_DRIVER,
|
||||
"Bacteria",
|
||||
"bacteria",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/bacteria"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
Definitions.PORT_BIKE_DRIVER,
|
||||
"ICBM",
|
||||
"nuke",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Nuke"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
Definitions.PORT_BIKE_WHEEL,
|
||||
"30\" Rim",
|
||||
"bike30inchAlloy",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Hex"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
"bikePedalR",
|
||||
"Pedal (right)",
|
||||
"bikePedalR",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Hex"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
"bikePedalL",
|
||||
"Pedal (left)",
|
||||
"bikePedalL",
|
||||
Resources.Load<Mesh>("Plagues/Mesh/Hex"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
null
|
||||
),
|
||||
new ChildModel(
|
||||
Definitions.PORT_ERLBACH_Wheel,
|
||||
"Wheel",
|
||||
"rad20",
|
||||
Resources.Load<Mesh>($"Model/ERLbach/02.01.05.0000-Rad_5Speichen"),
|
||||
Resources.Load<Material>($"Material/Default"),
|
||||
new Vector3(60f, 65f, -15f), // offset to the port
|
||||
Quaternion.Euler(0, 0, 0),
|
||||
new Vector3(1f, 1f, 1f),
|
||||
null,
|
||||
DefaultColors
|
||||
)
|
||||
};
|
||||
|
||||
static ModelList()
|
||||
{
|
||||
if (!ColorUtility.TryParseHtmlString("#4c00b0", out Color purple))
|
||||
{
|
||||
Debug.LogError("Who messed the Hex code up?");
|
||||
return;
|
||||
}
|
||||
DefaultColors = new List<Color>
|
||||
{
|
||||
Color.black,
|
||||
Color.gray,
|
||||
Color.white,
|
||||
Color.blue,
|
||||
Color.green,
|
||||
Color.red,
|
||||
Color.yellow,
|
||||
Color.magenta,
|
||||
Color.cyan,
|
||||
purple
|
||||
};
|
||||
|
||||
/*
|
||||
* ██████ ██ ██ ██ ███████
|
||||
@@ -261,34 +267,34 @@ public class ModelList
|
||||
},
|
||||
new Vector3[7]
|
||||
{
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
|
||||
},
|
||||
new Quaternion[7]
|
||||
{
|
||||
new Quaternion(0,0,0,0),
|
||||
new Quaternion(0,0,0,0),
|
||||
new Quaternion(0,0,0,0),
|
||||
new Quaternion(0,0,0,0),
|
||||
new Quaternion(0,0,0,0),
|
||||
new Quaternion(0,0,0,0),
|
||||
new Quaternion(0,0,0,0),
|
||||
Quaternion.identity,
|
||||
Quaternion.identity,
|
||||
Quaternion.identity,
|
||||
Quaternion.identity,
|
||||
Quaternion.identity,
|
||||
Quaternion.identity,
|
||||
Quaternion.identity,
|
||||
},
|
||||
new Vector3[7] // scale
|
||||
{
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
},
|
||||
new List<Port>[7] // ports
|
||||
{
|
||||
@@ -300,15 +306,15 @@ public class ModelList
|
||||
null,
|
||||
null,
|
||||
},
|
||||
new List<string>[7] // colors
|
||||
new List<Color>[7] // colors
|
||||
{
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
},
|
||||
0 //dont skip the first mesh, TODO: 'repair'
|
||||
);
|
||||
@@ -716,100 +722,100 @@ public class ModelList
|
||||
|
||||
}, new Vector3[94] // positions
|
||||
{
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
new Vector3(-60,-65,15), // wheel RH
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
new Vector3(0,0,0),
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
Vector3.zero,
|
||||
},
|
||||
new Quaternion[94] // rotations
|
||||
{
|
||||
@@ -910,103 +916,100 @@ public class ModelList
|
||||
},
|
||||
new Vector3[94] // scales
|
||||
{
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
new Vector3(1,1,1),
|
||||
|
||||
|
||||
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
Vector3.one,
|
||||
},
|
||||
new List<Port>[94] // ports
|
||||
{
|
||||
@@ -1106,7 +1109,7 @@ public class ModelList
|
||||
null,
|
||||
|
||||
},
|
||||
new List<string>[94] // colors
|
||||
new List<Color>[94] // colors
|
||||
{
|
||||
null,
|
||||
null,
|
||||
@@ -1186,134 +1189,24 @@ public class ModelList
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
}, // wheel
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
}, // wheel
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
}, // wheel
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
}, // wheel
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
},
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
},
|
||||
null,
|
||||
new List<string>
|
||||
{
|
||||
"yellow",
|
||||
"black",
|
||||
"white",
|
||||
"red",
|
||||
"blue",
|
||||
"green",
|
||||
"orange",
|
||||
"purple",
|
||||
"pink",
|
||||
},
|
||||
null,
|
||||
DefaultColors, // wheel
|
||||
DefaultColors, // wheel
|
||||
DefaultColors, // wheel
|
||||
DefaultColors, // wheel
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
DefaultColors,
|
||||
null,
|
||||
DefaultColors,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
},
|
||||
0 //skip the first mesh, which is the baseModel
|
||||
0 //don't skip the first mesh, which is the baseModel
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,14 +8,17 @@ public class ModelManager : MonoBehaviour
|
||||
private Dictionary<string, HashSet<ChildModel>> _portDict; //port mapped on
|
||||
private Dictionary<string, ChildModel> _childModelDict; //childModels by their ID
|
||||
|
||||
private List<BaseModel> _baseModelList; //available BaseModels
|
||||
public List<BaseModel> BaseModelList; //available BaseModels
|
||||
|
||||
public GameObject baseModelGO; //GameObject of the BaseModel
|
||||
public BaseModel BaseModel //current baseModel Phenotype
|
||||
{
|
||||
get { return baseModelGO.GetComponent<BaseModelBehaviour>().BaseModel; }
|
||||
}
|
||||
public BaseModelBehaviour BaseModelBehaviour;
|
||||
public BaseModelBehaviour BaseModelBehaviour
|
||||
{
|
||||
get { return baseModelGO.GetComponent<BaseModelBehaviour>(); }
|
||||
}
|
||||
public BaseModelSelector baseModelSelector;
|
||||
public List<Vector3> childPositions = new List<Vector3>();
|
||||
|
||||
@@ -25,7 +28,7 @@ public class ModelManager : MonoBehaviour
|
||||
Debug.Log("ModelManager: " + gameObject.name);
|
||||
_portDict = new Dictionary<string, HashSet<ChildModel>>();
|
||||
_childModelDict = new Dictionary<string, ChildModel>();
|
||||
_baseModelList = new List<BaseModel>();
|
||||
BaseModelList = new List<BaseModel>();
|
||||
//baseModelSelector = FindFirstObjectByType<BaseModelSelector>();
|
||||
|
||||
foreach (var baseModel in ModelList.BaseModels)
|
||||
@@ -84,8 +87,8 @@ public class ModelManager : MonoBehaviour
|
||||
{
|
||||
return;
|
||||
}
|
||||
_baseModelList ??= new List<BaseModel>();
|
||||
_baseModelList.Add(baseModel);
|
||||
BaseModelList ??= new List<BaseModel>();
|
||||
BaseModelList.Add(baseModel);
|
||||
}
|
||||
|
||||
public HashSet<ChildModel> GetChildModelsForPort(string port)
|
||||
|
||||
@@ -1,2 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d328782a7e1a9ff42a3c023ed7e0d15d
|
||||
guid: d328782a7e1a9ff42a3c023ed7e0d15d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 300
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
||||
@@ -3,38 +3,44 @@ public class Port
|
||||
{
|
||||
private readonly Vector3 _position;
|
||||
private readonly Quaternion _rotation;
|
||||
private readonly Vector3 _scale;
|
||||
private readonly float _scale;
|
||||
|
||||
public readonly string PortID; // port name
|
||||
public readonly string DefaultId; //the default ChildModel to apply on initialization
|
||||
public readonly bool Chooseable; //whether the Port will be rendered in GUI
|
||||
public readonly Vector3 direction;
|
||||
|
||||
public readonly Vector3 ExplodeDirection;
|
||||
|
||||
|
||||
public void Apply(Transform target)
|
||||
{
|
||||
target.localPosition = _position;
|
||||
target.localRotation = _rotation;
|
||||
target.localScale = _scale;
|
||||
Debug.Log($"Applying port {target.gameObject.name} pos {target.localPosition} {target.localRotation} {target.localScale}");
|
||||
target.localPosition += _position;
|
||||
target.localRotation *= _rotation;
|
||||
target.localScale *= _scale;
|
||||
Debug.Log($"applied port {target.gameObject.name} pos {target.localPosition} {target.localRotation} {target.localScale}");
|
||||
}
|
||||
|
||||
public void ApplySoft(Transform target)
|
||||
public void Unapply(Transform target)
|
||||
{
|
||||
target.localPosition += _position;
|
||||
Debug.Log($"Unapplying port {target.gameObject.name} pos {target.localPosition} {target.localRotation} {target.localScale}");
|
||||
target.localPosition -= _position;
|
||||
target.localRotation *= Quaternion.Inverse(_rotation);
|
||||
target.localScale /= _scale;
|
||||
Debug.Log($"unapplied port {target.gameObject.name} pos {target.localPosition} {target.localRotation} {target.localScale}");
|
||||
}
|
||||
public Port(string name, Vector3 position, string defaultId, bool chooseable = true, Vector3 direction = default)
|
||||
|
||||
public Port(string name, Vector3 position, string defaultId, bool chooseable = true, Vector3 explodeDirection = default)
|
||||
{
|
||||
PortID = name;
|
||||
this._position = position;
|
||||
this._rotation = Quaternion.identity;
|
||||
this._scale = new Vector3(1f,1f,1f);
|
||||
this._scale = 1f;
|
||||
this.DefaultId = defaultId;
|
||||
this.Chooseable = chooseable;
|
||||
|
||||
this.direction = direction;
|
||||
this.ExplodeDirection = explodeDirection;
|
||||
}
|
||||
|
||||
public Port(string portID, Vector3 position, Quaternion rotation, Vector3 scale, string defaultId, bool chooseable = true,Vector3 direction = default)
|
||||
public Port(string portID, Vector3 position, Quaternion rotation, float scale, string defaultId, bool chooseable = true,Vector3 explodeDirection = default)
|
||||
{
|
||||
this.PortID = portID;
|
||||
this._position = position;
|
||||
@@ -42,22 +48,18 @@ public class Port
|
||||
this._scale = scale;
|
||||
this.DefaultId = defaultId;
|
||||
this.Chooseable = chooseable;
|
||||
this.direction = direction;
|
||||
this.ExplodeDirection = explodeDirection;
|
||||
}
|
||||
public Port(string portID, Vector3 position, Quaternion rotation, string defaultId, bool chooseable = true, Vector3 direction = default)
|
||||
|
||||
public Port(string portID, Vector3 position, Quaternion rotation, string defaultId, bool chooseable = true, Vector3 explodeDirection = default)
|
||||
|
||||
{
|
||||
this.PortID = portID;
|
||||
this._position = position;
|
||||
this._rotation = rotation;
|
||||
this._scale = new Vector3(1f,1f,1f);
|
||||
this._scale = 1f;
|
||||
this.DefaultId = defaultId;
|
||||
this.Chooseable = chooseable;
|
||||
this.direction = direction;
|
||||
this.ExplodeDirection = explodeDirection;
|
||||
}
|
||||
public Vector3 GetPosition()
|
||||
{
|
||||
return _position;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -31,9 +31,9 @@ public class ExplodeModel : MonoBehaviour
|
||||
mm.childPositions.Add(child.localPosition);
|
||||
var childModelBehaviour = child.GetComponent<ChildModelBehaviour>();
|
||||
Port port = mm.GetPortForChildModel(childModelBehaviour.ChildModel);
|
||||
if (port.direction != Vector3.zero)
|
||||
if (port.ExplodeDirection != Vector3.zero)
|
||||
{
|
||||
Vector3 richtung = Richtung(port.direction);
|
||||
Vector3 richtung = Richtung(port.ExplodeDirection);
|
||||
|
||||
Debug.Log("Richtung Pos" + richtung*10);
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class BaseModelSelector : MonoBehaviour
|
||||
{
|
||||
float startY = 0f; // Start position on Y axis
|
||||
float buttonHeight = 0.3f; // Distance between Buttons
|
||||
foreach (var model in ModelList.BaseModels)
|
||||
foreach (var model in ModelList.BaseModels) //TODO: add mutex so modelmanagers bmlist works
|
||||
{
|
||||
var button = Spawn.GO(buttonPrefab, canvas.transform, new Vector3(0, startY, 0), "ModelButton:" + model.NameId);
|
||||
button.GetNamedChild("Icon").GetComponent<Image>().sprite = Resources.Load<Sprite>($"sprites/" + model.NameId);
|
||||
|
||||
@@ -53,7 +53,6 @@ public class ChildModelSelector : MonoBehaviour
|
||||
{
|
||||
Debug.Log($"Adding {childModel}");
|
||||
GameObject go = Spawn.GO(cmpPrefab, daddy.transform, Vector3.zero, "picker:" + childModel.Port + ":" + childModel.NameId);
|
||||
go.GetOrAddComponent<ModelHolder>().Model = childModel;
|
||||
go.SetActive(true);
|
||||
TextMeshProUGUI[] label = go.GetComponentsInChildren<TextMeshProUGUI>();
|
||||
if (label.Length > 0)
|
||||
@@ -68,11 +67,8 @@ public class ChildModelSelector : MonoBehaviour
|
||||
|
||||
public void OnClick(ChildModel model)
|
||||
{
|
||||
|
||||
modelManager.BaseModelBehaviour.UpdateChild(PortIndex, model.NameId);
|
||||
colorSelector.generateButtons(model, PortIndex);
|
||||
|
||||
|
||||
colorSelector.GenerateButtons(model, PortIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,72 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Mime;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
|
||||
public class ColorSelector : MonoBehaviour
|
||||
{
|
||||
public GameObject prefab;
|
||||
public Vector3 offset = new Vector3(0,45,0);
|
||||
public List<GameObject> colors = new List<GameObject>();
|
||||
public void generateButtons(ChildModel model , int portIndex)
|
||||
readonly Vector3 offset = new Vector3(0, 45, 0);
|
||||
List<GameObject> buttons = new List<GameObject>();
|
||||
GameObject Parent
|
||||
{
|
||||
makeParentInvisible(gameObject);
|
||||
foreach (var color in colors)
|
||||
get { return gameObject.transform.parent.gameObject; }
|
||||
}
|
||||
|
||||
public void GenerateButtons(ChildModel model , int portIndex)
|
||||
{
|
||||
foreach (var color in buttons)
|
||||
{
|
||||
Destroy(color);
|
||||
}
|
||||
buttons.Clear();
|
||||
|
||||
if (!model.HasColor())
|
||||
{
|
||||
Debug.Log($"{model} has no Colors defined, skipping");
|
||||
Parent.SetActive(false); //hide menu, since there isn't anything to select
|
||||
return;
|
||||
}
|
||||
|
||||
Parent.SetActive(true);
|
||||
int i = 0;
|
||||
if (model.color.Count != 0)
|
||||
foreach (var color in model.Color)
|
||||
{
|
||||
makeParentVisible(gameObject);
|
||||
foreach (var color in model.color)
|
||||
{
|
||||
|
||||
Vector3 off = i * offset;
|
||||
var go = Spawn.GO(prefab, transform,off, color);
|
||||
colors.Add(go);
|
||||
go.SetActive(true);
|
||||
Debug.Log(go.transform.localPosition);
|
||||
|
||||
var iconImage = go.GetComponent<UnityEngine.UI.Image>();
|
||||
if (ColorUtility.TryParseHtmlString(color, out Color parsedColor))
|
||||
{
|
||||
iconImage.color = parsedColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning($"Die Farbe {color} konnte nicht geparst werden.");
|
||||
}
|
||||
var colorSelectorButton = go.GetComponent<ColorSelectorButton>();
|
||||
if (colorSelectorButton != null)
|
||||
{
|
||||
colorSelectorButton.setPortIndex(portIndex);
|
||||
colorSelectorButton.childmodel = model;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("ColorSelectorButton-Komponente nicht gefunden.");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void makeParentVisible(GameObject childmodel)
|
||||
{
|
||||
if (childmodel.transform.parent != null)
|
||||
{
|
||||
var parent = childmodel.transform.parent.gameObject;
|
||||
parent.SetActive(true);
|
||||
}
|
||||
}
|
||||
public void makeParentInvisible(GameObject childmodel)
|
||||
{
|
||||
if (childmodel.transform.parent != null)
|
||||
{
|
||||
var parent = childmodel.transform.parent.gameObject;
|
||||
parent.SetActive(false);
|
||||
Vector3 off = i * offset;
|
||||
GameObject go = Spawn.GO(prefab, transform, off, "ColorButton_" + color);
|
||||
buttons.Add(go);
|
||||
go.GetComponent<UnityEngine.UI.Image>().color = color;
|
||||
go.GetOrAddComponent<ColorSelectorButton>().PortIndex = portIndex;
|
||||
go.SetActive(true);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,26 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using Unity.VisualScripting;
|
||||
|
||||
public class ColorSelectorButton : MonoBehaviour
|
||||
{
|
||||
public ModelManager modelManager;
|
||||
public ChildModel childmodel;
|
||||
private Button button;
|
||||
private int portIndex;
|
||||
|
||||
public void setPortIndex(int portIndex)
|
||||
{
|
||||
this.portIndex = portIndex;
|
||||
}
|
||||
public int PortIndex { private get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
button = GetComponent<Button>();
|
||||
if (button != null)
|
||||
{
|
||||
button.onClick.AddListener(OnClick);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Button-Komponente nicht gefunden!");
|
||||
}
|
||||
this.GetOrAddComponent<Button>().onClick.AddListener(OnClick);
|
||||
}
|
||||
|
||||
private void OnClick()
|
||||
void OnClick()
|
||||
{
|
||||
|
||||
|
||||
var iconImage = GetComponent<Image>();
|
||||
if (iconImage != null)
|
||||
{
|
||||
modelManager.BaseModelBehaviour.UpdateChildColor(portIndex, iconImage.color);
|
||||
Debug.Log($"Materialfarbe des ChildModels auf {iconImage.color} gesetzt.");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogWarning("Image-Komponente nicht gefunden, keine Farbe verfügbar.");
|
||||
var image = GetComponent<Image>();
|
||||
if (image == null)
|
||||
{
|
||||
Debug.LogWarning("ColorSelectorButton is missing an Image, can't set Color");
|
||||
return;
|
||||
}
|
||||
modelManager.BaseModelBehaviour.UpdateChildColor(PortIndex, image.color);
|
||||
Debug.Log($"Set Color to {image.color}");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class ModelHolder : MonoBehaviour
|
||||
{
|
||||
public Model Model { get; set; }
|
||||
}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6a546ba7fe7943099995e627d2b78411
|
||||
timeCreated: 1747078233
|
||||
@@ -1,11 +1,5 @@
|
||||
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
|
||||
{
|
||||
@@ -26,7 +20,7 @@ public class PortSelector : MonoBehaviour
|
||||
}
|
||||
int i = 0;
|
||||
int index = 0;
|
||||
foreach (Port port in modelManager.BaseModel.GetPorts())
|
||||
foreach (Port port in modelManager.BaseModel.Ports)
|
||||
{
|
||||
if (!port.Chooseable)
|
||||
{
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using TMPro;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -9,21 +8,11 @@ public class PortSelectorButton : MonoBehaviour
|
||||
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.");
|
||||
}
|
||||
this.GetOrAddComponent<Button>().onClick.AddListener(OnToggleValueChanged);
|
||||
}
|
||||
private void OnToggleValueChanged()
|
||||
void OnToggleValueChanged()
|
||||
{
|
||||
Debug.Log($"Opening CMS on {this}");
|
||||
options.PortID = PortID;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using NUnit.Framework;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
@@ -9,7 +8,7 @@ using UnityEngine;
|
||||
public class ModelLoader
|
||||
{
|
||||
public static void LoadChildModelsFromPackedModel(List<ChildModel> appendList, string[] port, string[] nameHuman,
|
||||
string[] nameId, Mesh[] meshes, Material[] mats,Vector3[] offset,Quaternion[] rotation, Vector3[] scale, List<Port>[] ports,List<String>[] colors = null, int fromMesh = 0, int toMesh = -1)
|
||||
string[] nameId, Mesh[] meshes, Material[] mats, Vector3[] offset, Quaternion[] rotation, Vector3[] scale, List<Port>[] ports, List<Color>[] colors = null, int fromMesh = 0, int toMesh = -1)
|
||||
{
|
||||
Debug.Log("LoadChildModels " + fromMesh + " to " + toMesh + " from " + mats.Length + " meshes");
|
||||
if (toMesh == -1)
|
||||
@@ -19,8 +18,8 @@ public class ModelLoader
|
||||
for (int i = 0; i < toMesh - fromMesh; i++)
|
||||
{
|
||||
Debug.Log($"{i}. {nameId[i]}:{nameHuman[i]} with {port.Length} ports");
|
||||
appendList.Add(new ChildModel(port[i], nameHuman[i], nameId[i], meshes[fromMesh + i], mats[i],offset[i], rotation[i], scale[i], ports[i], colors[i]));
|
||||
appendList.Add(new ChildModel(port[i], nameHuman[i], nameId[i], meshes[fromMesh + i], mats[i], offset[i], rotation[i], scale[i], ports[i], colors?[i]));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user