Пример #1
0
    public void OnEnable()
    {
        // Each editor window contains a root VisualElement object
        VisualElement root = rootVisualElement;
        // Import UXML
        var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/LevelEditorWindow.uxml");
        // A stylesheet can be added to a VisualElement.
        // The style will be applied to the VisualElement and all of its children.
        var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/LevelEditorWindow.uss");

        root.styleSheets.Add(styleSheet);

        //Get the visual editor tree
        levelEditorWindowContent = visualTree.CloneTree();
        root.Add(levelEditorWindowContent);

        //Get the container for the window content
        container = levelEditorWindowContent.Q <Box>("mainContentContainer");

        //Get the menu buttons
        //Register Click events for the menu buttons
        string[] menuButtonNames = { "menu-button-asset", "menu-button-object", /*"menu-button-player", "menu-button-enemy",*/ "menu-button-level" };
        foreach (string mbname in menuButtonNames)
        {
            Button mb = levelEditorWindowContent.Q <Button>(mbname);
            menuButtons.Add(mb);
            mb.RegisterCallback <MouseUpEvent, Button>(OnMenuButtonClick, mb);
        }

        //Add AssetManager by default
        assetManagerContent = AssetManager.GetAssetManager();
        //AssetManagerContent.visible = false;
        container.Add(assetManagerContent);

        objectManagerContent = ObjectManager.GetObjectManager();

        //playerEditorContent = PlayerEditor.GetPlayerEditor();
        //playerEditorContent.visible = false;
        //container.Add(playerEditorContent);

        //enemyEditorContent = EnemyEditor.GetEnemyEditor();
        LevelEditor.Destroy();
        levelEditorContent = LevelEditor.GetLevelEditor();
    }