private void IndentityMonoAdd() { /* * Set up a unique value for each Road and Connection. * This is because we cannot use the Road or Connection name in ECS as strings are not allowed (only bittable data can be used) * AND because road and connection names may not be unique. * We need the unique value to identify the relationship between road and connection */ ERRoadNetwork roadNetwork = new ERRoadNetwork(); ERRoad[] roads = roadNetwork.GetRoads(); ERConnection[] connections = roadNetwork.GetConnections(); int identity = 0; foreach (ERRoad road in roads) { road.gameObject.AddComponent <ERRoadConnectionIdentity>(); road.gameObject.GetComponent <ERRoadConnectionIdentity>().value = identity; identity++; } foreach (ERConnection connection in connections) { connection.gameObject.AddComponent <ERRoadConnectionIdentity>(); connection.gameObject.GetComponent <ERRoadConnectionIdentity>().value = identity; identity++; } }
private void IdentityMonoRemove() { ERRoadNetwork roadNetwork = new ERRoadNetwork(); ERRoad[] roads = roadNetwork.GetRoads(); ERConnection[] connections = roadNetwork.GetConnections(); foreach (ERRoad road in roads) { Destroy(road.gameObject.GetComponent <ERRoadConnectionIdentity>()); } foreach (ERConnection connection in connections) { Destroy(connection.gameObject.GetComponent <ERRoadConnectionIdentity>()); } }