public override void Deserialize(Dictionary <string, object> elements) { if (elements.ContainsKey("BoundingBoxes")) { foreach (var box in (List <object>)elements["BoundingBoxes"]) { BoundingBoxes.Add(SPBoundingBox.Deserialize(box as Dictionary <string, object>)); } } base.Deserialize(elements); }
public override void RenderInspectorGui(ParkitectObj parkitectObj) { Event e = Event.current; scrollPos2 = EditorGUILayout.BeginScrollView(scrollPos2, "GroupBox", GUILayout.Height(100)); for (int i = 0; i < BoundingBoxes.Count; i++) { Color gui = GUI.color; if (BoundingBoxes[i] == selected) { GUI.color = Color.red; } if (GUILayout.Button("BoudingBox" + (i + 1))) { if (e.button == 1) { BoundingBoxes.RemoveAt(i); return; } if (selected == BoundingBoxes[i]) { selected = null; return; } selected = BoundingBoxes[i]; } GUI.color = gui; } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Add BoudingBox")) { BoundingBoxes.Add(new SPBoundingBox()); } string caption = "Enable Editing"; if (enableEditing) { caption = "Disable Editing"; } if (GUILayout.Button(caption)) { enableEditing = !enableEditing; } if (enableEditing) { GUILayout.Label("Hold S - Snap to 0.25"); } base.RenderInspectorGui(parkitectObj); }
public static SPBoundingBox Deserialize(Dictionary <string, object> element) { Bounds b = new Bounds(); Vector3 min = new Vector3(); if (element.ContainsKey("XMin")) { min.x = Convert.ToSingle(element["XMin"]); } if (element.ContainsKey("YMin")) { min.y = Convert.ToSingle(element["YMin"]); } if (element.ContainsKey("ZMin")) { min.z = Convert.ToSingle(element["ZMin"]); } Vector3 max = new Vector3(); if (element.ContainsKey("XMax")) { max.x = Convert.ToSingle(element["XMax"]); } if (element.ContainsKey("YMax")) { max.y = Convert.ToSingle(element["YMax"]); } if (element.ContainsKey("ZMax")) { max.z = Convert.ToSingle(element["ZMax"]); } b.min = min; b.max = max; SPBoundingBox box = new SPBoundingBox(); box.Bounds = b; return(box); }