static void DrawGizmoForObiWorld(ObiWorld world, GizmoType gizmoType) { if ((gizmoType & GizmoType.Selected) != 0) { Gizmos.color = new Color(0,0,1,0.05f); DrawDBVH(world, world.dynamicBVH.Root); } }
private static void DrawDBVH(ObiWorld world, DBVH.DBVHNode node) { if (node == null) return; if (node.content == null){ DrawDBVH(world,world.dynamicBVH.GetLeftChild(node)); DrawDBVH(world,world.dynamicBVH.GetRightChild(node)); } Gizmos.DrawCube(node.bounds.center,node.bounds.size); }
public void Initialize(ObiWorld world) { this.world = world; if (this.world != null){ // Remove any existing actors for the same world: ObiActor[] actors = GetComponents<ObiActor>(); for(int i = 0; i < actors.Length;i++){ if (actors[i] != this && actors[i].world == this.world) GameObject.DestroyImmediate(actors[i]); } this.world.AddObject(gameObject); } }
public void OnEnable() { world = (ObiWorld) target; }
void OnGUI() { GenerateStyles(); worlds = GameObject.FindObjectsOfType<ObiWorld>(); GUILayout.BeginHorizontal(); GUILayout.BeginVertical(); EditorGUILayout.LabelField("Worlds in the scene:",EditorStyles.boldLabel); worldScrollPosition = GUILayout.BeginScrollView(worldScrollPosition,"ProjectBrowserPreviewBg"); if (worlds != null) foreach(ObiWorld world in worlds){ if (GUILayout.Button(world.name,(selectedWorld == world)?selectedLabelStyle:unselectedLabelStyle)){ selectedWorld = world; } } GUILayout.EndScrollView(); GUILayout.EndVertical(); if (selectedWorld == null){ EditorGUILayout.HelpBox("No Obi World selected.",MessageType.Info); }else{ GUILayout.BeginVertical(); EditorGUILayout.LabelField("GameObjects in "+selectedWorld.name+":",EditorStyles.boldLabel); worldMembersScrollPosition = GUILayout.BeginScrollView(worldMembersScrollPosition); foreach(GameObject obj in selectedWorld.Objects){ if (GUILayout.Button(obj.name,GUI.skin.label)){ Selection.activeGameObject = obj; } } GUILayout.EndScrollView(); if (GUILayout.Button(new GUIContent("Add selected objects",addIcon,"Adds all currently selected game objects to the Obi World."),GUILayout.Height(50))){ foreach(GameObject obj in Selection.gameObjects){ ObiActor a = obj.AddComponent<ObiActor>(); a.Initialize(selectedWorld); } } if (GUILayout.Button(new GUIContent("Remove selected objects",removeIcon,"Removes all currently selected game objects from the Obi World."),GUILayout.Height(50))){ foreach(GameObject obj in Selection.gameObjects){ // Get the ObiActor for this world and destroy it. ObiActor[] actors = obj.GetComponents<ObiActor>(); for(int i = 0; i < actors.Length; i++){ if (actors[i].world == selectedWorld){ GameObject.DestroyImmediate(actors[i]); } } } } GUILayout.EndVertical(); } GUILayout.EndHorizontal(); }