/// <summary> /// handles all assigned controls for one axis /// </summary> /// <param name="theControls"></param> /// <returns></returns> float HandleControlAxis(control_axis[] theControls, out bool theReset) { theReset = false; float aValue = 0.0f; for(int i = 0; i< theControls.Length; i++) { control_axis aControlAxis = theControls[i]; float aSign = 1.0f; if (aControlAxis.itsInvertAxis) { aSign = -1.0f; } if(aControlAxis.itsAdditionalKey == KeyCode.None && aControlAxis.itsAdditionalMouseButton == control_axis.eMouseButton.eNone) { float anAxis = 0.0f; try { anAxis = Input.GetAxis(aControlAxis.itsAxisName); } catch(Exception theException) { Debug.LogError("KGFOrbitcam exception: "+theException); return 0.0f; } aValue += anAxis*aControlAxis.itsAxisSensitivity*aSign; } else { if(Input.GetKey(aControlAxis.itsAdditionalKey) || Input.GetMouseButton((int)aControlAxis.itsAdditionalMouseButton)) { aValue += Input.GetAxis(aControlAxis.itsAxisName)*aControlAxis.itsAxisSensitivity*aSign; } else { if(aControlAxis.itsResetRotationOnRelease) { theReset = true; } } } } return aValue; }
/// <summary> /// Sets the vertical controls /// </summary> /// <returns></returns> public void SetRotationVerticalControls(control_axis[] theControls) { itsRotation.itsVertical.itsControls = theControls; }
/// <summary> /// Sets the horizontal controls /// </summary> /// <returns></returns> public void SetZoomControls(control_axis[] theControls) { itsZoom.itsControls = theControls; }
/// <summary> /// Sets the horizontal controls /// </summary> /// <returns></returns> public void SetRotationHorizontalControls(control_axis[] theControls) { itsRotation.itsHorizontal.itsControls = theControls; }
/// <summary> /// Sets the Up Down controls /// </summary> /// <returns></returns> public void SetPanningUpDownControls(control_axis[] theControls) { itsPanning.itsUpDown.itsControls = theControls; }
/// <summary> /// Sets the left right controls /// </summary> /// <returns></returns> public void SetPanningLeftRightControls(control_axis[] theControls) { itsPanning.itsLeftRight.itsControls = theControls; }
/// <summary> /// Sets the Forward Backward controls /// </summary> /// <returns></returns> public void SetPanningForwardBackwardControls(control_axis[] theControls) { itsPanning.itsForwardBackward.itsControls = theControls; }
/// <summary> /// validate controls /// </summary> /// <param name="theControlAxis"></param> /// <returns></returns> public static KGFMessageList ValidateControls(control_axis[] theControlAxis, string theDebugPrefix) { KGFMessageList aMessageList = new KGFMessageList(); for(int i = 0; i< theControlAxis.Length; i++) { control_axis aControlAxis = theControlAxis[i]; if(aControlAxis.itsAxisSensitivity < 0) { aMessageList.AddError ("control axis sensitivity cannot be smaller than 0!"); } bool anException = false; try { Input.GetAxis(aControlAxis.itsAxisName); } catch(Exception theException) { Debug.LogError("KGFOrbitcamException: "+theException); anException = true; } if(anException) { aMessageList.AddError(theDebugPrefix+"["+i+"].itsAxisName: '"+aControlAxis.itsAxisName+"' is not defined in unity input settings"); } } return aMessageList; }