| | | 1 | | using UnityEngine; |
| | | 2 | | using System.Collections; |
| | | 3 | | |
| | | 4 | | [ExecuteInEditMode] |
| | | 5 | | public class DisplaySelectedObject : MonoBehaviour { |
| | | 6 | | public GameObject[] displayOptions; //Do not comment or change this variable, local values have been assigned to every |
| | | 7 | | public int currentDisplay; |
| | | 8 | | private int oldDisplay; |
| | 10 | 9 | | public int temporalGOArrange=0; //Temporal Variable |
| | 10 | 10 | | public bool ButtonSelectable=true; |
| | | 11 | | |
| | 10 | 12 | | void OnEnable () { |
| | | 13 | | //temporalGOArrange = 0; |
| | 10 | 14 | | if (temporalGOArrange == 1) { //Temporal script |
| | 0 | 15 | | TemporalMethodArrangeModels (); |
| | 0 | 16 | | TemporalPlaceArrangeModels(); |
| | 10 | 17 | | } else { |
| | 20 | 18 | | if (displayOptions.Length > 0) { |
| | 10 | 19 | | TurnOffAll (); //Activate off every object in the array |
| | 10 | 20 | | displayOptions [currentDisplay].SetActive (true); //Activate on the currently selected GameObjec |
| | 10 | 21 | | oldDisplay = currentDisplay; //Since the gameObject we needed is already Activated, we |
| | 10 | 22 | | } |
| | 10 | 23 | | } |
| | 10 | 24 | | } |
| | | 25 | | |
| | | 26 | | |
| | 10 | 27 | | void TurnOffAll(){ |
| | 20 | 28 | | if (displayOptions.Length > 0) { |
| | 272 | 29 | | for (int i=0; i<displayOptions.Length; i++) { |
| | 84 | 30 | | displayOptions [i].SetActive (false); //turn off every GameObject Iniside displayOptions Arr |
| | 84 | 31 | | } |
| | 10 | 32 | | } |
| | 10 | 33 | | } |
| | | 34 | | |
| | 125 | 35 | | public void TurnSelectedWithButton(int curDisp){ |
| | 125 | 36 | | currentDisplay = curDisp; |
| | 243 | 37 | | if (curDisp != oldDisplay) { |
| | 118 | 38 | | displayOptions [oldDisplay].SetActive(false); |
| | 118 | 39 | | displayOptions [curDisp].SetActive(true); |
| | 118 | 40 | | oldDisplay=curDisp; |
| | 118 | 41 | | } |
| | | 42 | | |
| | 125 | 43 | | } |
| | | 44 | | |
| | 0 | 45 | | void TemporalMethodArrangeModels(){ //TemporalScript |
| | 0 | 46 | | Transform[] transformChild = GetComponentsInChildren<Transform> (); |
| | 0 | 47 | | int childCounter=0; |
| | 0 | 48 | | int childAssign=0; |
| | 0 | 49 | | for (int i=1; i<transformChild.Length; i++) { |
| | 0 | 50 | | if (transformChild[i].parent.gameObject==this.gameObject)childCounter++; |
| | 0 | 51 | | } |
| | 0 | 52 | | displayOptions=new GameObject[childCounter]; |
| | 0 | 53 | | for (int j=1; j<transformChild.Length; j++) { |
| | 0 | 54 | | if (transformChild[j].parent.gameObject==this.gameObject){ |
| | 0 | 55 | | displayOptions[childAssign]=transformChild[j].gameObject; |
| | 0 | 56 | | childAssign++; |
| | 0 | 57 | | } |
| | | 58 | | //displayOptions=new GameObject[1]; |
| | 0 | 59 | | } |
| | 0 | 60 | | childCounter = 0; |
| | 0 | 61 | | childAssign = 0; |
| | | 62 | | |
| | 0 | 63 | | } |
| | 0 | 64 | | void TemporalPlaceArrangeModels(){ |
| | 0 | 65 | | Transform[] transformChild = GetComponentsInChildren<Transform> (); |
| | 0 | 66 | | for (int i=1; i<transformChild.Length; i++) { |
| | 0 | 67 | | for (int j=0;j<displayOptions.Length;j++){ |
| | 0 | 68 | | if (displayOptions[j].name.Contains(i+"_")){ |
| | 0 | 69 | | displayOptions[j].transform.SetAsLastSibling(); |
| | 0 | 70 | | } |
| | | 71 | | // if (displayOptions[j].name.Contains("Wood Atlas"))displayOptions[j].transform.SetAsLastSibling(); |
| | | 72 | | // //if (displayOptions[j].name.Contains("Marble Atlas"))displayOptions[j].transform.SetAsLastSibling(); |
| | | 73 | | // if (displayOptions[j].name.Contains("Metal Atlas"))displayOptions[j].transform.SetAsLastSibling(); |
| | | 74 | | // if (displayOptions[j].name.Contains("Plastic Atlas"))displayOptions[j].transform.SetAsLastSibling(); |
| | | 75 | | // if (displayOptions[j].name.Contains("Quarry Atlas"))displayOptions[j].transform.SetAsLastSibling(); |
| | | 76 | | // if (displayOptions[j].name.Contains("Glass Shine"))displayOptions[j].transform.SetAsLastSibling(); |
| | 0 | 77 | | } |
| | 0 | 78 | | } |
| | 0 | 79 | | } |
| | | 80 | | } |