Created
December 14, 2020 16:59
-
-
Save cr4yz/8d1fd6ee757cbd6351972aeb19c33984 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UIElements; | |
[RequireComponent(typeof(UIDocument))] | |
public class TestScript : MonoBehaviour | |
{ | |
private VisualElement _parent; | |
private void Start() | |
{ | |
var scroll = new ScrollView(); | |
scroll.style.height = 200; | |
scroll.style.backgroundColor = Color.white; | |
for(int i = 0; i < 100; i++) | |
{ | |
var el = new Label("Test Label"); | |
scroll.Add(el); | |
} | |
_parent = new VisualElement(); | |
_parent.Add(scroll); | |
GetComponent<UIDocument>().rootVisualElement.Add(_parent); | |
} | |
private void Update() | |
{ | |
if (Input.GetKeyDown(KeyCode.Q)) | |
{ | |
_parent.visible = !_parent.visible; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment