public override VisualElement CreateInspectorGUI() { // display the UIElements assets loaded in OnEnable root.Clear(); tree.CloneTree(root); // Add a callback to the inspector button to open a new LevelEditorWindow with the inspectedLevel as an arg Button editButton = root.Q <Button>(name = "open-editor-button"); editButton.clickable.clicked += () => LevelEditorWindow.EditLevel(inspectedLevel); // fill the info labels width = inspectedLevel.gridWidth; height = inspectedLevel.gridHeight; levelName = inspectedLevel.levelName; root.Q <Label>("width-value").text = width.ToString(); root.Q <Label>("height-value").text = height.ToString(); root.Q <Label>("name-value").text = levelName; // display the grid CreateGrid(); // return root to display it return(root); }
public static bool OpenEditor(int instanceId, int line) { LevelScriptableObject level = EditorUtility.InstanceIDToObject(instanceId) as LevelScriptableObject; if (level != null) { LevelEditorWindow.EditLevel(level); return(true); } return(false); }