private void OnSceneGUI() { Event e = Event.current; //Step Object if (e.type == EventType.ScrollWheel && e.shift) { (target as Collection)?.Step(CollectionUtility.GetScrollStep(e)); e.Use(); } //Rotate Object if (e.type == EventType.ScrollWheel && e.alt) { (target as Collection)?.StepRotation(CollectionUtility.GetScrollStep(e)); e.Use(); } //Randomize Object if (e.isMouse && e.button == 2 && e.shift) { (target as Collection)?.Randomize(); e.Use(); } Handles.BeginGUI(); //Add padding EditorGUILayout.LabelField(""); EditorGUILayout.LabelField("Scroll + Shift: Step through objects"); EditorGUILayout.LabelField("Scroll + Alt: Rotate Object"); EditorGUILayout.LabelField("Middle Mouse + Shift: Random objects"); Handles.EndGUI(); }
public override void OnInspectorGUI() { base.OnInspectorGUI(); if (Application.isPlaying) { return; } CollectionGroup myTarget = (CollectionGroup)target; DrawChildren(myTarget); EditorGUILayout.Space(); //Children EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("All Children"); if (GUILayout.Button("<-", GUILayout.ExpandWidth(false))) { myTarget.Step(-1); } if (GUILayout.Button("->", GUILayout.ExpandWidth(false))) { myTarget.Step(1); } if (GUILayout.Button("?", GUILayout.ExpandWidth(false))) { myTarget.Randomize(); } EditorGUILayout.EndHorizontal(); //Scrolling if (Event.current.type == EventType.ScrollWheel) { myTarget.Step(CollectionUtility.GetScrollStep(Event.current)); } }
public override void UpdateCollection() { if (Application.isPlaying) { return; } //Reset index if prefab mode if (!CollectionUtility.IsPrefabMode() && isPrefab) { isPrefab = false; selectedIndex = -1; ClearChildrenPrefabs(); } //Auto Selection if (spawnedObject == null && prefabs != null && PrefabCount > 0) { if (selectedIndex == -1) { SelectInitial(); } else { Select(selectedIndex); } } //Detect no prefabs if (spawnedObject == null && (prefabs == null || prefabs.Count == 0)) { ClearChildrenPrefabs(); spawnedObject = null; selectedIndex = -1; EditorUtility.SetDirty(this); } //Out of range if (selectedIndex != -1 && selectedIndex >= PrefabCount) { Select(PrefabCount - 1); } else { //Detect change in current prefab bool isSamePrefab = true; #if UNITY_EDITOR if (spawnedObject != null) { isSamePrefab = PrefabUtility.GetCorrespondingObjectFromSource(spawnedObject) == prefabs[selectedIndex]; } #endif if (selectedIndex != -1 && !isSamePrefab) { Select(selectedIndex); } } }