public void StartMarkerFromActionDescription() { ActionRunner runner = GameMaster.GetInstance().GetSelectedAction(); Transform prefab = runner.ActionDescription.m_EventMarker; if (prefab == null) { return; } if (!m_Markers.ContainsKey(prefab.name)) { if (!LoadMarker(prefab.name)) { return; } } IAnimationEvent marker = m_Markers[prefab.name]; marker.StartEvent(); }
private bool LoadMarker(string _prefabName) { string resourcePath = string.Format("Prefabs/Marker/{0}", _prefabName); GameObject prefab = Resources.Load <GameObject>(resourcePath); if (prefab == null) { Debug.LogError(string.Format("Can't load marker name {0}", _prefabName)); return(false); } GameObject obj = (GameObject)Instantiate(prefab, Vector3.zero, Quaternion.identity); IAnimationEvent marker = obj.GetComponent <IAnimationEvent>(); if (marker == null) { Debug.LogError(string.Format("The prefab {0} has no IMarker component", _prefabName)); return(false); } m_Markers.Add(_prefabName, marker); //NOT MULTITHREADING SAFE!!!!! return(true); }