void Start() { circleS = GetComponent <SelectorEditor>(); Items = circleS.Items; linear = circleS.LinearVector; //get the angle between Items if (transform.childCount > 0) { angle = 360 / transform.childCount; } //get the distance between Items distance = circleS.Radius / 2; //Reference The text in the UI if (GameObject.Find("TextItemSelected").GetComponent <Text>() && GameObject.Find("ItemData").GetComponent <Text>()) { TextSelectedName = GameObject.Find("TextItemSelected").GetComponent <Text>(); ItemData = GameObject.Find("ItemData").GetComponent <Text>(); TextTotalCoins = GameObject.Find("TotalCoins").GetComponent <Text>(); TextLevel = GameObject.Find("TextLevel").GetComponent <Text>(); UpdateValues(); pressed = false; } else { Debug.Log("TextGUI not found"); } cam = circleS.MenuCamera; //Get the camera from the CircleEditor circleS.enabled = false; //Disable Circle EditorScript InitialPosCam = cam.transform.position; CheckLockItem(); //Snap to the first item you want to be on focus if (circleS.Type == SelectorEditor.SelectorType.Circular) { transform.rotation = Quaternion.Euler(0, angle * (FirstItem - 1), 0); } else { IndexSelected = (FirstItem - 1) % transform.childCount; transform.position = linear * distance * -IndexSelected; } }
public override void OnInspectorGUI() { serObj.Update(); SelectorEditor MySelector = (SelectorEditor)target; DrawDefaultInspector(); SelectorEditor.SelectorType type = (SelectorEditor.SelectorType)Type.enumValueIndex; if (type == SelectorEditor.SelectorType.Circular) { EditorGUILayout.PropertyField(Radius, new GUIContent("Radius", "Radius of the selector")); } if (type == SelectorEditor.SelectorType.Linear) { EditorGUILayout.PropertyField(Radius, new GUIContent("Distance", "Distance between objects")); EditorGUILayout.Slider(LinearX, 0, 1, new GUIContent("Linear X")); EditorGUILayout.Slider(LinearY, 0, 1, new GUIContent("Linear Y")); EditorGUILayout.Slider(LinearZ, 0, 1, new GUIContent("Linear Z")); } GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("Reset Rotation", "Reset the objects rotation to zero "))) { MySelector.ResetItemRotation(); } if (GUILayout.Button(new GUIContent("Look Rotation", "All items look away from the center"))) { MySelector.LookAtRotation(); } GUILayout.EndHorizontal(); if (MySelector.MenuCamera == null) { EditorGUILayout.HelpBox("No camera found, please add a camera to the script", MessageType.Warning); } serObj.ApplyModifiedProperties(); }