public void Init(SimulatorView simView, EngineProfile profile)
 {
     _simView    = simView;
     _profile    = profile;
     _patternIds = new List <int>();
     foreach (var p in _profile.Patterns)
     {
         _patternMap[p.PatternId] = p;
         _patternIds.Add(p.PatternId);
     }
     _patternIds.Sort();
     _patternIndex = 0;
     UpdatePatternVisualProperties();
 }
        public override void StartProvider()
        {
            var p = Resources.Load("TE.Profile") as TextAsset;

            if (p != null)
            {
                var s = p.text;
                if (!string.IsNullOrEmpty(s))
                {
                    _profile = JsonConvert.DeserializeObject <EngineProfile>(s);
                    Log.Out("TE2: Parsed patterns file");
                }
            }

            if (_profile == null)
            {
                _profile = EngineProfile.DefaultProfile();
            }

            var o = Resources.Load("TE.Sim.SimulatorView");

            if (o == null)
            {
                Log.Error("TE2: Could not find TE.SimulatorView prefab. The simulator will not function.");
                OnFailedToConnect();
            }
            else
            {
                var inst = Object.Instantiate(o);
                var go   = inst as GameObject;
                if (go == null)
                {
                    OnFailedToConnect();
                }
                else
                {
                    _simulatorView = go.GetComponent <SimulatorView>();
                    if (_simulatorView == null)
                    {
                        OnFailedToConnect();
                    }
                    else
                    {
                        _simulatorView.Init(this, _tangibles, _profile);
                        OnConnected();
                    }
                }
            }
        }