static bool IsSnapsPrototypePrefab(GameObject targetGo) { PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(targetGo); if (prefabType != PrefabAssetType.Regular && prefabType != PrefabAssetType.Variant) { return(false); } Regex reg = new Regex(@"_snaps[0-9][0-9][0-9].prefab$"); string PrefabPath = SwapTool.GetOriginalPrefabPath(targetGo).ToLower(); if (PrefabPath.Contains(PrefabRoot.ToLower()) || PrefabPath.Contains(GenSnapsPrototypePath.ToLower())) { if (reg.IsMatch(PrefabPath)) { return(true); } } return(false); }
static bool IsSnapsHDPrefab(GameObject targetGo) { PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(targetGo); if (prefabType != PrefabAssetType.Regular && prefabType != PrefabAssetType.Variant) { return(false); } if (IsSnapsPrototypePrefab(targetGo) == false) { Regex reg = new Regex(@"_snaps[0-9][0-9][0-9].prefab$"); string PrefabPath = SwapTool.GetOriginalPrefabPath(targetGo).ToLower(); string SnapsPrototypePath = SwapTool.PrefabPath.Replace(Application.dataPath, string.Empty).ToLower(); if (reg.IsMatch(PrefabPath) && !PrefabPath.Contains(SnapsPrototypePath)) { return(true); } } return(false); }
static void ShowSwapTool() { SwapTool SwapWindow = EditorWindow.GetWindow <SwapTool>(); SwapWindow.titleContent.text = "Asset Swap Tool"; Vector2 windowSize = new Vector2(400, 380); SwapWindow.minSize = windowSize; SwapWindow.maxSize = windowSize; SwapWindow.Show(); if (Directory.Exists(PrefabPath)) { groupEnabled = true; } else { groupEnabled = false; } }
static bool SetUnpackPrefab(GameObject target) { if (target == null) { return(false); } if (IsSnapsHDPrefab(target)) { return(false); } string PrefabPath = SwapTool.PrefabPath; Dictionary <string, string> ObjInfo = SwapTool.GetObjectMatchingTable(PrefabPath); string targetPrefabPath = Path.GetFileNameWithoutExtension(SwapTool.GetOriginalPrefabPath(target).ToLower()); if (ObjInfo.ContainsKey(targetPrefabPath)) { return(false); } PrefabAssetType prefabType = PrefabUtility.GetPrefabAssetType(target); if (prefabType == PrefabAssetType.Regular || prefabType == PrefabAssetType.Variant) { if (target.transform.childCount == 0 && target.GetComponent <MeshRenderer>() == null) { return(false); } PrefabUtility.UnpackPrefabInstance(target, PrefabUnpackMode.OutermostRoot, InteractionMode.AutomatedAction); } return(true); }