Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //MD5Hash:6014b3c40b7b1230125095ceba807875;
- using UnityEngine;
- using UnityEngine.UI;
- using System;
- using UnityEditor;
- using UnityEngine.Events;
- using System.Collections.Generic;
- public class MechEditor : UnityEngine.MonoBehaviour
- {
- [HeaderAttribute("UI Elemente")]
- public UnityEngine.UI.Dropdown MechTorso = null;
- public UnityEngine.UI.Dropdown MechArms = null;
- public UnityEngine.UI.Dropdown MechLegs = null;
- public UnityEngine.UI.Dropdown MechHead = null;
- [HeaderAttribute("Mech Editor Hilfsobjekte")]
- public UnityEngine.GameObject Hanging = null;
- public UnityEngine.GameObject Torso = null;
- public UnityEngine.GameObject Arms = null;
- public UnityEngine.GameObject Legs = null;
- public UnityEngine.GameObject Head = null;
- [HeaderAttribute("Deffinition der Komponenten")]
- public MechPart_Torso[] MechTorso_List = null;
- public MechPart_Arm[] MechArm_List = null;
- public MechPart_Leg[] MechLeg_List = null;
- public MechPart_Head[] MechHead_List = null;
- public MechEditor.MechConstruct MechConstruction = new MechEditor.MechConstruct();
- [ContextMenu("Hilfe")]
- public void ContextMenu()
- {
- UnityEditor.Help.BrowseURL("https://valentinwinkelmann.com/");
- }
- void Start()
- {
- MenuEvents();
- Fill_UI();
- }
- void Update()
- {
- }
- public void MenuEvents()
- {
- UnityEngine.UI.Dropdown Dropdown_Dropdown_Torso = null;
- MechTorso.onValueChanged.AddListener(delegate (int arg0)
- {
- BuildMech_Part(arg0, MechPart_Type.Torso);
- });
- MechArms.onValueChanged.AddListener(delegate (int arg0)
- {
- BuildMech_Part(arg0, MechPart_Type.Arm);
- });
- MechLegs.onValueChanged.AddListener(delegate (int arg0)
- {
- UnityEngine.Debug.Log(arg0);
- });
- }
- public void InitializeMech()
- {
- }
- public void BuildMech_Torso(int Index)
- {
- if ((Torso.transform.GetChildCount() > 0))
- {
- ///Chech if mech part allready exists and delete when true...
- UnityEngine.Object.Destroy(Torso.transform.GetChild(0).gameObject);
- UnityEngine.Object.Instantiate(MechTorso_List[Index].Prefab, new UnityEngine.Vector3(0f, 0f, 0f), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), Torso.transform);
- }
- else
- {
- UnityEngine.Object.Instantiate(MechTorso_List[Index].Prefab, new UnityEngine.Vector3(0f, 0f, 0f), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), Torso.transform);
- }
- }
- public void BuildMech_Arms(int Index)
- {
- }
- public void Fill_UI()
- {
- System.Collections.Generic.List<string> MechTorso_List1 = new System.Collections.Generic.List<string>();
- System.Collections.Generic.List<string> MechArm_List1 = new System.Collections.Generic.List<string>();
- System.Collections.Generic.List<string> MechLeg_List1 = new System.Collections.Generic.List<string>();
- System.Collections.Generic.List<string> MechHead_List1 = new System.Collections.Generic.List<string>();
- foreach (var iterator_156 in MechTorso_List)
- {
- MechTorso_List1.Add(iterator_156.name);
- }
- MechTorso.AddOptions(MechTorso_List1);
- foreach (var iterator_173 in MechArm_List)
- {
- MechArm_List1.Add(iterator_173.name);
- }
- MechArms.AddOptions(MechArm_List1);
- foreach (var iterator_186 in MechLeg_List)
- {
- MechLeg_List1.Add(iterator_186.name);
- }
- MechLegs.AddOptions(MechLeg_List1);
- foreach (var iterator_193 in MechHead_List)
- {
- MechHead_List1.Add(iterator_193.name);
- }
- MechHead.AddOptions(MechHead_List1);
- }
- public UnityEngine.GameObject FindMechPart(MechPart_Direction Direction, MechPart_Type Type, int Index)
- {
- UnityEngine.GameObject _GameObject = null;
- switch (Type)
- {
- case MechPart_Type.Torso:
- _GameObject = MechTorso_List[Index].Prefab;
- break;
- case MechPart_Type.Arm:
- switch (Direction)
- {
- case MechPart_Direction.left:
- _GameObject = MechArm_List[Index].Prefab_LeftArm;
- break;
- case MechPart_Direction.right:
- _GameObject = MechArm_List[Index].Prefab_RightArm;
- break;
- default:
- break;
- }
- break;
- case MechPart_Type.Leg:
- switch (Direction)
- {
- case MechPart_Direction.left:
- _GameObject = MechLeg_List[Index].Prefab_LeftLeg;
- break;
- case MechPart_Direction.right:
- _GameObject = MechLeg_List[Index].Prefab_RightLeg;
- break;
- default:
- break;
- }
- break;
- case MechPart_Type.Head:
- _GameObject = MechHead_List[Index].Prefab;
- break;
- default:
- break;
- }
- return _GameObject;
- }
- public bool CheckPart(MechPart_Type Type)
- {
- bool _bool = false;
- switch (Type)
- {
- case MechPart_Type.Torso:
- _bool = (Torso.transform.GetChildCount() > 0);
- break;
- case MechPart_Type.Arm:
- _bool = (Arms.transform.GetChildCount() > 0);
- break;
- case MechPart_Type.Leg:
- _bool = (Legs.transform.GetChildCount() > 0);
- break;
- case MechPart_Type.Head:
- _bool = (Head.transform.GetChildCount() > 0);
- break;
- default:
- break;
- }
- return _bool;
- }
- public void DeletePart(MechPart_Type Type)
- {
- UnityEngine.GameObject _GameObject1 = null;
- switch (Type)
- {
- case MechPart_Type.Torso:
- _GameObject1 = Torso;
- break;
- case MechPart_Type.Arm:
- _GameObject1 = Arms;
- break;
- case MechPart_Type.Leg:
- _GameObject1 = Legs;
- break;
- case MechPart_Type.Head:
- default:
- _GameObject1 = Head;
- break;
- }
- if (CheckPart(MechPart_Type.Torso))
- {
- for (int i_402 = 0; i_402 < _GameObject1.transform.GetChildCount(); i_402++)
- {
- UnityEngine.Object.Destroy(_GameObject1.transform.GetChild(i_402).gameObject);
- }
- }
- else
- {
- UnityEngine.Debug.Log("Schmuuuuu");
- }
- }
- public void BuildMech_Part(int Index, MechPart_Type Type)
- {
- DeletePart(Type);
- switch (Type)
- {
- case MechPart_Type.Torso:
- UnityEngine.Object.Instantiate(FindMechPart(MechPart_Direction.none, Type, Index), new UnityEngine.Vector3(0f, 0f, 0f), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), Torso.transform);
- FindJoint(MechPart_Type.Torso);
- break;
- case MechPart_Type.Arm:
- ///Right Arm Instantiating
- var _TempVar_336_1 = Arms.transform;
- UnityEngine.Object.Instantiate(FindMechPart(MechPart_Direction.right, Type, Index), GetJoint("Right_Arm"), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), _TempVar_336_1);
- ///Left Arm Instantiating
- UnityEngine.Object.Instantiate(FindMechPart(MechPart_Direction.left, Type, Index), GetJoint("Left_Arm"), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), _TempVar_336_1);
- break;
- case MechPart_Type.Leg:
- UnityEngine.Object.Instantiate(FindMechPart(MechPart_Direction.right, Type, Index), new UnityEngine.Vector3(0f, 0f, 0f), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), Legs.transform);
- UnityEngine.Object.Instantiate(FindMechPart(MechPart_Direction.left, Type, Index), new UnityEngine.Vector3(0f, 0f, 0f), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), Legs.transform);
- break;
- case MechPart_Type.Head:
- UnityEngine.Object.Instantiate(FindMechPart(MechPart_Direction.none, Type, Index), new UnityEngine.Vector3(0f, 0f, 0f), new UnityEngine.Quaternion(0f, 0f, 0f, 0f), Head.transform);
- break;
- default:
- break;
- }
- }
- public void FindJoint(MechPart_Type Type)
- {
- switch (Type)
- {
- case MechPart_Type.Torso:
- for (int i_420 = 0; i_420 < Torso.transform.GetChild(0).GetChildCount(); i_420++)
- {
- var _TempVar_417_2 = Torso.transform.GetChild(0).GetChild(i_420);
- if (MechConstruction.JointDictionary.ContainsKey(_TempVar_417_2.name))
- {
- MechConstruction.JointDictionary.Remove(_TempVar_417_2.name);
- MechConstruction.JointDictionary.Add(_TempVar_417_2.name, _TempVar_417_2.position);
- }
- else
- {
- MechConstruction.JointDictionary.Add(_TempVar_417_2.name, _TempVar_417_2.position);
- }
- }
- break;
- default:
- break;
- }
- }
- public UnityEngine.Vector3 GetJoint(string JointName)
- {
- return MechConstruction.JointDictionary[JointName];
- }
- [SerializableAttribute]
- public class MechPart_Torso
- {
- public string name = "";
- public UnityEngine.GameObject Prefab = null;
- [TextAreaAttribute]
- public string Description = "";
- public void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
- {
- }
- }
- [SerializableAttribute]
- public class MechPart_Arm
- {
- public string name = "";
- public UnityEngine.GameObject Prefab_RightArm = null;
- public UnityEngine.GameObject Prefab_LeftArm = null;
- [TextAreaAttribute]
- public string Description = "";
- }
- [SerializableAttribute]
- public class MechPart_Leg
- {
- public string name = "";
- public UnityEngine.GameObject Prefab_RightLeg = null;
- public UnityEngine.GameObject Prefab_LeftLeg = null;
- [TextAreaAttribute]
- public string Description = "";
- }
- [SerializableAttribute]
- public class MechPart_Head
- {
- public string name = "";
- public UnityEngine.GameObject Prefab = null;
- [TextAreaAttribute]
- public string Description = "";
- }
- public class MechConstruct
- {
- public UnityEngine.Vector3 Arm_Left_Position;
- public UnityEngine.Vector3 Arm_Right_Position;
- public UnityEngine.Vector3 Leg_Left_Position;
- public UnityEngine.Vector3 Leg_Right_Position;
- public System.Collections.Generic.Dictionary<string, UnityEngine.Vector3> JointDictionary = new System.Collections.Generic.Dictionary<string, UnityEngine.Vector3>();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement