// ---------------------------- static protected void SetupAxisBinding(AxisBinding binding, string axisName) { binding.Clear(); if (!string.IsNullOrEmpty(axisName)) { binding.Enable(); binding.AddTarget().SetSingleAxis(axisName, false); } }
// ------------------ public void Draw(AxisBinding bind, InputRig rig) { bool bindingEnabled = bind.enabled; EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); bindingEnabled = EditorGUILayout.ToggleLeft(this.labelContent, bindingEnabled, GUILayout.MinWidth(30)); if (bindingEnabled) { if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texPlusSign, "Add target"), CFEditorStyles.Inst.iconButtonStyle)) //, GUILayout.Width(20), GUILayout.Height(20))) { CFGUI.CreateUndo("Add new target to Analog Binding.", this.undoObject); bind.AddTarget(); CFGUI.EndUndo(this.undoObject); } if (GUILayout.Button(new GUIContent(CFEditorStyles.Inst.texMinusSign, "Remove target"), CFEditorStyles.Inst.iconButtonStyle)) //, GUILayout.Width(20), GUILayout.Height(20))) { CFGUI.CreateUndo("Remove target from Analog Binding.", this.undoObject); bind.RemoveLastTarget(); CFGUI.EndUndo(this.undoObject); } } EditorGUILayout.EndHorizontal(); if (bindingEnabled) { CFGUI.BeginIndentedVertical(CFEditorStyles.Inst.transpSunkenBG); if (this.customExtraGUI != null) { this.customExtraGUI(); } this.PrepareTargetElemListInspectors(bind.targetList.Count); if (bind.targetList.Count == 0) { EditorGUILayout.LabelField("No targets defined...", CFEditorStyles.Inst.centeredTextTranspBG); } else { for (int i = 0; i < bind.targetList.Count; ++i) { this.targetElemInspList[i].DrawGUI(bind.targetList[i], rig, (i == (bind.targetList.Count - 1))); } } CFGUI.EndIndentedVertical(); } EditorGUILayout.EndVertical(); if ((bindingEnabled != bind.enabled) ) { CFGUI.CreateUndo("Analog Axis Binding modification.", this.undoObject); bind.enabled = bindingEnabled; CFGUI.EndUndo(this.undoObject); } }
// --------------- public void Execute() { if (this.binding == null) { return; } CFGUI.CreateUndo(this.undoLabel, this.undoObject); DigitalBinding digiBinding = (this.binding as DigitalBinding); AxisBinding analogBinding = (this.binding as AxisBinding); EmuTouchBinding touchBinding = (this.binding as EmuTouchBinding); MousePositionBinding mouseBinding = (this.binding as MousePositionBinding); //JoystickNameBinding joyNameBinding = (this.binding as JoystickNameBinding); // Digi binding... if (digiBinding != null) { if (this.digiKey != KeyCode.None) { digiBinding.Enable(); if (this.digiKeyElemId < 0) { digiBinding.AddKey(this.digiKey); } else { digiBinding.ReplaceKey(this.digiKeyElemId, this.digiKey); } } if (!string.IsNullOrEmpty(this.digiAxisName)) { digiBinding.Enable(); DigitalBinding.AxisElem elem = null; if (this.digiAxisElemId < 0) { elem = digiBinding.AddAxis(); } else { elem = digiBinding.GetAxisElem(this.digiAxisElemId); } if (elem != null) { elem.SetAxis(this.digiAxisName, this.digiBindToPositiveAxis); } } } // Analog Binding... else if (analogBinding != null) { if (!string.IsNullOrEmpty(this.analogAxisName)) { analogBinding.Enable(); AxisBinding.TargetElem elem = null; if (this.analogElemId < 0) { elem = analogBinding.AddTarget(); } else { elem = analogBinding.GetTarget(this.analogElemId); } if (elem != null) { if (this.analogSeparate) { elem.SetSeparateAxis(this.analogAxisName, this.analogPositiveSide, !this.analogFlip); } else { elem.SetSingleAxis(this.analogAxisName, this.analogFlip); } } } } // Touch Binding... else if (touchBinding != null) { touchBinding.Enable(); } // Mouse Binding... else if (mouseBinding != null) { mouseBinding.Enable(); } CFGUI.EndUndo(this.undoObject); if (this.onRefreshCallback != null) { this.onRefreshCallback(); } }