/*public static bool IsModelProcessed(string path) * { * if (lstorage == null) lstorage = GetLocalStorage(); * var listProcessed = lstorage.modifiedAssetPathList; * return listProcessed.Contains(path); * }*/ public static void MarkModelProcessed(string path, bool enabled) { if (lstorage == null) { lstorage = GetLocalStorage(); } if (gstorage == null) { gstorage = GetGlobalStorage(); } if (enabled) { int gid = gstorage.modifiedAssetPathList.IndexOf(path); if (gid < 0) { return; } int hash = gstorage.CalculatePaddingHash(gid); while (gstorage.modifiedAssetPaddingHash.Count <= gid) { gstorage.modifiedAssetPaddingHash.Add(0); } gstorage.modifiedAssetPaddingHash[gid] = hash; int id = lstorage.modifiedAssetPathList.IndexOf(path); if (id < 0) { lstorage.modifiedAssetPathList.Add(path); id = lstorage.modifiedAssetPathList.Count - 1; } while (lstorage.modifiedAssetPaddingHash.Count <= id) { lstorage.modifiedAssetPaddingHash.Add(0); } lstorage.modifiedAssetPaddingHash[id] = hash; EditorUtility.SetDirty(gstorage); EditorSceneManager.MarkAllScenesDirty(); } else { int id = lstorage.modifiedAssetPathList.IndexOf(path); if (id >= 0) { lstorage.modifiedAssetPathList.RemoveAt(id); if (lstorage.modifiedAssetPaddingHash.Count > id) { lstorage.modifiedAssetPaddingHash.RemoveAt(id); } } } EditorUtility.SetDirty(lstorage); }
static ftLocalStorage GetLocalStorage() { if (lstorage != null) { return(lstorage); } lstorage = AssetDatabase.LoadAssetAtPath("Assets/Bakery/ftLocalStorage.asset", typeof(ftLocalStorage)) as ftLocalStorage; if (lstorage == null) { Debug.Log("Created Bakery LocalStorage"); lstorage = ScriptableObject.CreateInstance <ftLocalStorage>(); AssetDatabase.CreateAsset(lstorage, "Assets/Bakery/ftLocalStorage.asset"); AssetDatabase.SaveAssets(); } return(lstorage); }
static void CreateGlobalStorageAsset() { if (gstorage == null) { gstorage = GetGlobalStorage(); } if (lstorage == null) { lstorage = GetLocalStorage(); } var listToProccess = gstorage.modifiedAssetPathList; var listToProcessHash = gstorage.modifiedAssetPaddingHash; var listProcessed = lstorage.modifiedAssetPathList; var listProcessedHash = lstorage.modifiedAssetPaddingHash; for (int i = 0; i < listToProccess.Count; i++) { int localID = listProcessed.IndexOf(listToProccess[i]); if (localID >= 0) { if (listToProcessHash.Count > i) { int globalPaddingHash = listToProcessHash[i]; if (listProcessedHash.Count > localID) { int localPaddingHash = listProcessedHash[localID]; if (globalPaddingHash == localPaddingHash) { continue; } } } else { // Hash is not initialized = legacy continue; } } #if UNITY_2017_1_OR_NEWER var importer = AssetImporter.GetAtPath(listToProccess[i]) as ModelImporter; if (importer != null) { var props = importer.extraUserProperties; int propID = -1; for (int p = 0; p < props.Length; p++) { if (props[p].Substring(0, 7) == "#BAKERY") { propID = p; break; } } if (propID >= 0) { continue; // should be fine without additional reimport - metadata is always loaded with model } } #endif var asset = AssetDatabase.LoadAssetAtPath(listToProccess[i], typeof(GameObject)) as GameObject; if (asset == null) { continue; } if (asset.tag == "BakeryProcessed") { continue; // legacy } //if (asset.tag != "BakeryProcessed") AssetDatabase.ImportAsset(list[i], ImportAssetOptions.ForceUpdate); Debug.Log("Reimporting to adjust UVs: " + listToProccess[i]); AssetDatabase.ImportAsset(listToProccess[i], ImportAssetOptions.ForceUpdate); } }