public void LoadObjectsButtons(ObjectCategory filter = 0) { foreach (Transform child in objectList.transform) { GameObject.Destroy(child.gameObject); } foreach (var so in SessionManager.Instance.sceneObjects.objectSet) { ISceneObject isc = (ISceneObject)so; if (isc == null) { continue; } UISceneObject uisc = isc.GetUISceneObject(); if (filter != ObjectCategory.All && filter != uisc.category) { continue; } GameObject soButton = Instantiate(sceneObjectUiPrefab, objectList); Button button = soButton.GetComponent <Button>(); soButton.GetComponentInChildren <TextMeshProUGUI>()?.SetText(so.GetDisplayName()); button.onClick.AddListener(() => { SetPlacementObject(isc); }); button.targetGraphic.color = uisc.color; soButton.transform.Find("Icon").GetComponent <Image>().sprite = uisc.icon; } foreach (var so in SessionManager.Instance.sceneObjects.prefabSet) { ISceneObject isc = (ISceneObject)so; if (isc == null) { continue; } UISceneObject uisc = isc.GetUISceneObject(); if (filter != ObjectCategory.All && filter != ObjectCategory.UserPrefabs && filter != uisc.category) { continue; } GameObject soButton = Instantiate(sceneObjectUiPrefab, objectList); Button button = soButton.GetComponent <Button>(); soButton.GetComponentInChildren <TextMeshProUGUI>()?.SetText(so.GetDisplayName()); button.onClick.AddListener(() => { SetPlacementObject(isc); }); button.targetGraphic.color = Color.yellow; soButton.transform.Find("Icon").GetComponent <Image>().sprite = uisc.icon; } }