public void Show() { canvasObject.SetActive(true); foreach (var obj in otherCanvasObjects) { obj.SetActive(false); } //既存のボタン削除 for (int i = 0; i < content.childCount; i++) { var child = content.GetChild(i); Destroy(child.gameObject); } //シーン内のAnimatorかAnimationコンポーネントを持ってるオブジェクトを列挙 var animatorObjects = GameObject.FindObjectsOfType <Animator>(); var animationObjects = GameObject.FindObjectsOfType <Animation>(); HashSet <GameObject> objects = new HashSet <GameObject>(); foreach (var obj in animatorObjects) { objects.Add(obj.gameObject); } foreach (var obj in animationObjects) { objects.Add(obj.gameObject); } //ボタン作成 foreach (var obj in objects) { var node = Instantiate(prefabNodeSelectObject, content, false); NodeUIButton nodeUIButton = node.GetComponent <NodeUIButton>(); var target = obj; nodeUIButton.text.text = target.name; nodeUIButton.button.onClick.AddListener(() => { Selection.objects = new Object[1] { target }; Hide(); }); } }
public void Show() { var rootObject = wAnimationWindowHelper.GetAnimationWindowCurrentRootGameObject(); if (rootObject == null) { Debug.Log("Maybe not selected any object in Animation Window."); return; } canvasObject.SetActive(true); foreach (var obj in otherCanvasObjects) { obj.SetActive(false); } //既存のボタン削除 for (int i = 0; i < content.childCount; i++) { var child = content.GetChild(i); if (child.name != "AddAnimation") //アニメーション追加ボタンは削除しない { Destroy(child.gameObject); } } AnimationClip[] clips = AnimationUtility.GetAnimationClips(rootObject); //ボタン作成 for (int i = 0; i < clips.Length; i++) { var node = Instantiate(prefabNodeSelectAnimation, content, false); NodeUIButton nodeUIButton = node.GetComponent <NodeUIButton>(); var clip = clips[i]; nodeUIButton.text.text = clip.name; nodeUIButton.button.onClick.AddListener(() => { wAnimationWindowHelper.SetActiveAnimationClip(clip); Hide(); }); } }