// Multi-input /// <summary> /// Adds a multi-input to the <see cref="P:MultiInputs"/> array. /// The <see cref="P:Id"/> is set automatically not to be duplicated. /// If the length of <see cref="P:MultiInputs"/> array reaches to the <see cref="P:MaxMultiInputCount"/>, /// this method stops to work and returns <see cref="T:false"/>. /// </summary> /// <returns><c>true</c>, if a multi-input was added, <c>false</c> otherwise.</returns> public override bool AddMultiInput() { // Check the length. if (MultiInputs.Length >= MaxMultiInputCount.Value) { if (FrameworkBehaviour.CanShowLog) { Debug.Log("[ToryInput] The maximum number of multi-inputs (" + MaxMultiInputCount + ") reached."); } return(false); } // Add a new multi-input. ToryMultiInput <Vector3> mi = new ToryVector3MultiInput(); multiInputList.Add(mi); MultiInputs = multiInputList.ToArray(); mi.ValueReceived += TriggerMultiInputValueReceivedEvent; mi.Interacted += TriggerMultiInputInteractedEvent; if (FrameworkBehaviour.CanShowLog) { Debug.Log("[ToryInput] A new multi-input (ID: " + mi.Id + ") added."); } // Trigger an event. TriggerMultiInputAdded(mi); return(true); }
/// <summary> /// Adds a multi-input to the <see cref="P:MultiInputs"/> array. /// The <see cref="P:Id"/> is set manually. /// If the length of <see cref="P:MultiInputs"/> array reaches to the <see cref="P:MaxMultiInputCount"/>, /// this method stops to work and returns <see cref="T:false"/>. /// </summary> /// <returns><c>true</c>, if a multi-input was added, <c>false</c> otherwise.</returns> /// <param name="id">Identifier.</param> public override bool AddMultiInput(int id) { // Check the length. if (MultiInputs.Length >= MaxMultiInputCount.Value) { if (FrameworkBehaviour.CanShowLog) { Debug.Log("[ToryInput] The maximum number of multi-inputs (" + MaxMultiInputCount + ") reached."); } return(false); } //// Check if the id already exists. //ToryMultiInput<float> found = multiInputList.Find( (obj) => { return obj.Id.Equals(id); } ); //if (found != null) //{ // if (FrameworkBehaviour.CanShowLog) // { // Debug.Log("[ToryInput] The id (" + id + ") passed by a parameter already exists in the MultiInputs array."); // } // return false; //} // Add a new multi-input. ToryMultiInput <Vector3> mi = new ToryVector3MultiInput(id); multiInputList.Add(mi); MultiInputs = multiInputList.ToArray(); mi.ValueReceived += TriggerMultiInputValueReceivedEvent; mi.Interacted += TriggerMultiInputInteractedEvent; if (FrameworkBehaviour.CanShowLog) { Debug.Log("[ToryInput] A new multi-input (ID: " + mi.Id + ") added."); } // Trigger an event. TriggerMultiInputAdded(mi); return(true); }