void Start() { _carcounter = GetComponent <CarCounter> (); _eventsystem = GetComponent <EventSystem> (); _synccolor = GetComponent <SyncColor> (); _synccolor.sync(); }
SyncMaterial BuildMaterial(SyncColor color) { // Create a basic colored material var material = new SyncMaterial(new SyncId("Material id")); material.AlbedoColor = color; return(material); }
public List <SyncMaterial> BuildMaterialAry() { List <SyncMaterial> materialAry = new List <SyncMaterial>(); // Create a basic colored material var material = new SyncMaterial(new SyncId("Material id")); Random random = new Random(); material.AlbedoColor = SyncColor.From256(random.Next(0, 255), random.Next(0, 255), random.Next(0, 255)); //mtl.MaterialList[0].; materialAry.Add(material); return(materialAry); }
void OnSyncUpdate(object source, ElapsedEventArgs e) { // Let's start a sync update transaction var transaction = m_PublisherClient.StartTransaction(); // Next step is to send only what has changed // Here we only override the material with a new random color var randomColor = SyncColor.From256( m_Random.Next(0, 255), m_Random.Next(0, 255), m_Random.Next(0, 255) ); var material = BuildMaterial(randomColor); transaction.Send(material); // Finally, let's commit the transaction transaction.Commit(); }
public SyncMaterial BuildMaterial(Obj curObj, PublisherTransaction transaction) { SyncMaterial material = null; ObjParser.Types.Material mat = FindMaterial(curObj.UseMtl); if (mat != null) { material = new SyncMaterial(new SyncId("MaterialId_" + mat.Name), mat.Name); Random random = new Random(); //material.AlbedoColor = new SyncColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble()); material.AlbedoColor = SyncColor.From256(200, 200, 200); // test Console.WriteLine("\t\tColor: " + material.AlbedoColor.R.ToString() + ", " + material.AlbedoColor.G.ToString() + ", " + material.AlbedoColor.B.ToString() + ", "); // テクスチャが見つかった場合 if (mat.map_Kd.Length > 0) { //material.AlbedoFade = 1.0f; // 0.5f; //2021.5.26 SyncTexture texture = BuildTexture(mat); if (texture != null) { transaction.Send(texture); Console.WriteLine("\tTexture Id: " + texture.Id); Console.WriteLine("\tTexture Name: " + texture.Name); SyncMap albedoMap = new SyncMap(texture.Id, new Vector2(), new Vector2(1, 1)); material.AlbedoMap = albedoMap; } } } else { Console.WriteLine("Warning: No Material."); material = new SyncMaterial(new SyncId("MaterialId_" + "DEFAULT"), "DEFAULT"); material.AlbedoColor = SyncColor.From256(200, 0, 0); } return(material); }
public static Color GetUnityColor(SyncColor color, bool keepAlpha = true) { return(new Color(color.R, color.G, color.B, keepAlpha ? color.A : 1.0f)); }
void Awake() { _synccolor = GetComponent <SyncColor> (); }