public void Setup(string _name = "") { if (!string.IsNullOrEmpty(_name)) { mapName = _name; } editorOpen = false; prevState = false; button = null; axis1D = null; axis2D = null; axisType = AxisType.Button; typeButton = InputTypeButton.ThumbClick; type1D = InputTypeAxis1D.Trigger; type2D = InputTypeAxis2D.Thumb2D; Activated = new UnityEventVoid(); Deactivated = new UnityEventVoid(); UpdateBool = new UnityEventButton(); Update1D = new UnityEventFloat(); Moved2D = new UnityEventAxis2D(); Moved2DX = new UnityEventFloat(); Moved2DY = new UnityEventFloat(); }
public static void TryInvoke(this UnityEventFloat evt, float value) { if (evt != null) { evt.Invoke(value); } }
public string GetDelegateText(UnityEventFloat ue, Func <float, bool> a) { StringBuilder text = new StringBuilder(); if (ue != null) { for (int i = 0; i < ue.GetPersistentEventCount(); ++i) { if (text.Length > 0) { text.Append("\n"); } UnityEngine.Object obj = ue.GetPersistentTarget(i); string t = obj != null ? obj.name : "<???>"; text.Append(t).Append(".").Append(KBind.EventSet.FilterMethodName(ue.GetPersistentMethodName(i))); } } if (a != null) { Delegate[] delegates = a.GetInvocationList(); for (int i = 0; i < delegates.Length; ++i) { if (text.Length > 0) { text.Append("\n"); } text.Append(delegates[i].Target).Append(".").Append(delegates[i].Method.Name); } } return(text.ToString()); }
public void DeserializeEvents() { if (!string.IsNullOrEmpty(json_onEnergyChanged)) { OnEnergyChanged = JsonUtility.FromJson <UnityEventFloat>(json_onEnergyChanged); AssignTargets(OnEnergyChanged, targets_onEnergyChanged); } }
public static void TriggerEvent(string eventName, float param) { UnityEventFloat thisEvent = null; if (Instance != null && Instance.eventDictionaryFloat.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(param); } }
public static void TriggerEvent(string eventName, float value) { UnityEventFloat thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.Invoke(value); } }
// Custom Unity Event validation public void OnValidate() { response = Event != null && Event.UnityEventType == typeof(UnityEvent) ? response : null; responseGameObject = Event != null && Event.UnityEventType == typeof(UnityEventGameObject) ? responseGameObject : null; responseTransform = Event != null && Event.UnityEventType == typeof(UnityEventTransform) ? responseTransform : null; responseInt = Event != null && Event.UnityEventType == typeof(UnityEventInt) ? responseInt : null; responseFloat = Event != null && Event.UnityEventType == typeof(UnityEventFloat) ? responseFloat : null; responseBool = Event != null && Event.UnityEventType == typeof(UnityEventBool) ? responseBool : null; responseString = Event != null && Event.UnityEventType == typeof(UnityEventString) ? responseString : null; }
void Start() { moduleCosts = BalanceTweaks.GlobalInstance.moduleCosts; NextTier = 1; CheckNextThreshold(); upgradeAvailable = false; upgradeTierAvailableEvent = playerM.eventManager.GetEvent(PlayerEvents.UpgradeAvailable); upgradeAppliedEvent = playerM.eventManager.GetEvent(PlayerEvents.UpgradeApplied); playerM.eventManager.GetEvent(PlayerEvents.EnergyChanged).AddListener(EnergyChangeEvent); }
private void Start() { EventManager eventM = playerM.eventManager; wasHitEvent = eventM.GetEvent(PlayerEvents.WasHit); eventM.GetEvent(PlayerEvents.WasKilled).AddListener((f) => { if (lastAttacker != null) { lastAttacker.eventManager.GetEvent(PlayerEvents.KilledEnemy).Invoke(playerM.playerNum); } }); }
public static void StopListening(string eventName, UnityAction <float> listener) { if (eventManager == null) { return; } UnityEventFloat thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.RemoveListener(listener); } }
public UnityEventFloat GetEvent(string name) { UnityEventFloat e; _events.TryGetValue(name, out e); if (e == null) { e = new UnityEventFloat(); _events.Add(name, e); } return(e); }
void Start() { if (TankTweaksProp == null) { TankTweaksProp = BalanceTweaks.GlobalInstance.medTank; } eventM = playerM.eventManager; moveEvent = eventM.GetEvent(PlayerEvents.Move); MoveInput = Vector2.zero; rb = this.GetComponent <Rigidbody2D>(); }
public static void StartListening(string eventName, UnityAction <float> listener) { UnityEventFloat thisEvent = null; if (instance.eventDictionary.TryGetValue(eventName, out thisEvent)) { thisEvent.AddListener(listener); } else { thisEvent = new UnityEventFloat(); thisEvent.AddListener(listener); instance.eventDictionary.Add(eventName, thisEvent); } }
void Start() { EventManager eventM = playerM.eventManager; HealthTweaks healthTweaks = BalanceTweaks.GlobalInstance.health; Init(eventM.GetEvent(PlayerEvents.HealthChanged), healthTweaks.medHullHealth); SetStatValue(healthTweaks.medHullHealth); wasKilledEvent = eventM.GetEvent(PlayerEvents.WasKilled); lostEvent = eventM.GetEvent(PlayerEvents.Lost); spawnPoint = playerM.tankObj.transform.position; lives = healthTweaks.lives; eventM.GetEvent(PlayerEvents.WasHit).AddListener(WasHitEvent); }
public void AddListenerToADLRunStatEvent(string eventKey, UnityAction <float> listener) { UnityEventFloat anADLRunStatEvent; if (EventKeyToADLRunStatEvents.TryGetValue(eventKey, out anADLRunStatEvent)) { anADLRunStatEvent.AddListener(listener); } else { anADLRunStatEvent = new UnityEventFloat(); anADLRunStatEvent.AddListener(listener); EventKeyToADLRunStatEvents.Add(eventKey, anADLRunStatEvent); } }
public void LoadSceneAsync(int sceneBuildIndex, LoadSceneMode loadSceneMode = LoadSceneMode.Single, UnityEventFloat onLoadingSceneAsync = null) { if (this._loadSceneAsyncProcess != null) { this.StopCoroutine(this._loadSceneAsyncProcess); } this._loadSceneAsyncProcess = this.StartCoroutine(this.LoadSceneAsyncProcess(sceneBuildIndex, loadSceneMode, onLoadingSceneAsync)); }
private IEnumerator LoadSceneAsyncProcess(int sceneBuildIndex, LoadSceneMode loadSceneMode, UnityEventFloat onLoadingSceneAsync) { AsyncOperation sceneLoadingAsyncOperation = SceneManager.LoadSceneAsync(sceneBuildIndex, loadSceneMode); while (!sceneLoadingAsyncOperation.isDone) { this._onLoadingSceneAsync.Invoke(sceneLoadingAsyncOperation.progress); onLoadingSceneAsync?.Invoke(sceneLoadingAsyncOperation.progress); yield return(null); } }