private void StopPreview() { if (!m_PreviewID.Empty()) { VideoUtil.StopPreview(m_PreviewID); } m_PlayingClip = null; m_PreviewID = kEmptyGUID; }
/// <summary> /// Sets the ID used for the name. /// </summary> /// <param name="value">GUID value to set.</param> public void SetFileGUID(GUID value) { if (value.Empty()) { value = GUID.Generate(); } m_GUID = value; }
public static void ForceReserializeAssets(IEnumerable <string> assetPaths, ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) { if (EditorApplication.isPlaying) { throw new Exception("AssetDatabase.ForceReserializeAssets cannot be used when in play mode"); } HashSet <GUID> guidList = new HashSet <GUID>(); foreach (string path in assetPaths) { if (path == "") { continue; } if (path.Equals("Assets") || path.Equals("Packages")) { continue; } if (AssetDatabase.IsPackagedAssetPath(path)) { continue; } if (InternalEditorUtility.IsUnityExtensionRegistered(path)) { continue; } GUID guid = new GUID(AssetPathToGUID(path)); if (!guid.Empty()) { guidList.Add(guid); } else { if (File.Exists(path)) { Debug.LogWarningFormat("Cannot reserialize file \"{0}\": the file is not in the AssetDatabase. Skipping.", path); } else { Debug.LogWarningFormat("Cannot reserialize file \"{0}\": the file does not exist. Skipping.", path); } } } GUID[] guids = new GUID[guidList.Count]; guidList.CopyTo(guids); ReSerializeAssetsForced(guids, options); }
private void ValidateGUID() { if (m_GUID.Empty()) { // We can't use ISerializationCallbackReceiver because we will hit into Script serialization errors m_GUID = new GUID(m_SpriteID); if (m_GUID.Empty()) { m_GUID = GUID.Generate(); m_SpriteID = m_GUID.ToString(); } } }
public static void ForceReserializeAssets(IEnumerable <string> assetPaths, ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) { if (EditorApplication.isPlaying) { throw new Exception("AssetDatabase.ForceReserializeAssets cannot be used when in play mode"); } HashSet <GUID> guidList = new HashSet <GUID>(); foreach (string path in assetPaths) { if (path == "") { continue; } if (InternalEditorUtility.IsUnityExtensionRegistered(path)) { continue; } bool rootFolder, readOnly; bool validPath = GetAssetFolderInfo(path, out rootFolder, out readOnly); if (validPath && (rootFolder || readOnly)) { continue; } GUID guid = GUIDFromAssetPath(path); if (!guid.Empty()) { guidList.Add(guid); } else { if (File.Exists(path)) { Debug.LogWarningFormat("Cannot reserialize file \"{0}\": the file is not in the AssetDatabase. Skipping.", path); } else { Debug.LogWarningFormat("Cannot reserialize file \"{0}\": the file does not exist. Skipping.", path); } } } GUID[] guids = new GUID[guidList.Count]; guidList.CopyTo(guids); ForceReserializeAssets(guids, options); }
public static void ForceReserializeAssets(IEnumerable <string> assetPaths, ForceReserializeAssetsOptions options = ForceReserializeAssetsOptions.ReserializeAssetsAndMetadata) { if (EditorApplication.isPlaying) { throw new Exception("AssetDatabase.ForceReserializeAssets cannot be used when in play mode"); } HashSet <GUID> hashSet = new HashSet <GUID>(); foreach (string current in assetPaths) { if (!(current == "")) { if (!current.Equals("Assets") && !current.Equals("Packages")) { if (!AssetDatabase.IsPackagedAssetPath(current)) { if (!InternalEditorUtility.IsUnityExtensionRegistered(current)) { GUID item = new GUID(AssetDatabase.AssetPathToGUID(current)); if (!item.Empty()) { hashSet.Add(item); } else if (File.Exists(current)) { Debug.LogWarningFormat("Cannot reserialize file \"{0}\": the file is not in the AssetDatabase. Skipping.", new object[] { current }); } else { Debug.LogWarningFormat("Cannot reserialize file \"{0}\": the file does not exist. Skipping.", new object[] { current }); } } } } } } GUID[] array = new GUID[hashSet.Count]; hashSet.CopyTo(array); AssetDatabase.ReSerializeAssetsForced(array, options); }
public static bool TryParse(string hex, out GUID result) { GUID.HexToGUIDInternal(hex, out result); return(!result.Empty()); }