mirror of
https://git.aaro.dev/VRCBoard/vrcboard-udon.git
synced 2026-03-17 04:29:46 +00:00
Image Component Updates
This commit is contained in:
@@ -6,11 +6,8 @@ using VRC.SDK3.Data;
|
||||
namespace VRCBoard.Components
|
||||
{
|
||||
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
|
||||
public class VRCBoardImageBasic : VRCBoardBaseComponent
|
||||
public class VRCBoardImageBasic : VRCBoardImageBaseComponent
|
||||
{
|
||||
[Header("Uploader ID (only applies to images of 'shared' or 'instance' type)")]
|
||||
public string uploaderIdOverride;
|
||||
|
||||
[Header("Image IDs")]
|
||||
public string albedoImageId;
|
||||
public string emissionImageId;
|
||||
@@ -24,8 +21,6 @@ namespace VRCBoard.Components
|
||||
public Texture2D defaultNormal;
|
||||
public float normalIntensity = 1.0f;
|
||||
|
||||
|
||||
private string _mainType = "";
|
||||
private string _uploaderId = "";
|
||||
|
||||
protected override void OnRegister()
|
||||
@@ -55,52 +50,10 @@ namespace VRCBoard.Components
|
||||
GetComponent<Renderer>().SetPropertyBlock(_propertyBlock);
|
||||
}
|
||||
|
||||
|
||||
private string GetUploader()
|
||||
{
|
||||
string uploaderId = "";
|
||||
if (string.IsNullOrEmpty(uploaderIdOverride))
|
||||
{
|
||||
GetImageAtlasTexture(albedoImageId, 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(albedoImageId);
|
||||
}
|
||||
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();
|
||||
_uploaderId = GetUploader(albedoImageId);
|
||||
if (string.IsNullOrEmpty(_uploaderId))
|
||||
{
|
||||
Debug.LogError("Failed to get uploader ID");
|
||||
|
||||
Reference in New Issue
Block a user