コード例 #1
0
 public void OnSelectionChange()
 {
     if (isRunning || EditorApplication.isPlayingOrWillChangePlaymode)
     {
         return;
     }
     if (Selection.objects != null &&
         Selection.objects.All(o => o is GameObject))
     {
         if (Selection.objects.Count() == 1)
         {
             var go   = Selection.objects.Single() as GameObject;
             var temp = go.transform;
             while (temp != null)
             {
                 var tc = temp.gameObject.GetComponent <TestComponent> ();
                 if (tc != null && !tc.gameObject.activeSelf)
                 {
                     renderer.SelectInHierarchy(new[] { temp.gameObject });
                     break;
                 }
                 temp = temp.parent;
             }
         }
         else if (Selection.objects.All(o => (o as GameObject).GetComponent <TestComponent> () != null))
         {
             renderer.SelectInHierarchy(Selection.objects.Select(o => o as GameObject));
             Repaint();
         }
     }
 }
コード例 #2
0
        public void OnSelectionChange()
        {
            if (isRunning || EditorApplication.isPlayingOrWillChangePlaymode)
            {
                return;
            }
            if (Selection.objects != null &&
                Selection.objects.All(o => o is GameObject) &&
                Selection.objects.All(o => (o as GameObject).GetComponent <TestComponent>() != null))
            {
                renderer.SelectInHierarchy(Selection.objects.Select(o => o as GameObject));
                Repaint();
            }

            if (Selection.activeGameObject != null && Selection.activeGameObject.transform.parent != null)
            {
                var testGO = TestManager.FindTopGameObject(Selection.activeGameObject);
                if (testGO.GetComponent <TestComponent>() != null)
                {
                    renderer.SelectInHierarchy(new[] { testGO });
                }
            }
        }