Пример #1
0
	public void UnloadInputBinder(InputBinderBase binder, OnKeybindOrderChanged unregCallback)
	{
		onOrderChanged += unregCallback;
		List<InputDefinition> defs = binder.GetInputBinds();
		if (defs == null) return;
		if (defs.Count == 0) return;

		state = State.Init;

		List<InputGroup> checkEmptyGroups = new List<InputGroup>();
		InputGroup group = null;
		foreach (InputDefinition d in defs)
		{
			if (group != null)
			{
				if (!group.name.Equals(d.groupName)) group = null;
			}

			if (group == null)
			{
				int idx = GetInputGroupIdx(d.groupName);
				if (idx < 0) continue;
				group = inputGroups[idx];
				if (!checkEmptyGroups.Contains(group)) checkEmptyGroups.Add(group);
			}

			int rem = -1;
			for (int i = 0; i < group.inputs.Count; i++)
			{
				if (group.inputs[i].inputName.Equals(d.inputName)) { rem = i; break; }
			}
			
			if (rem >= 0) 
			{
				group.inputs.RemoveAt(rem);

				rem = -1;
				for (int i = 0; i < callbackList.Count; i++)
				{
					if (callbackList[i].groupName.Equals(d.groupName) && callbackList[i].inputName.Equals(d.inputName))
					{
						rem = i; break;
					}
				}

				if (rem >= 0) callbackList.RemoveAt(rem);
			}
		}

		for (int i = 0; i < checkEmptyGroups.Count; i++)
		{
			if (checkEmptyGroups[i].inputs.Count == 0) inputGroups.Remove(checkEmptyGroups[i]);
		}

		if (onOrderChanged != null) onOrderChanged();
	}
Пример #2
0
	public static void UnloadInputsFromBinder(InputBinderBase binder)
	{
	}
Пример #3
0
	// ================================================================================================================
	#region pub

	/// <summary>Load input definitions via a binder. This should be called during Start() of a component (or as soon as possible, but not in Awake())</summary>
	public void LoadInputFromBinder(InputBinderBase binder, OnKeybindOrderChanged regCallback)
	{
		onOrderChanged += regCallback;
		List<InputDefinition> defs = binder.GetInputBinds();
		if (defs == null) return;
		if (defs.Count == 0) return;

		state = State.Init;
		foreach (InputDefinition d in defs)
		{
			InputIdxCache idx = AddInput(d);
			binder._SaveInputIdxCache(idx); // tell the binder about the idx in case it wants to save it
		}

		if (onOrderChanged != null) onOrderChanged();
	}
Пример #4
0
	public static void LoadInputsFromBinder(InputBinderBase binder)
	{
		List<InputDefinition> defs = binder.GetInputBinds();
		foreach (InputDefinition d in defs)
		{
			if (!inputBinds.ContainsKey(d.groupName)) inputBinds.Add(d.groupName, new Dictionary<string, InputDefinition>());
			if (!inputBinds[d.groupName].ContainsKey(d.inputName))
			{
				inputBinds[d.groupName].Add(d.inputName, d);
			}
		}
	}