private void CreateFlowerButtons(List <Flower> flowers) { GridObjectCollection buttonCollection = commandPanel.GetComponentInChildren <GridObjectCollection>(); ScrollingObjectCollection buttonCollectionScroll = commandPanel.GetComponentInChildren <ScrollingObjectCollection>(); float n = 0.0f; foreach (Flower flower in flowers) { GameObject button = GameObject.Instantiate <GameObject>(flowerButtonPrefab, buttonCollection.transform.position, Quaternion.identity); button.transform.parent = buttonCollection.transform; FlowerProperties buttonFlowerProperties = button.GetComponentInChildren <FlowerProperties>(); buttonFlowerProperties.Name = flower.Name; buttonFlowerProperties.PlantingRadius = flower.PlantingRadius; TextMeshPro[] buttonText = button.GetComponentsInChildren <TextMeshPro>(); foreach (TextMeshPro text in buttonText) { text.text = flower.Name; } Interactable buttonInteractable = button.GetComponentInChildren <Interactable>(); buttonInteractable.OnClick.AddListener(() => SelectRadius(button)); n += 0.05f; } buttonCollection.UpdateCollection(); buttonCollectionScroll.UpdateContent(); buttonCollectionScroll.gameObject.SetActive(false); }
public override void OnInspectorGUI() { serializedObject.Update(); using (var check = new EditorGUI.ChangeCheckScope()) { EditorGUILayout.Space(); DrawGeneralSection(); DrawPaginationSection(); DrawAdvancedSettingsSection(); DrawEventsSection(); serializedObject.ApplyModifiedProperties(); if (check.changed) { scrollView.UpdateContent(); foreach (var renderer in scrollView.GetComponentsInChildren <Renderer>(true)) { if (renderer.sharedMaterial == null) { continue; } if (!CheckForStandardShader(renderer)) { Debug.LogWarning(renderer.name + " has a renderer that is not using " + StandardShaderUtility.MrtkStandardShaderName + ". This will result in unexpected results with ScrollingObjectCollection."); } } } } }