Skip to content

Commit

Permalink
fix: prefab helper throwing error
Browse files Browse the repository at this point in the history
  • Loading branch information
rYuuk committed Jan 3, 2024
1 parent 9682b1a commit 026f3e9
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ private void Completed(object sender, CompletionEventArgs args)
}
var paramHash = AvatarCache.GetAvatarConfigurationHash(avatarLoaderSettings.AvatarConfig);
var path = $"{DirectoryUtility.GetRelativeProjectPath(args.Avatar.name, paramHash)}/{args.Avatar.name}";
if (!AvatarLoaderSettings.LoadSettings().AvatarCachingEnabled)
if (!avatarLoaderSettings.AvatarCachingEnabled)
{
SDKLogger.LogWarning(TAG, "Enable Avatar Caching to generate a prefab in the project folder.");
return;
}
var avatar = PrefabHelper.CreateAvatarPrefab(args.Metadata, path);
var avatar = PrefabHelper.CreateAvatarPrefab(args.Metadata, path, avatarConfig: avatarLoaderSettings.AvatarConfig);
if (useEyeAnimations) avatar.AddComponent<EyeAnimationHandler>();
if (useVoiceToAnim) avatar.AddComponent<VoiceHandler>();
DestroyImmediate(args.Avatar, true);
Expand Down
4 changes: 2 additions & 2 deletions Editor/Core/Scripts/Utilities/PrefabHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ public static void TransferPrefabByGuid(string guid, string newPath)
Selection.activeObject = AssetDatabase.LoadAssetAtPath(newPath, typeof(GameObject));
}

public static GameObject CreateAvatarPrefab(AvatarMetadata avatarMetadata, string path, string prefabPath = null)
public static GameObject CreateAvatarPrefab(AvatarMetadata avatarMetadata, string path, string prefabPath = null, AvatarConfig avatarConfig = null)
{
var modelFilePath = $"{path}.glb";
AssetDatabase.Refresh();
var avatarSource = AssetDatabase.LoadAssetAtPath(modelFilePath, typeof(GameObject));
var newAvatar = (GameObject) PrefabUtility.InstantiatePrefab(avatarSource);
var avatarProcessor = new AvatarProcessor();
PrefabUtility.UnpackPrefabInstance(newAvatar, PrefabUnpackMode.Completely, InteractionMode.AutomatedAction);
avatarProcessor.ProcessAvatar(newAvatar, avatarMetadata);
avatarProcessor.ProcessAvatar(newAvatar, avatarMetadata, avatarConfig);
var avatarData = newAvatar.AddComponent<AvatarData>();
avatarData.AvatarMetadata = avatarMetadata;
avatarData.AvatarId = newAvatar.name;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ MonoBehaviour:
UseHands: 0
UseDracoCompression: 0
UseMeshOptCompression: 0
Shader: {fileID: 0}
Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0}
ShaderProperties:
- TextureChannel: 0
PropertyName: _MainTex
- TextureChannel: 1
PropertyName: _BumpMap
- TextureChannel: 2
PropertyName:
PropertyName: _MetallicGlossMap
- TextureChannel: 3
PropertyName:
PropertyName: _EmissionMap
- TextureChannel: 4
PropertyName:
PropertyName: _OcclusionMap
MorphTargets:
- Oculus Visemes
4 changes: 2 additions & 2 deletions Runtime/Core/Scripts/Operations/AvatarProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ private void RenameChildMeshes(GameObject avatar, AvatarConfig avatarConfig = nu

renderer.name = $"{RENDERER_PREFIX}_{assetName}";
renderer.sharedMaterial.name = $"{MATERIAL_PREFIX}_{assetName}";
var textureByPropertyName = SetTextures(renderer, assetName, avatarConfig);
var textureByPropertyName = SetTextures(renderer, assetName);
SetShader(renderer, avatarConfig, textureByPropertyName);
SetMeshName(renderer, assetName);
}
Expand All @@ -206,7 +206,7 @@ private void RenameChildMeshes(GameObject avatar, AvatarConfig avatarConfig = nu
/// <param name="assetName">Name of the asset.</param>
/// <param name="avatarConfig"></param>
/// <remarks>Naming convention is 'Avatar_PropertyName_AssetName'. This makes it easier to view them in profiler</remarks>
private Dictionary<TextureChannel, Texture> SetTextures(Renderer renderer, string assetName, AvatarConfig avatarConfig = null)
private Dictionary<TextureChannel, Texture> SetTextures(Renderer renderer, string assetName)
{
var texturesByPropertyName = new Dictionary<TextureChannel, Texture>();

Expand Down

0 comments on commit 026f3e9

Please sign in to comment.