-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathPrefabUtils.cs
More file actions
30 lines (27 loc) · 754 Bytes
/
PrefabUtils.cs
File metadata and controls
30 lines (27 loc) · 754 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEngine.UI;
using System.Linq;
public class PrefabUtils
{
[MenuItem("Utilities/Prefabs/Revert All Selected", true)]
static bool ValidateRevertSelectedPrefabs()
{
return Selection.gameObjects.Count(g => PrefabUtility.GetPrefabParent(g)) > 0;
}
[MenuItem("Utilities/Prefabs/Revert All Selected")]
static void RevertSelectedPrefabs()
{
GameObject[] selectedGOs = Selection.gameObjects;
Undo.RecordObjects(selectedGOs, "Revert All Selected");
for(int i = 0; i < selectedGOs.Length; i++)
{
if (PrefabUtility.GetPrefabParent(selectedGOs[i]))
{
PrefabUtility.RevertPrefabInstance(selectedGOs[i]);
EditorUtility.SetDirty(selectedGOs[i]);
}
}
}
}