Esempio n. 1
0
    void CreateVisualTree()
    {
        var visualTree = AssetDatabase.LoadAssetAtPath <VisualTreeAsset>("Assets/Editor/EditorComponents/ObjectManager.uxml");
        var styleSheet = AssetDatabase.LoadAssetAtPath <StyleSheet>("Assets/Editor/LevelEditorWindow.uss");

        objectEditor = visualTree.CloneTree();

        objectPropertiesContainer = objectEditor.Q <Box>("addObjectContainer");
        objectTypeContainer       = objectEditor.Q <Box>("addObjectTypeContainer");

        ObjectNameTextField = objectPropertiesContainer.Q <TextField>("objectNameTextField");
        AddObjectButton     = objectPropertiesContainer.Q <Button>("addObjectNameButton");
        AddObjectButton.RegisterCallback <MouseUpEvent>(AddNewObject);
        SaveObjectButton = objectPropertiesContainer.Q <Button>("saveObjectNameButton");
        SaveObjectButton.RegisterCallback <MouseUpEvent>(SaveEditedObject);

        ObjectTypeLayer = new PopupField <string>("Select Type Of Object", ObjectTypes, 0);
        ObjectTypeLayer.RegisterValueChangedCallback(UpdateOnTypeSelection);
        ObjectTypeLayer.Focus();
        //ObjectTypeLayer.AddToClassList("height-width-slider");
        objectTypeContainer.Add(ObjectTypeLayer);

        objectEditContainer          = objectEditor.Q <Box>("editObjectContainer");
        objectEditSelectionContainer = objectEditor.Q <Box>("editObjectSelectionContainer");

        objectSelectionField = new ObjectField {
            objectType = typeof(SpriteObject)
        };
        objectSelectionField.RegisterValueChangedCallback(UpdateOnObjectSelection);

        //objectPropertiesContainer.Add(ObjectTypeLayer);
        objectEditContainer.Add(objectSelectionField);
        objectEditContainer.Add(objectEditSelectionContainer);
    }