コード例 #1
0
        private void OnTreeSelectionChanged(object sender, TreeSelectionArgs <ILevelEditorObject> e)
        {
            if (!selectedThroughObjectManager)
            {
                selectedThroughUI            = true;
                selectedThroughObjectManager = false;
            }

            if (realLevelEditor != null)
            {
                realLevelEditor.Selection.SetSelection(e.New);
            }
        }
コード例 #2
0
        private void OnTreeSelectionChanged(object sender, TreeSelectionArgs <object> e)
        {
            if (e.New is LevelEditorResource resource)
            {
                if (generateAsync && creatingIcons)
                {
                    StopCoroutine(createIconsRoutine);
                }

                creatingIcons = false;
                resource      = LookupAsset(resource.TreeID);

                if (activeButtons.Count < resource.Children.Count)
                {
                    for (int i = activeButtons.Count; i < resource.Children.Count; i++)
                    {
                        GetAssetButton();
                    }
                }
                else if (activeButtons.Count > resource.Children.Count)
                {
                    for (int i = activeButtons.Count - 1; i >= resource.Children.Count; i--)
                    {
                        PoolAssetButton(activeButtons[i]);
                    }
                }

                Assert.AreEqual(activeButtons.Count, resource.Children.Count);
                for (int i = 0; i < resource.Children.Count; i++)
                {
                    activeButtons[i].Item       = resource.Children[i];
                    activeButtons[i].Label.text = resource.Children[i].Name;
#if UNITY_EDITOR
                    activeButtons[i].gameObject.name = $"{assetButtonPrefab.name} - {resource.Children[i].Name} ({resource.Children[i].ID})";
#endif

                    if (generateAsync)
                    {
                        activeButtons[i].Icon.sprite = null;
                        activeButtons[i].Icon.color  = Color.clear;
                    }
                    else
                    {
                        activeButtons[i].Icon.sprite = GetIcon(resource.Children[i], out Color iconColor);
                        activeButtons[i].Icon.color  = iconColor;
                    }
                }

                if (generateAsync)
                {
                    createIconsRoutine = StartCoroutine(GetIconsRoutine(resource.Children));
                }
            }
            else if (e.New == null)
            {
                for (int i = activeButtons.Count - 1; i >= 0; i--)
                {
                    PoolAssetButton(activeButtons[i]);
                }
            }
        }