mirror of
https://git.aaro.dev/VRCBoard/vrcboard-udon.git
synced 2026-03-17 02:49:46 +00:00
Refactor VRCBoard components to replace material override with material index and update related methods
This commit is contained in:
@@ -311,12 +311,13 @@ namespace VRCBoard
|
||||
}
|
||||
|
||||
atlasIndex = (int)atlasIndexToken.Double;
|
||||
texture = _downloadedAtlasTextures[atlasIndex];
|
||||
|
||||
bool positionSuccess = uploadInfo.TryGetValue("p", out DataToken positionToken);
|
||||
if (!positionSuccess || positionToken.TokenType != TokenType.Double)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
texture = _downloadedAtlasTextures[atlasIndex];
|
||||
position = (int)positionToken.Double;
|
||||
return true;
|
||||
}
|
||||
@@ -517,27 +518,28 @@ namespace VRCBoard
|
||||
_atlasDownloadTimes[index] = Time.time;
|
||||
Debug.Log("Downloaded atlas texture " + index);
|
||||
foreach (var component in vrcBoardComponents)
|
||||
component._OnImageLoaded(index);
|
||||
component._OnAtlasImageLoaded(index);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public Texture2D GetTexture2D(string uploader, string imageId)
|
||||
{
|
||||
bool success = _GetImageAtlasTexture(imageId, uploader, out int atlasIndex, out Texture2D texture,
|
||||
out int position, out int size, out string type);
|
||||
|
||||
if (!success)
|
||||
if (!success || atlasIndex == -1)
|
||||
{
|
||||
Debug.LogWarning("[VRCBoard] [GetTexture2D] Failed to get texture for " + uploader);
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!texture)
|
||||
if (texture == null)
|
||||
{
|
||||
Debug.LogWarning("[VRCBoard] [GetTexture2D] Failed to get texture for " + uploader);
|
||||
return null;
|
||||
}
|
||||
|
||||
int blockSize = (int)Mathf.Floor((float)texture.width / (float)size);
|
||||
int blockSize = (int)Mathf.Floor((float)(texture.width+1) / (float)(size));
|
||||
|
||||
|
||||
int startX = position % size;
|
||||
@@ -552,6 +554,9 @@ namespace VRCBoard
|
||||
Color[] pixels = texture.GetPixels(startX * blockWidth, startY * blockHeight, blockWidth, blockHeight);
|
||||
newTexture.SetPixels(pixels);
|
||||
newTexture.wrapMode = TextureWrapMode.Clamp;
|
||||
newTexture.filterMode = FilterMode.Trilinear;
|
||||
newTexture.anisoLevel = 1;
|
||||
//newTexture.alphaIsTransparency = true;
|
||||
newTexture.Apply();
|
||||
return newTexture;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user