Not sure what i had typed in wrongly but the debug log doesn’t print anything onto the console regardless whether the Task List open up or when the button has been pressed
Here is my code thus far
public class TaskListEditor : EditorWindow //Inherit from SCriptable Object and used to create windows
{
VisualElement _container;
public const string path = "Assets/TaskList/Editor/EditorWindow/";
TextField _taskText;
Button _addTaskButton;
ScrollView _taskListScrollView;
[MenuItem("TaskListUI/TaskList")]
private static void ShowWindow()
{
TaskListEditor window = GetWindow<TaskListEditor>();
window.titleContent = new GUIContent("TaskList");
}
private void CreateGUI() //CreateGUI is called when the EditorWindow's rootVisualElement is ready to be populated.
{
_container = rootVisualElement;
VisualTreeAsset original = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(path + "TaskListEditor.uxml");
_container.Add(original.Instantiate());
StyleSheet styleSheet = AssetDatabase.LoadAssetAtPath<StyleSheet>(path + "TaskListEditor.uss");
_container.styleSheets.Add(styleSheet);
_taskText = _container.Q<TextField>("taskText");
_addTaskButton = _container.Q<Button>("addTaskButton");
_taskListScrollView = _container.Q<ScrollView>("taskList");
Debug.Log(_taskText);
Debug.Log(_taskListScrollView);
}
}
Also here is the image of the UI Builder