Skip to content
Open

v3 #3

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/call-build-repo-listing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Call Build Repo Listing
on:
workflow_dispatch:
workflow_run:
workflows: [Build Package Listing]
workflows: [Build Release]
types:
- completed

Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ permissions:

jobs:
build:
uses: Narazaka/vpm-repos/.github/workflows/release.yml@main
uses: Narazaka/vpm-repos/.github/workflows/release.yml@main
with:
novcc: false
16 changes: 15 additions & 1 deletion ColorEncoder16.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
namespace net.narazaka.vrchat.sync_texture
using UnityEngine;

namespace net.narazaka.vrchat.sync_texture
{
public abstract class ColorEncoder16 : ColorEncoderBase<ushort>
{
public override ushort[] Pack(Color32[] colors, int startColorIndex, int pixelLength)
{
var data = new ushort[pixelLength * PackUnitLength];
Pack(colors, startColorIndex, data, 0, pixelLength);
return data;
}

public override Color[] Unpack(ushort[] data, int startPixelIndex, int pixelLength)
{
var colors = new Color[pixelLength];
return Unpack(data, startPixelIndex, colors, 0, pixelLength);
}
}
}
14 changes: 14 additions & 0 deletions ColorEncoder8.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
using UnityEngine;

namespace net.narazaka.vrchat.sync_texture
{
public abstract class ColorEncoder8 : ColorEncoderBase<byte>
{
public override byte[] Pack(Color32[] colors, int startColorIndex, int pixelLength)
{
var data = new byte[pixelLength * PackUnitLength];
Pack(colors, startColorIndex, data, 0, pixelLength);
return data;
}

public override Color[] Unpack(byte[] data, int startPixelIndex, int pixelLength)
{
var colors = new Color[pixelLength];
return Unpack(data, startPixelIndex, colors, 0, pixelLength);
}
}
}
2 changes: 2 additions & 0 deletions ColorEncoderBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public abstract class ColorEncoderBase<T> : UdonSharpBehaviour where T : struct
public abstract int PackUnitLength { get; }

public abstract T[] Pack(Color32[] colors);
public abstract T[] Pack(Color32[] colors, int startColorIndex, int pixelLength);
public abstract void Pack(Color32[] colors, int startColorIndex, T[] data, int startPixelIndex, int pixelLength);

public abstract Color[] Unpack(T[] data);
public abstract Color[] Unpack(T[] data, int startPixelIndex, int pixelLength);

public abstract Color[] Unpack(T[] data, int startPixelIndex, Color[] colors, int startColorIndex, int pixelLength);
}
Expand Down
350 changes: 290 additions & 60 deletions Editor/SyncTextureEditor.cs

Large diffs are not rendered by default.

15 changes: 15 additions & 0 deletions Editor/SyncTextureManagerEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,21 @@ public override void OnInspectorGUI()
SyncTextures.GetArrayElementAtIndex(SyncTextures.arraySize - 1).objectReferenceValue = syncTexture;
SetSelfToSyncTexture(syncTexture);
}
var syncTexturesSet = new HashSet<SyncTexture>();
var toRemove = new List<int>();
for (var i = 0; i < SyncTextures.arraySize; i++)
{
var syncTexture = SyncTextures.GetArrayElementAtIndex(i).objectReferenceValue as SyncTexture;
if (syncTexture == null || !syncTexturesSet.Add(syncTexture))
{
toRemove.Add(i);
}
}
toRemove.Reverse();
foreach (var i in toRemove)
{
SyncTextures.DeleteArrayElementAtIndex(i);
}
}

serializedObject.ApplyModifiedProperties();
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,25 @@ Texture2Dを同期します。Render TextureからTexture2Dへの変換などは
基本的に他のUdonからの制御を前提にしています。

- SyncTextureManager: 順番に同期
- SyncTexturesOnLateJoin: late joinerが来たら順番に同期を開始

```
// SyncTexture
bool CanStartSync;
float Progress;
void StartSync(); // take ownership and send
void ForceStartSync();

// SyncTextureManager
bool Sending;
void RequestResend();
void StartSyncAll(bool requestResendWhenSending = false);
void ForceStartSyncAll();
void CancelSync();
void RequestSyncTextureByIndex(int index, bool resendWhenExistsAndNowSending = true);
void RequestSyncTexture(SyncTextureBase syncTexture, bool resendWhenExistsAndNowSending = true);
```

## 更新履歴

- 3.0.0
- アーキテクチャの一新
- インスタンスに情報が保持される仕組みにし、一般的なケースでlate joinerの同期速度を飛躍的に向上。
- 破壊的変更
- アーキテクチャの一新によりAPIが大幅に変更されました。
- 一般的なケースでは以下の手順でマイグレーション出来ると思います。
1. SyncTexture2DのBulkLineCountを再設定する。
2. 任意のSyncTexture2Dの「Set All DataList」ボタンを押す。
3. SyncTexturesOnLateJoinを削除し、`SyncTextureManager.RequestSyncTexture()`を呼ぶ仕組みを実装する。
- 2.0.0
- 新機能
- VRCAsyncGPUReadbackを用いた高速読取処理が可能に
Expand Down
28 changes: 14 additions & 14 deletions SyncTexturesOnLateJoin.asset → Samples/RequestSyncTexture.asset
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ MonoBehaviour:
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: c333ccfdd0cbdbc4ca30cef2dd6e6b9b, type: 3}
m_Name: SyncTexturesOnLateJoin
m_Name: RequestSyncTexture
m_EditorClassIdentifier:
serializedUdonProgramAsset: {fileID: 11400000, guid: a569f3f0d2dbe8040b35e9bbee881078,
serializedUdonProgramAsset: {fileID: 11400000, guid: affead9b684adb64ebff9b4b7ce384a3,
type: 2}
udonAssembly:
assemblyError:
sourceCsScript: {fileID: 11500000, guid: 207df2a8019c9234d99a50caace66be1, type: 3}
sourceCsScript: {fileID: 11500000, guid: d777506b830ecdf4bb7e0ca3bbbabcbf, type: 3}
scriptVersion: 2
compiledVersion: 2
behaviourSyncMode: 1
hasInteractEvent: 0
scriptID: 8100210175251213104
hasInteractEvent: 1
scriptID: -9113643327544977197
serializationData:
SerializedFormat: 2
SerializedBytes:
Expand Down Expand Up @@ -50,13 +50,13 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: SyncTextureManager
Data: syncTextureManager
- Name: $v
Entry: 7
Data: 2|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: SyncTextureManager
Data: syncTextureManager
- Name: <UserType>k__BackingField
Entry: 7
Data: 3|System.RuntimeType, mscorlib
Expand Down Expand Up @@ -116,25 +116,25 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: ForceSyncOnStart
Data: syncTexture
- Name: $v
Entry: 7
Data: 7|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: ForceSyncOnStart
Data: syncTexture
- Name: <UserType>k__BackingField
Entry: 7
Data: 8|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Boolean, mscorlib
Data: net.narazaka.vrchat.sync_texture.SyncTexture, SyncTexture
- Name:
Entry: 8
Data:
- Name: <SystemType>k__BackingField
Entry: 9
Data: 8
Data: 4
- Name: <SyncMode>k__BackingField
Entry: 7
Data: System.Nullable`1[[UdonSharp.UdonSyncMode, UdonSharp.Runtime]], mscorlib
Expand Down Expand Up @@ -176,19 +176,19 @@ MonoBehaviour:
Data:
- Name: $k
Entry: 1
Data: Delay
Data: resendWhenExistsAndNowSending
- Name: $v
Entry: 7
Data: 11|UdonSharp.Compiler.FieldDefinition, UdonSharp.Editor
- Name: <Name>k__BackingField
Entry: 1
Data: Delay
Data: resendWhenExistsAndNowSending
- Name: <UserType>k__BackingField
Entry: 7
Data: 12|System.RuntimeType, mscorlib
- Name:
Entry: 1
Data: System.Single, mscorlib
Data: System.Boolean, mscorlib
- Name:
Entry: 8
Data:
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 26 additions & 0 deletions Samples/RequestSyncTexture.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using UdonSharp;
using UnityEngine;
using VRC.SDKBase;
using VRC.Udon;

namespace net.narazaka.vrchat.sync_texture.samples
{
[AddComponentMenu("")]
[UdonBehaviourSyncMode(BehaviourSyncMode.None)]
public class RequestSyncTexture : UdonSharpBehaviour
{
[SerializeField] SyncTextureManager syncTextureManager;
[SerializeField] SyncTexture syncTexture;
[SerializeField] bool resendWhenExistsAndNowSending = true;

public override void Interact()
{
Send();
}

public void Send()
{
syncTextureManager.RequestSyncTexture(syncTexture, resendWhenExistsAndNowSending);
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions Samples/SyncTexture.Samples.asmdef
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
{
"name": "SyncTexture.Samples",
"rootNamespace": "",
"references": [
"GUID:3c1bc1267eab5884ebe7f232c09ee0d9",
"GUID:f70a94b0bedfa8ec50ed757f72032810",
"GUID:99835874ee819da44948776e0df4ff1d"
"VRC.Udon",
"VRC.Udon.Serialization.OdinSerializer",
"UdonSharp.Runtime",
"SyncTexture"
],
"includePlatforms": [],
"excludePlatforms": [],
Expand Down
Loading