public void ChangeConnectionStrategy(string newStrategy) { if (newStrategy == Strategy) { return; } switch (Strategy.ToLower()) { case "pubnub": Destroy(PubnubConnectionStrategy); break; case "socket": default: Destroy(SocketConnectionStrategy); break; } Strategy = newStrategy; switch (Strategy.ToLower()) { case "pubnub": TrilleonConnectionStrategy = ConnectionStrategyType.Pubnub; PubnubConnectionStrategy = gameObject.AddComponent <PubnubConnectionStrategy>(); break; case "socket": default: TrilleonConnectionStrategy = ConnectionStrategyType.Socket; SocketConnectionStrategy = gameObject.AddComponent <SocketConnectionStrategy>(); break; } }
void Start() { switch (ConfigReader.GetString("CONNECTION_STRATEGY").ToLower()) { case "pubnub": TrilleonConnectionStrategy = ConnectionStrategyType.Pubnub; gameObject.AddComponent <PubnubConnectionStrategy>(); break; case "socket": default: TrilleonConnectionStrategy = ConnectionStrategyType.Socket; gameObject.AddComponent <SocketConnectionStrategy>(); break; } }