Esempio n. 1
0
 public void AssignColorGroup(ColorGroup colorGroup)
 {
     if (Selection.gameObjects.Length > 0)
     {
         foreach (GameObject g in Selection.gameObjects)
         {
             #if UNITY_2018_3_OR_NEWER
             var prefab = PrefabUtility.GetOutermostPrefabInstanceRoot(Selection.activeGameObject);
             #else
             var prefab = PrefabUtility.FindPrefabRoot(Selection.activeGameObject);
             #endif
             if (prefab && AssetDatabase.Contains(prefab))
             {
                 Theme.AssignColorGroup(colorGroup, prefab);
                 EditorUtility.SetDirty(prefab);
             }
             else
             {
                 Theme.AssignColorGroup(colorGroup, g);
                 EditorUtility.SetDirty(g);
             }
         }
     }
     else
     {
         var objects = SceneManager.GetActiveScene().GetRootGameObjects();
         foreach (GameObject g in objects)
         {
             Theme.AssignColorGroup(colorGroup, g);
             EditorUtility.SetDirty(g);
         }
     }
 }