mirror of
https://git.aaro.dev/VRCBoard/vrcboard-udon.git
synced 2026-03-17 04:49:45 +00:00
Image Component Updates
This commit is contained in:
@@ -11,18 +11,14 @@ namespace VRCBoard.Components
|
||||
{
|
||||
|
||||
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
|
||||
public class VRCBoardImage : VRCBoardBaseComponent
|
||||
public class VRCBoardImage : VRCBoardImageBaseComponent
|
||||
{
|
||||
[Header("Uploader ID (only applies to images of 'shared' or 'instance' type)")]
|
||||
public string uploaderIdOverride;
|
||||
|
||||
[HideInInspector] public int materialIndex;
|
||||
|
||||
[HideInInspector] public string[] imageIds = new string[0];
|
||||
[HideInInspector] public string[] texturePropertyMappings = new string[0];
|
||||
[HideInInspector] public Texture2D[] defaultTextures = new Texture2D[0];
|
||||
|
||||
private string _mainType = "";
|
||||
|
||||
private string _uploaderId = "";
|
||||
|
||||
private Renderer _renderer;
|
||||
@@ -40,52 +36,15 @@ namespace VRCBoard.Components
|
||||
}
|
||||
|
||||
|
||||
private string GetUploader()
|
||||
{
|
||||
string uploaderId = "";
|
||||
if (string.IsNullOrEmpty(uploaderIdOverride) && imageIds.Length > 0)
|
||||
{
|
||||
string firstImageID = imageIds[0];
|
||||
GetImageAtlasTexture(firstImageID, null, out Texture2D albedoTexture, out int albedoAtlasPosition, out int albedoAtlasSize, out string albedoType);
|
||||
if (albedoType == null)
|
||||
{
|
||||
Debug.LogError("Failed to get image type for albedo image");
|
||||
return "";
|
||||
}
|
||||
_mainType = albedoType;
|
||||
if (_mainType == "shared")
|
||||
{
|
||||
uploaderId = GetRandomUploader(firstImageID);
|
||||
}
|
||||
else
|
||||
{
|
||||
DataDictionary ownerInfo = manager.GetSupporterDataFromPlayer(manager.InstanceOwner);
|
||||
if (ownerInfo == null)
|
||||
{
|
||||
Debug.LogWarning("Failed to get owner info, user has likely not linked their account.");
|
||||
return "";
|
||||
}
|
||||
bool ownerSuccess = ownerInfo.TryGetValue("id", out DataToken ownerToken);
|
||||
if (!ownerSuccess || ownerToken.TokenType != TokenType.String)
|
||||
{
|
||||
Debug.LogWarning("Failed to get owner ID from owner info.");
|
||||
return "";
|
||||
}
|
||||
uploaderId = ownerToken.String;
|
||||
}
|
||||
|
||||
Debug.Log("image uploader: " + uploaderId);
|
||||
} else
|
||||
{
|
||||
uploaderId = uploaderIdOverride;
|
||||
}
|
||||
return uploaderId;
|
||||
}
|
||||
|
||||
|
||||
private void TryGetUploader()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_uploaderId)) return;
|
||||
_uploaderId = GetUploader();
|
||||
|
||||
if (imageIds.Length == 0) return;
|
||||
_uploaderId = GetUploader(imageIds[0]);
|
||||
|
||||
if (string.IsNullOrEmpty(_uploaderId))
|
||||
{
|
||||
Debug.LogError("Failed to get uploader ID");
|
||||
|
||||
Reference in New Issue
Block a user