mirror of
https://git.aaro.dev/VRCBoard/vrcboard-udon.git
synced 2026-03-17 01:09:45 +00:00
Image Component Updates
This commit is contained in:
@@ -46,7 +46,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedFormat: 0
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
@@ -162,6 +162,7 @@ MonoBehaviour:
|
||||
- url: http://mydomain.vrcboard.app/atlas/98
|
||||
- url: http://mydomain.vrcboard.app/atlas/99
|
||||
customModuleUrls: []
|
||||
customModuleEnabled:
|
||||
atlasInfoUrl:
|
||||
url: http://mydomain.vrcboard.app/api/data/v1/atlas
|
||||
supporterInfoUrl:
|
||||
@@ -187,7 +188,7 @@ MonoBehaviour:
|
||||
AllowCollisionOwnershipTransfer: 0
|
||||
Reliable: 0
|
||||
_syncMethod: 0
|
||||
serializedProgramAsset: {fileID: 11400000, guid: d4ffc934acd43fc4b8cb40f7f16ab93b,
|
||||
serializedProgramAsset: {fileID: 11400000, guid: f9597e921c7b6ed43b9c0e546b52af81,
|
||||
type: 2}
|
||||
programSource: {fileID: 11400000, guid: c4183376def25d24a8d2963d59ac2cd2, type: 2}
|
||||
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBV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:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedFormat: 0
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
@@ -136,7 +136,7 @@ MonoBehaviour:
|
||||
AllowCollisionOwnershipTransfer: 0
|
||||
Reliable: 0
|
||||
_syncMethod: 1
|
||||
serializedProgramAsset: {fileID: 11400000, guid: 32cf8d0597898494cbc98c3c876c73e3,
|
||||
serializedProgramAsset: {fileID: 11400000, guid: 19ae0697d87c22c40b5eceb361997922,
|
||||
type: 2}
|
||||
programSource: {fileID: 11400000, guid: ac7f998a74898ea4ead01ba49e49e658, type: 2}
|
||||
serializedPublicVariablesBytesString: Ai8AAAAAATIAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAFQAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AAAAAAAYBAAAAAAAAACcBBAAAAHQAeQBwAGUAAWgAAABTAHkAcwB0AGUAbQAuAEMAbwBsAGwAZQBjAHQAaQBvAG4AcwAuAEcAZQBuAGUAcgBpAGMALgBMAGkAcwB0AGAAMQBbAFsAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4ALgBJAG4AdABlAHIAZgBhAGMAZQBzAC4ASQBVAGQAbwBuAFYAYQByAGkAYQBiAGwAZQAsACAAVgBSAEMALgBVAGQAbwBuAC4AQwBvAG0AbQBvAG4AXQBdACwAIABtAHMAYwBvAHIAbABpAGIAAQEJAAAAVgBhAHIAaQBhAGIAbABlAHMALwEAAAABaAAAAFMAeQBzAHQAZQBtAC4AQwBvAGwAbABlAGMAdABpAG8AbgBzAC4ARwBlAG4AZQByAGkAYwAuAEwAaQBzAHQAYAAxAFsAWwBWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAEkAbgB0AGUAcgBmAGEAYwBlAHMALgBJAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlACwAIABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgBdAF0ALAAgAG0AcwBjAG8AcgBsAGkAYgABAAAABgEAAAAAAAAAAi8CAAAAAUkAAABWAFIAQwAuAFUAZABvAG4ALgBDAG8AbQBtAG8AbgAuAFUAZABvAG4AVgBhAHIAaQBhAGIAbABlAGAAMQBbAFsAUwB5AHMAdABlAG0ALgBJAG4AdAAzADIALAAgAG0AcwBjAG8AcgBsAGkAYgBdAF0ALAAgAFYAUgBDAC4AVQBkAG8AbgAuAEMAbwBtAG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
|
||||
|
||||
@@ -48,7 +48,7 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
serializationData:
|
||||
SerializedFormat: 2
|
||||
SerializedFormat: 0
|
||||
SerializedBytes:
|
||||
ReferencedUnityObjects: []
|
||||
SerializedBytesString:
|
||||
@@ -138,7 +138,7 @@ MonoBehaviour:
|
||||
AllowCollisionOwnershipTransfer: 0
|
||||
Reliable: 0
|
||||
_syncMethod: 1
|
||||
serializedProgramAsset: {fileID: 11400000, guid: d1ddff36e693dc44c9be01aca0c91ed0,
|
||||
serializedProgramAsset: {fileID: 11400000, guid: 7111a5f4b78f7a94fb3d6ae9aef3b9d4,
|
||||
type: 2}
|
||||
programSource: {fileID: 11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AG0AbwBuAAIAAAAGAgAAAAAAAAAnAQQAAAB0AHkAcABlAAEXAAAAUwB5AHMAdABlAG0ALgBTAHQAcgBpAG4AZwAsACAAbQBzAGMAbwByAGwAaQBiACcBCgAAAFMAeQBtAGIAbwBsAE4AYQBtAGUAAR8AAABfAF8AXwBVAGQAbwBuAFMAaABhAHIAcABCAGUAaABhAHYAaQBvAHUAcgBWAGUAcgBzAGkAbwBuAF8AXwBfACcBBAAAAHQAeQBwAGUAARYAAABTAHkAcwB0AGUAbQAuAEkAbgB0ADMAMgAsACAAbQBzAGMAbwByAGwAaQBiABcBBQAAAFYAYQBsAHUAZQACAAAABwUHBQcF
|
||||
|
||||
@@ -81,7 +81,7 @@ namespace VRCBoard.Components
|
||||
internal bool GetImageAtlasTexture(string imageId, string uploader, out Texture2D texture,
|
||||
out int position, out int size, out string type) {
|
||||
return manager._GetImageAtlasTexture(imageId, uploader, out int atlasIndex, out texture, out position, out size,
|
||||
out type);
|
||||
out type, out string hash);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: VRCBoardImage
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: f83f88ce349d298438a783df6b33c10f,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 19ae0697d87c22c40b5eceb361997922,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
@@ -44,7 +44,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 12
|
||||
Data: 11
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -563,13 +563,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _mainType
|
||||
Data: _uploaderId
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 33|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _mainType
|
||||
Data: _uploaderId
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
@@ -611,64 +611,16 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _uploaderId
|
||||
Data: _renderer
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 35|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _uploaderId
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 36|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _renderer
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 37|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _renderer
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 7
|
||||
Data: 38|System.RuntimeType, mscorlib
|
||||
Data: 36|System.RuntimeType, mscorlib
|
||||
- Name:
|
||||
Entry: 1
|
||||
Data: UnityEngine.Renderer, UnityEngine.CoreModule
|
||||
@@ -677,7 +629,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 38
|
||||
Data: 36
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
@@ -692,7 +644,7 @@ MonoBehaviour:
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 39|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
Data: 37|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
|
||||
@@ -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");
|
||||
|
||||
61
Components/VRCBoardImageBaseComponent.cs
Normal file
61
Components/VRCBoardImageBaseComponent.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon;
|
||||
using UnityEngine.Serialization;
|
||||
using VRC.SDK3.Data;
|
||||
|
||||
namespace VRCBoard.Components
|
||||
{
|
||||
public abstract class VRCBoardImageBaseComponent : VRCBoardBaseComponent
|
||||
{
|
||||
[Header("Uploader ID (only applies to images of 'shared' or 'instance' type)")]
|
||||
public string uploaderIdOverride;
|
||||
internal string GetUploader(string imageId)
|
||||
{
|
||||
string uploaderId = "";
|
||||
if (string.IsNullOrEmpty(uploaderIdOverride))
|
||||
{
|
||||
GetImageAtlasTexture(imageId, 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 "";
|
||||
}
|
||||
string _mainType = albedoType;
|
||||
if (_mainType == "shared")
|
||||
{
|
||||
uploaderId = GetRandomUploader(imageId);
|
||||
}
|
||||
else if (_mainType == "global")
|
||||
{
|
||||
uploaderId = null;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Components/VRCBoardImageBaseComponent.cs.meta
Normal file
11
Components/VRCBoardImageBaseComponent.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 43df2736f0176d743827643f443578f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: VRCBoardImageBasic
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: dfe93a97c46c4cf4c95cfe80dcaa0d3e,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 7111a5f4b78f7a94fb3d6ae9aef3b9d4,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
@@ -44,7 +44,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 16
|
||||
Data: 15
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -845,13 +845,13 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _mainType
|
||||
Data: _uploaderId
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 43|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _mainType
|
||||
Data: _uploaderId
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
@@ -888,54 +888,6 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: _uploaderId
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 45|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: _uploaderId
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 15
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 46|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: VRCBoardOverheadIcons
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 4d130d8e384312146b0f690571220be5,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: 9b52c5e5b2955fa468b15a65e066455d,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: VRCBoardSupporterBoardTMP
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: e758930ddabc47d499d718189a2787b5,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: cb7ba44e9b1599548a81a4691eb88bb4,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
|
||||
@@ -12,7 +12,7 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
|
||||
m_Name: VRCBoardManager
|
||||
m_EditorClassIdentifier:
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: b0a3201f714d46b4cbdb27ef08a99c58,
|
||||
serializedUdonProgramAsset: {fileID: 11400000, guid: f9597e921c7b6ed43b9c0e546b52af81,
|
||||
type: 2}
|
||||
udonAssembly:
|
||||
assemblyError:
|
||||
@@ -44,7 +44,7 @@ MonoBehaviour:
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 25
|
||||
Data: 28
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
@@ -1359,6 +1359,150 @@ MonoBehaviour:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: textureCacheKeys
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 71|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: textureCacheKeys
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 61
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 61
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 72|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: textureCacheTextures
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 73|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: textureCacheTextures
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 25
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 74|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 7
|
||||
Data:
|
||||
- Name: $k
|
||||
Entry: 1
|
||||
Data: textureCacheCurrentSize
|
||||
- Name: $v
|
||||
Entry: 7
|
||||
Data: 75|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
|
||||
- Name: <Name>k__BackingField
|
||||
Entry: 1
|
||||
Data: textureCacheCurrentSize
|
||||
- Name: <UserType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 12
|
||||
- Name: <SystemType>k__BackingField
|
||||
Entry: 9
|
||||
Data: 12
|
||||
- Name: <SyncMode>k__BackingField
|
||||
Entry: 7
|
||||
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
|
||||
- Name:
|
||||
Entry: 6
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name: <IsSerialized>k__BackingField
|
||||
Entry: 5
|
||||
Data: false
|
||||
- Name: _fieldAttributes
|
||||
Entry: 7
|
||||
Data: 76|System.Collections.Generic.List`1[[System.Attribute, mscorlib]], mscorlib
|
||||
- Name:
|
||||
Entry: 12
|
||||
Data: 0
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 8
|
||||
Data:
|
||||
- Name:
|
||||
Entry: 13
|
||||
Data:
|
||||
|
||||
@@ -71,6 +71,7 @@ namespace VRCBoard
|
||||
[UdonSynced, FieldChangeCallback(nameof(InstanceOwner))] private string _instanceOwner;
|
||||
public string[] imageIdDownloadQueue = new string[0];
|
||||
|
||||
[PublicAPI]
|
||||
public void SetInstanceOwner(string owner)
|
||||
{
|
||||
instanceOwnerOverride = owner;
|
||||
@@ -265,13 +266,15 @@ namespace VRCBoard
|
||||
if (token.TokenType != TokenType.DataDictionary) return null;
|
||||
return token.DataDictionary;
|
||||
}
|
||||
public bool _GetImageAtlasTexture(string imageId, string uploader, out int atlasIndex, out Texture2D texture, out int position, out int size, out string type)
|
||||
|
||||
public bool _GetImageAtlasTexture(string imageId, string uploader, out int atlasIndex, out Texture2D texture, out int position, out int size, out string type, out string hash)
|
||||
{
|
||||
texture = null;
|
||||
position = -1;
|
||||
size = -1;
|
||||
atlasIndex = -1;
|
||||
type = null;
|
||||
hash = null;
|
||||
DataDictionary imageInfo = _GetImageIdInfo(imageId);
|
||||
if (imageInfo == null)
|
||||
{
|
||||
@@ -348,6 +351,13 @@ namespace VRCBoard
|
||||
}
|
||||
texture = _downloadedAtlasTextures[atlasIndex];
|
||||
position = (int)positionToken.Double;
|
||||
|
||||
bool hashSuccess = uploadInfo.TryGetValue("h", out DataToken hashToken);
|
||||
if (!hashSuccess || hashToken.TokenType != TokenType.String)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
hash = hashToken.String;
|
||||
return true;
|
||||
}
|
||||
public void _RequestImageLoad(string imageId, string uploader, VRCBoardBaseComponent component)
|
||||
@@ -365,7 +375,7 @@ namespace VRCBoard
|
||||
string imageId = split[0];
|
||||
string uploader = split[1];
|
||||
bool success = _GetImageAtlasTexture(imageId, uploader, out int atlasIndex, out Texture2D texture,
|
||||
out int position, out int size, out string type);
|
||||
out int position, out int size, out string type, out string hash);
|
||||
//Debug.Log("Try download image " + combinedImageId + " success: " + success);
|
||||
if (!success) return;
|
||||
DownloadAtlas(atlasIndex);
|
||||
@@ -582,13 +592,83 @@ namespace VRCBoard
|
||||
foreach (var component in vrcBoardComponents)
|
||||
component._OnAtlasImageLoaded(index);
|
||||
}
|
||||
|
||||
private static int NextPowerOf2(int value)
|
||||
{
|
||||
if (value <= 0)
|
||||
return 1;
|
||||
|
||||
// Use bitwise manipulation to find the next power of 2
|
||||
value--;
|
||||
value |= value >> 1;
|
||||
value |= value >> 2;
|
||||
value |= value >> 4;
|
||||
value |= value >> 8;
|
||||
value |= value >> 16;
|
||||
return value + 1;
|
||||
}
|
||||
|
||||
private string[] textureCacheKeys = new string[0];
|
||||
private Texture2D[] textureCacheTextures = new Texture2D[0];
|
||||
private int textureCacheCurrentSize = 0;
|
||||
|
||||
public void AddToTextureCache(string key, Texture2D texture)
|
||||
{
|
||||
// If the store is full, resize the arrays
|
||||
if (textureCacheCurrentSize >= textureCacheKeys.Length)
|
||||
{
|
||||
ResizeArrays(textureCacheCurrentSize + 1);
|
||||
}
|
||||
|
||||
// Add the new key-value pair
|
||||
textureCacheKeys[textureCacheCurrentSize-1] = key;
|
||||
textureCacheTextures[textureCacheCurrentSize-1] = texture;
|
||||
}
|
||||
|
||||
// Method to get a texture by its key
|
||||
public Texture2D GetFromTextureCache(string key)
|
||||
{
|
||||
for (int i = 0; i < textureCacheCurrentSize; i++)
|
||||
{
|
||||
if (textureCacheKeys[i] == key)
|
||||
{
|
||||
return textureCacheTextures[i];
|
||||
}
|
||||
}
|
||||
|
||||
Debug.LogWarning("Key not found: " + key);
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ResizeArrays(int newSize)
|
||||
{
|
||||
string[] newKeys = new string[newSize];
|
||||
Texture2D[] newTextures = new Texture2D[newSize];
|
||||
|
||||
// Copy existing data to the new arrays
|
||||
for (int i = 0; i < textureCacheCurrentSize; i++)
|
||||
{
|
||||
newKeys[i] = textureCacheKeys[i];
|
||||
newTextures[i] = textureCacheTextures[i];
|
||||
}
|
||||
|
||||
// Replace old arrays with the new resized arrays
|
||||
textureCacheKeys = newKeys;
|
||||
textureCacheTextures = newTextures;
|
||||
|
||||
textureCacheCurrentSize = newSize;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public Texture2D GetTexture2D(string uploader, string imageId)
|
||||
public Texture2D GetTexture2D(string uploader, string imageId, out string imageHash)
|
||||
{
|
||||
bool success = _GetImageAtlasTexture(imageId, uploader, out int atlasIndex, out Texture2D texture,
|
||||
out int position, out int size, out string type);
|
||||
out int position, out int size, out string type, out string hash);
|
||||
imageHash = hash;
|
||||
|
||||
Texture2D cachedTexture = GetFromTextureCache(hash);
|
||||
if (cachedTexture != null) return cachedTexture;
|
||||
|
||||
if (!success || atlasIndex == -1)
|
||||
{
|
||||
Debug.LogWarning("[VRCBoard] [GetTexture2D] Failed to get texture for " + uploader);
|
||||
@@ -604,25 +684,51 @@ namespace VRCBoard
|
||||
int blockSize = (int)Mathf.Floor((float)(texture.width) / (float)(size));
|
||||
|
||||
|
||||
int startX = position % size;
|
||||
int startY = size - (int)Mathf.Floor((float)position / (float)size) - 1;
|
||||
float startX = position % size;
|
||||
float startY = size - (int)Mathf.Floor((float)position / (float)size) - 1;
|
||||
|
||||
startX = startX / size;
|
||||
startY = startY / size;
|
||||
|
||||
// Debug.Log("texture startX:" + startX + ", startY:" + startY);
|
||||
Debug.Log("texture startX:" + startX + ", startY:" + startY);
|
||||
|
||||
int textureSize = 1024;
|
||||
|
||||
Texture2D newTexture = new Texture2D (textureSize, textureSize);
|
||||
|
||||
int blockWidth = blockSize;
|
||||
int blockHeight = blockSize;
|
||||
|
||||
Texture2D newTexture = new Texture2D (blockWidth, blockHeight);
|
||||
Color[] pixels = texture.GetPixels(startX * blockWidth, startY * blockHeight, blockWidth, blockHeight);
|
||||
newTexture.SetPixels(pixels);
|
||||
Color[] stretchedPixels = new Color[textureSize * textureSize];
|
||||
|
||||
for (int y = 0; y < textureSize; y++)
|
||||
{
|
||||
for (int x = 0; x < textureSize; x++)
|
||||
{
|
||||
// Get the corresponding pixel from the original texture
|
||||
float u = startX + ((float)x / textureSize / size);
|
||||
float v = startY + ((float)y / textureSize / size);
|
||||
|
||||
// Sample the original texture at the calculated UV coordinates
|
||||
Color pixel = texture.GetPixelBilinear(u, v);
|
||||
stretchedPixels[y * textureSize + x] = pixel;
|
||||
}
|
||||
}
|
||||
|
||||
//Color[] pixels = texture.GetPixels(startX * blockSize, startY * blockSize, blockSize, blockSize);
|
||||
newTexture.SetPixels(stretchedPixels);
|
||||
newTexture.wrapMode = TextureWrapMode.Clamp;
|
||||
newTexture.filterMode = FilterMode.Trilinear;
|
||||
newTexture.anisoLevel = 1;
|
||||
//newTexture.alphaIsTransparency = true;
|
||||
newTexture.Apply();
|
||||
AddToTextureCache(hash, newTexture);
|
||||
return newTexture;
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public Texture2D GetTexture2D(string uploader, string imageId)
|
||||
{
|
||||
return GetTexture2D(uploader, imageId, out string imageHash);
|
||||
}
|
||||
|
||||
public override void OnImageLoadError(IVRCImageDownload result)
|
||||
{
|
||||
base.OnImageLoadError(result);
|
||||
@@ -776,7 +882,7 @@ namespace VRCBoard
|
||||
|
||||
if (GUILayout.Button("Link all VRCBoard components"))
|
||||
{
|
||||
VRCBoardBaseComponent[] components = FindObjectsOfType<VRCBoardBaseComponent>();
|
||||
VRCBoardBaseComponent[] components = FindObjectsOfType<VRCBoardBaseComponent>(true);
|
||||
manager.vrcBoardComponents = components;
|
||||
// mark the object as dirty
|
||||
EditorUtility.SetDirty(manager);
|
||||
|
||||
Reference in New Issue
Block a user