Skip to content

Commit

Permalink
1.3.7
Browse files Browse the repository at this point in the history
Backported function to mid release 2020.3 and 2021.1 SaveAssetIfDirty removed.
  • Loading branch information
soupday committed Aug 16, 2022
1 parent ea78049 commit 321a67c
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

### v 1.3.7
- Backported function to mid release 2020.3 and 2021.1 SaveAssetIfDirty removed.
- GUIDFromAssetPath Unity 2019 fix for built-in pipeline.

### v 1.3.6
- Runtime components Build fix.

Expand Down
8 changes: 3 additions & 5 deletions Editor/AnimRetargetGUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public static class AnimRetargetGUI
private static Vector3 animatorPosition;
private static Quaternion animatorRotation;


// Function variables
const string emptyGuid = "00000000000000000000000000000000";
// Function variables
public const string ANIM_FOLDER_NAME = "Animations";
public const string RETARGET_FOLDER_NAME = "Retargeted";
public const string RETARGET_SOURCE_PREFIX = "Imported";
Expand Down Expand Up @@ -1252,13 +1250,13 @@ static string GenerateClipAssetPath(AnimationClip originalClip, GameObject fbxAs

if (!overwrite)
{
if (!AssetDatabase.GUIDFromAssetPath(assetPath).ToString().Equals(emptyGuid))
if (!Util.AssetPathIsEmpty(assetPath))
{
for (int i = 0; i < 999; i++)
{
string extension = string.Format("{0:000}", i);
assetPath = Path.Combine(animFolder, animName + "_" + extension + ".anim");
if (AssetDatabase.GUIDFromAssetPath(assetPath).ToString().Equals(emptyGuid)) break;
if (Util.AssetPathIsEmpty(assetPath)) break;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Editor/Pipeline.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public enum MaterialQuality { None, Default, High, Baked }

public static class Pipeline
{
public const string VERSION = "1.3.6";
public const string VERSION = "1.3.7";

#if HDRP_10_5_0_OR_NEWER
// version
Expand Down
16 changes: 10 additions & 6 deletions Editor/QuickAnimProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public static bool ATValidateInitAssetProcessingForce()
return IsModel(Selection.activeObject);
}

private static string emptyGuid = "00000000000000000000000000000000";
private static string[] modelFileExtensions = new string[] { ".fbx", ".blend", ".dae", ".obj" };

public static bool IsModel(Object o)
Expand Down Expand Up @@ -224,16 +223,14 @@ private static void WriteAnimationClip(Object o, AnimationClip animationClip)
string animName = SanitizeName(o.name + " - " + animationClip.name);
string fullOutputPath = workingDirectory + "/" + animName + ".anim";

if (!AssetDatabase.GUIDFromAssetPath(fullOutputPath).ToString().Equals(emptyGuid))

if (AssetPathIsEmpty(fullOutputPath))
{
for (int i = 0; i < 999; i++)
{
string extension = string.Format("{0:000}", i);
fullOutputPath = workingDirectory + "/" + animName + "." + extension + ".anim";
if (AssetDatabase.GUIDFromAssetPath(fullOutputPath).ToString().Equals(emptyGuid))
{
break;
}
if (AssetPathIsEmpty(fullOutputPath)) break;
}
}
Debug.Log("Writing Asset: " + fullOutputPath);
Expand All @@ -247,4 +244,11 @@ private static string SanitizeName(string inputName)
Regex r = new Regex(string.Format("[{0}]", Regex.Escape(invalid)));
return r.Replace(inputName, " - ");
}

public static bool AssetPathIsEmpty(string assetPath)
{
const string emptyGuid = "00000000000000000000000000000000";

return AssetDatabase.AssetPathToGUID(assetPath).Equals(emptyGuid);
}
}
8 changes: 8 additions & 0 deletions Editor/Util.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using Object = UnityEngine.Object;

namespace Reallusion.Import
{
Expand Down Expand Up @@ -895,6 +896,13 @@ public static void FindSceneObjects(Transform root, string search, List<GameObje
}
}

public static bool AssetPathIsEmpty(string assetPath)
{
const string emptyGuid = "00000000000000000000000000000000";

return AssetDatabase.AssetPathToGUID(assetPath).Equals(emptyGuid);
}

public static void LogInfo(string message)
{
if (LOG_LEVEL >= 2)
Expand Down
14 changes: 12 additions & 2 deletions Runtime/PhysicsSettingsStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,11 @@ public static PhysicsSettingsStore SaveColliderSettings(ColliderManager collider
{
settings.colliderSettings = workingSettings;
EditorUtility.SetDirty(settings);
#if UNITY_2021_2_OR_NEWER
AssetDatabase.SaveAssetIfDirty(AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(settings)));
#else
AssetDatabase.SaveAssets();
#endif

Debug.Log("Collider settings stored.");

Expand Down Expand Up @@ -161,8 +165,14 @@ public static PhysicsSettingsStore SaveClothSettings(WeightMapper weightMapper)
settings.clothSettings.Add(s);
}
}

EditorUtility.SetDirty(settings);
#if UNITY_2021_2_OR_NEWER
AssetDatabase.SaveAssetIfDirty(AssetDatabase.GUIDFromAssetPath(AssetDatabase.GetAssetPath(settings)));
#else
AssetDatabase.SaveAssets();
#endif


Debug.Log("Cloth physics settings stored.");

Expand Down Expand Up @@ -252,7 +262,7 @@ private static bool TryGetSavedIndex(List<PhysicsSettings> savedClothSettings, P
return true;

return false;
}
}
#endif
}
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "com.soupday.cc3_unity_tools",
"version": "1.3.6",
"version": "1.3.7",
"displayName": "CC/iC Unity Tools HDRP",
"description": "Unity importer for Character Creator 3 & 4 and iClone 7 and 8.",
"unity": "2020.3",
Expand Down

0 comments on commit 321a67c

Please sign in to comment.