Skip to content

Commit

Permalink
Rework reward asset bundles
Browse files Browse the repository at this point in the history
  • Loading branch information
Guerra24 committed May 23, 2024
1 parent 37d69a6 commit 26cb62c
Show file tree
Hide file tree
Showing 25 changed files with 631 additions and 112 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ MonoBehaviour:
m_Key: Avatars.Title
m_Metadata:
m_Items: []
- m_Id: 2529792431669248
m_Key: Startup.RewardAssetBundleMissing.Text
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
7 changes: 7 additions & 0 deletions Assets/Localization/Locales/Tables/Pages/Pages_en.asset
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,13 @@ MonoBehaviour:
m_Localized: Avatars
m_Metadata:
m_Items: []
- m_Id: 2529792431669248
m_Localized: 'Reward asset bundle "{0}" was not found.
Please choose a
new file'
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
7 changes: 6 additions & 1 deletion Assets/Localization/Locales/Tables/Pages/Pages_es.asset
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ MonoBehaviour:
m_Metadata:
m_Items: []
- m_Id: 581141708800
m_Localized: "No se encontr\xF3 el archivo del avatar \"{0}\".\r\nPor favor elija
m_Localized: "No se encontr\xF3 el archivo del avatar \"{0}\".\nPor favor elija
un nuevo archivo"
m_Metadata:
m_Items: []
Expand Down Expand Up @@ -75,6 +75,11 @@ MonoBehaviour:
m_Localized: Avatares
m_Metadata:
m_Items: []
- m_Id: 2529792431669248
m_Localized: "No se encontr\xF3 el paquetes de objetos para recompensas \"{0}\".\nPor
favor elija un nuevo archivo"
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,30 @@ MonoBehaviour:
m_Key: Avatar.Settings.GazeVerticalOffset.Title
m_Metadata:
m_Items: []
- m_Id: 2900653940588544
m_Key: Twitch.RewardAssetBundles.Title
m_Metadata:
m_Items: []
- m_Id: 2901165767311360
m_Key: RewardAssetBundles.Add.Title
m_Metadata:
m_Items: []
- m_Id: 2901211963375616
m_Key: RewardAssetBundles.Add.Button
m_Metadata:
m_Items: []
- m_Id: 2902103064231936
m_Key: RewardAssetBundles.Dialog.Title
m_Metadata:
m_Items: []
- m_Id: 2902120357347328
m_Key: RewardAssetBundles.Dialog.Content
m_Metadata:
m_Items: []
- m_Id: 2905186355822592
m_Key: RewardAssetBundle.Remove.Button
m_Metadata:
m_Items: []
m_Metadata:
m_Items: []
m_KeyGenerator:
Expand Down
27 changes: 27 additions & 0 deletions Assets/Localization/Locales/Tables/Settings/Settings_en.asset
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,33 @@ MonoBehaviour:
m_Localized: Gaze vertical offset
m_Metadata:
m_Items: []
- m_Id: 2900653940588544
m_Localized: Reward asset bundles
m_Metadata:
m_Items: []
- m_Id: 2901165767311360
m_Localized: Add reward asset bundle
m_Metadata:
m_Items: []
- m_Id: 2901211963375616
m_Localized: Add bundle
m_Metadata:
m_Items: []
- m_Id: 2902103064231936
m_Localized: Remove reward bundle
m_Metadata:
m_Items: []
- m_Id: 2902120357347328
m_Localized: 'Unable to remove reward bundle because reward asset "{0}" is being
used in "{1}".
Reset Item reward to default?'
m_Metadata:
m_Items: []
- m_Id: 2905186355822592
m_Localized: Remove
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
26 changes: 26 additions & 0 deletions Assets/Localization/Locales/Tables/Settings/Settings_es.asset
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,32 @@ MonoBehaviour:
m_Localized: Movimiento de la mirada
m_Metadata:
m_Items: []
- m_Id: 2901211963375616
m_Localized: Agregar paquete
m_Metadata:
m_Items: []
- m_Id: 2900653940588544
m_Localized: Paquetes de objetos para recompensas
m_Metadata:
m_Items: []
- m_Id: 2901165767311360
m_Localized: Agregar paquetes de objetos para recompensas
m_Metadata:
m_Items: []
- m_Id: 2902103064231936
m_Localized: Eliminar paquetes de objetos para recompensas
m_Metadata:
m_Items: []
- m_Id: 2902120357347328
m_Localized: "No se puede eliminar el paquete de objetos para recompensas porque
el objeto \"{0}\" est\xE1 en uso en la recompensa \"{1}\".\n\xBFReiniciar recompensa
al objeto por defecto?"
m_Metadata:
m_Items: []
- m_Id: 2905186355822592
m_Localized: Eliminar
m_Metadata:
m_Items: []
references:
version: 2
RefIds: []
11 changes: 10 additions & 1 deletion Assets/Scenes/Startup.unity
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
Status: {fileID: 1307567428}
StatusText:
MissingAvatar:
m_TableReference:
m_TableCollectionName: GUID:9da5f674f257f1547bd98558fa127135
m_TableEntryReference:
Expand All @@ -621,6 +621,15 @@ MonoBehaviour:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
MissingRewardBundle:
m_TableReference:
m_TableCollectionName: GUID:9da5f674f257f1547bd98558fa127135
m_TableEntryReference:
m_KeyId: 2529792431669248
m_Key:
m_FallbackState: 0
m_WaitForCompletion: 0
m_LocalVariables: []
references:
version: 2
RefIds: []
Expand Down
24 changes: 5 additions & 19 deletions Assets/Scripts/ApplicationPersistance.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public class AppSettings
public float AmbientIntensity { get; set; } = 0.3921569f;
[JsonConverter(typeof(ColorJsonConverter))]
public Color AmbientColor { get; set; } = Color.white;
public List<string> RewardBundles { get; } = new();
public Dictionary<Guid, RewardAssetsBundle> RewardAssetsBundles { get; } = new();
}

public enum LipSyncProfile
Expand Down Expand Up @@ -271,30 +271,16 @@ public enum AvatarBlendshapeMode
Hold, Toggle
}

public class LoadedAvatar
public class RewardAssetsBundle
{
public string Path { get; set; }

public AssetBundle Bundle { get; }
public GameObject Object { get; }

public LoadedAvatar(AssetBundle bundle, GameObject @object)
public RewardAssetsBundle(string path)
{
Bundle = bundle;
Object = @object;
Path = path;
}
}

public class LoadedRewardAsset
{
public GameObject Object { get; }
public RewardAsset RewardAsset { get; }

public LoadedRewardAsset(GameObject @object, RewardAsset rewardAsset)
{
Object = @object;
RewardAsset = rewardAsset;
}
}

public class Reward
{
Expand Down
42 changes: 41 additions & 1 deletion Assets/Scripts/ApplicationState.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using AvatarViewer.SDK;
using UnityEngine;
using VRM;

Expand All @@ -19,8 +20,47 @@ public static class ApplicationState

public static Dictionary<Guid, LoadedRewardAsset> RewardAssets { get; } = new();

public static Dictionary<string, AssetBundle> RewardBundles { get; } = new();
public static Dictionary<Guid, LoadedRewardAssetsBundle> RewardBundles { get; } = new();

}


public class LoadedAvatar
{

public AssetBundle Bundle { get; }
public GameObject Object { get; }

public LoadedAvatar(AssetBundle bundle, GameObject @object)
{
Bundle = bundle;
Object = @object;
}
}

public class LoadedRewardAsset
{
public GameObject Object { get; }
public RewardAsset RewardAsset { get; }

public LoadedRewardAsset(GameObject @object, RewardAsset rewardAsset)
{
Object = @object;
RewardAsset = rewardAsset;
}
}

public class LoadedRewardAssetsBundle
{
public AssetBundle Bundle { get; }

public Dictionary<Guid, LoadedRewardAsset> RewardAssets { get; }

public LoadedRewardAssetsBundle(AssetBundle bundle, Dictionary<Guid, LoadedRewardAsset> rewardAssets)
{
Bundle = bundle;
RewardAssets = rewardAssets;
}
}

}
2 changes: 1 addition & 1 deletion Assets/Scripts/ApplicationStateController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ private void DestroyData()
avatar.Value.Bundle.Unload(true);
ApplicationState.AvatarBundles.Clear();
foreach (var bundle in ApplicationState.RewardBundles)
bundle.Value.Unload(true);
bundle.Value.Bundle.Unload(true);
ApplicationState.RewardBundles.Clear();
}
}
Expand Down
13 changes: 13 additions & 0 deletions Assets/Scripts/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,17 @@ public static class StringExtensions
{
public static string AsFormat(this string format, params object[] args) => string.Format(format, args);
}

public static class DialogExtensions
{
public static void CreateDialog(this GameObject _dialog, string title, string content, UnityAction onOK = null, UnityAction onCancel = null)
{
var dialog = GameObject.Instantiate(_dialog, GameObject.Find("Canvas").transform, false);
var data = dialog.GetComponentInChildren<Dialog>();
data.SetTitle(title);
data.SetContent(content);
data.SetOnOkAction(onOK);
data.SetOnCancelAction(onCancel);
}
}
}
Loading

0 comments on commit 26cb62c

Please sign in to comment.