

ColorSyncModel.csColorSyncModel.csColorSyncModel.csColorSyncModel.csColorSyncModel.csColorSyncModel.cspartialpartialpartial[RealtimeModel][RealtimeModel][RealtimeModel][RealtimeProperty][RealtimeProperty][RealtimeProperty]ColorSync.csColorSync.csColorSync.csRealtimeComponent<ColorSyncModel>RealtimeComponent<ColorSyncModel>RealtimeComponent<ColorSyncModel>ColorSyncColorSyncColorSyncusing System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
using Normal.Realtime.Serialization;
[RealtimeModel]
public partial class ColorSyncModel {
[RealtimeProperty(1, true, true)]
private Color[] _colors;
} using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
public class ColorSync : RealtimeComponent<ColorSyncModel> {
private MeshRenderer _meshRenderer;
private void Awake() {
// Get a reference to the mesh renderer
_meshRenderer = GetComponent<MeshRenderer>();
}
private void UpdateMeshRendererColors() {
// Get the colors from the model and set it on the mesh renderer.
_meshRenderer.materials = model.colors;
}
public void SetColors(Color[] colors) {
// Set the colors on the model
model.colors = colors;
}
} using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
using Normal.Realtime.Serialization;
[RealtimeModel]
public partial class ColorSyncModel {
[RealtimeProperty(1, true, true)]
private Dictionary<int, Color> _colors;
} using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
public class ColorSync : RealtimeComponent<ColorSyncModel> {
private MeshRenderer _meshRenderer;
private void Awake() {
// Get a reference to the mesh renderer
_meshRenderer = GetComponent<MeshRenderer>();
}
private void UpdateMeshRendererColors() {
// Get the colors from the model and set it on the mesh renderer.
_meshRenderer.materials = model.colors.Values.ToArray();
}
public void SetColors(Dictionary<int, Color> colors) {
// Set the colors on the model
model.colors = colors;
}
} using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
using Normal.Realtime.Serialization;
[RealtimeModel]
public partial class ColorSyncModel {
[RealtimeProperty(1, true, true)]
private RealtimeDictionary<int, Color> _colors;
} using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Normal.Realtime;
public class ColorSync : RealtimeComponent<ColorSyncModel> {
private MeshRenderer _meshRenderer;
private void Awake() {
// Get a reference to the mesh renderer
_meshRenderer = GetComponent<MeshRenderer>();
}
private void UpdateMeshRendererColors() {
// Get the colors from the model and set it on the mesh renderer.
_meshRenderer.material.color = model.colors[0]; // Assuming 0 is the key for the color you want to sync
}
public void SetColor(int key, Color color) {
// Set the color on the model
model.colors[key] = color;
}
}