// Called at 100fps. void Update() { if (!DomInspector.DocumentsAvailable) { // Reload: DomInspector.GetDocuments(true); } }
void OnGUI() { // Doc dropdown: DocumentEntry entry = DomInspector.DocumentDropdown(Entry); if (entry == null) { return; } ReflowDocument reflowDoc = entry.Document as ReflowDocument; if (reflowDoc == null) { Entry = entry; PowerUIEditor.HelpBox("Not a suitable document (it can't be styled)."); return; } if (Entry != entry) { // Changed! Entry = entry; ComputedNodeData = null; // Rebuild list of stylesheets. RebuildSheets(reflowDoc); } // Draw a refresh button: if (GUILayout.Button("Refresh sheets")) { // Refresh now: RebuildSheets(reflowDoc); } // Draw dropdown list now! int selectedIndex = EditorGUILayout.Popup(SheetIndex, SheetNames); if (selectedIndex != SheetIndex || ComputedNodeData == null) { SheetIndex = selectedIndex; try{ BuildString(reflowDoc.styleSheets[SheetIndex]); }catch (Exception e) { ComputedNodeData = "<b>Error whilst building node data</b>\r\n" + e.ToString(); } } GUILayout.Label(ComputedNodeData); }
public void RebuildSheets(ReflowDocument reflowDoc) { // List all stylesheets in the doc. int x = 1; string[] names = new string[reflowDoc.styleSheets.Count]; int i = 0; foreach (StyleSheet sheet in reflowDoc.styleSheets) { string name = sheet.href; if (name == null) { name = "Inline stylesheet " + x; x++; } names[i++] = DomInspector.ListableName(name); } SheetNames = names; }