protected override void SelectInputType() { // [DGT] // First, look for Control Freak 2 rig with UFE Bridge component... InputTouchControllerBridge bridge = GameObject.FindObjectOfType <InputTouchControllerBridge>(); if (bridge != null) { this.InitializeTouchControllerBridge(bridge); return; } // Then, look for Control Freak 1.x controller... else { Type type = UFE.SearchClass("TouchController"); UnityEngine.Object touchController = null; if ((type != null) && ((touchController = GameObject.FindObjectOfType(type)) != null)) { this.InitializeControlFreakTouchController(touchController); return; } } // If nothing found, use standard Input... base.SelectInputType(); }
public virtual void GoToControlsScreen() { if (UFE.isCInputInstalled && UFE.config.inputOptions.inputManagerType == InputManagerType.cInput) { UFE.SearchClass("cGUI").GetMethod( "ToggleGUI", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] {}, null ).Invoke(null, null); } }
protected override void SelectInputType() { Type type = UFE.SearchClass("TouchController"); UnityEngine.Object touchController = null; if (type != null) { touchController = GameObject.FindObjectOfType(type); } if (touchController != null) { this.InitializeControlFreakTouchController(touchController); } else { base.SelectInputType(); } }
public virtual void GoToControlsScreen() { if (UFE.config.inputOptions.inputManagerType == InputManagerType.cInput && UFE.isCInputInstalled) { UFE.SearchClass("cGUI").GetMethod( "ToggleGUI", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { }, null ).Invoke(null, null); } else if (UFE.config.inputOptions.inputManagerType == InputManagerType.Rewired && UFE.isRewiredInstalled) { if (RewiredInputController.inputConfiguration != null) { RewiredInputController.inputConfiguration.ShowInputConfigurationUI(() => UFE.StartOptionsScreen(0.1f)); // show the config screen and return to Options screen when screen is closed Destroy(this.gameObject); // close options screen when control config UI is opened to prevent UFEScreen navigation system from interfering } } }
public static void CreateAsset <T> () where T : ScriptableObject { T asset = ScriptableObject.CreateInstance <T> (); string path = AssetDatabase.GetAssetPath(Selection.activeObject); if (path == "") { path = "Assets"; } else if (Path.GetExtension(path) != "") { path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(Selection.activeObject)), ""); } string fileName; if (asset is MoveInfo) { fileName = "New Move"; } else if (asset is CharacterInfo) { fileName = "New Character"; } else if (asset.GetType().ToString().Equals("AIInfo")) { fileName = "New AI Instructions"; } else if (asset is GlobalInfo) { fileName = "UFE_Config"; } else { fileName = typeof(T).ToString(); } string assetPathAndName = AssetDatabase.GenerateUniqueAssetPath(path + "/" + fileName + ".asset"); AssetDatabase.CreateAsset(asset, assetPathAndName); AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; if (asset is MoveInfo) { MoveEditorWindow.Init(); } else if (asset is GlobalInfo) { GlobalEditorWindow.Init(); } else if (asset.GetType().ToString().Equals("AIInfo")) { UFE.SearchClass("AIEditorWindow").GetMethod( "Init", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, null, null ).Invoke(null, new object[] {}); } else if (asset is CharacterInfo) { CharacterEditorWindow.Init(); } }
protected virtual void InitializeCInput() { // If cInput is defined, use cInput Type inputType = UFE.SearchClass("cInput"); if (inputType != null) { // Retrieve the required methods using the Reflection API to avoid // compilation errors if cInput hasn't been imported into the project // We will cache the method information to call these methods later MethodInfo getAxisInfo = inputType.GetMethod( "GetAxis", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string) }, null ); if (getAxisInfo != null) { this.getAxis = delegate(string axis){ return((float)getAxisInfo.Invoke(null, new object[] { axis })); }; } MethodInfo getAxisRawInfo = inputType.GetMethod( "GetAxisRaw", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string) }, null ); if (getAxisRawInfo != null) { this.getAxisRaw = delegate(string axis){ return((float)getAxisRawInfo.Invoke(null, new object[] { axis })); }; } MethodInfo getButtonInfo = inputType.GetMethod( "GetButton", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string) }, null ); if (getButtonInfo != null) { this.getButton = delegate(string button){ return((bool)getButtonInfo.Invoke(null, new object[] { button })); }; } MethodInfo setAxisInfo = inputType.GetMethod( "SetAxis", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string), typeof(string), typeof(string) }, null ); Action <string, string, string> setAxis = delegate(string axis, string negativeButton, string positiveButton){ setAxisInfo.Invoke(null, new object[] { axis, negativeButton, positiveButton }); }; MethodInfo setKeyInfo = inputType.GetMethod( "SetKey", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string), typeof(string), typeof(string) }, null ); Action <string, string, string> setKey = delegate(string key, string primary, string secondary){ setKeyInfo.Invoke(null, new object[] { key, primary, secondary }); }; MethodInfo isAxisDefinedInfo = inputType.GetMethod( "IsAxisDefined", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string) }, null ); Func <string, bool> isAxisDefined = delegate(string axis){ return((bool)isAxisDefinedInfo.Invoke(null, new object[] { axis })); }; MethodInfo isKeyDefinedInfo = inputType.GetMethod( "IsKeyDefined", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, new Type[] { typeof(string) }, null ); Func <string, bool> isKeyDefined = delegate(string key){ return((bool)isKeyDefinedInfo.Invoke(null, new object[] { key })); }; PropertyInfo allowDuplicatesInfo = inputType.GetProperty("allowDuplicates"); allowDuplicatesInfo.SetValue( null, Convert.ChangeType(UFE.config.inputOptions.cInputAllowDuplicates, allowDuplicatesInfo.PropertyType), null ); inputType.GetField("gravity").SetValue(null, UFE.config.inputOptions.cInputGravity); inputType.GetField("sensitivity").SetValue(null, UFE.config.inputOptions.cInputSensitivity); inputType.GetField("deadzone").SetValue(null, UFE.config.inputOptions.cInputDeadZone); // Iterate over all the input references... foreach (InputReferences input in this.inputReferences) { // Check the type of input... if (input.inputType == InputType.Button) { // If this input reference represents the vertical axis, // check if the reference is defined in cInput... if (!isKeyDefined(input.inputButtonName)) { string defaultKey = input.cInputPositiveDefaultKey; string alternativeKey = input.cInputPositiveAlternativeKey; if (string.IsNullOrEmpty(defaultKey)) { defaultKey = this.None; } if (string.IsNullOrEmpty(alternativeKey)) { alternativeKey = this.None; } // If it wasn't defined, define the input with the default values setKey(input.inputButtonName, defaultKey, alternativeKey); } } else { string negativeKeyName = input.cInputNegativeKeyName; string positiveKeyName = input.cInputPositiveKeyName; string negativeDefaultKey = input.cInputNegativeDefaultKey; string positiveDefaultKey = input.cInputPositiveDefaultKey; string positiveAlternativeKey = input.cInputPositiveAlternativeKey; string negativeAlternativeKey = input.cInputNegativeAlternativeKey; if (input.inputType == InputType.HorizontalAxis) { // If this input reference represents the horizontal axis, // check if we should use the default values... if (string.IsNullOrEmpty(negativeKeyName)) { negativeKeyName = input.inputButtonName + "_Left"; } if (string.IsNullOrEmpty(positiveKeyName)) { positiveKeyName = input.inputButtonName + "_Right"; } if (string.IsNullOrEmpty(negativeDefaultKey)) { negativeDefaultKey = "LeftArrow"; } if (string.IsNullOrEmpty(positiveDefaultKey)) { positiveDefaultKey = "RightArrow"; } } else { // If this input reference represents the vertical axis, // check if we should use the default values... if (string.IsNullOrEmpty(negativeKeyName)) { negativeKeyName = input.inputButtonName + "_Down"; } if (string.IsNullOrEmpty(positiveKeyName)) { positiveKeyName = input.inputButtonName + "_Up"; } if (string.IsNullOrEmpty(negativeDefaultKey)) { negativeDefaultKey = "DownArrow"; } if (string.IsNullOrEmpty(positiveDefaultKey)) { positiveDefaultKey = "UpArrow"; } } if (string.IsNullOrEmpty(positiveAlternativeKey)) { positiveAlternativeKey = this.None; } if (string.IsNullOrEmpty(negativeAlternativeKey)) { negativeAlternativeKey = this.None; } // Finally, check if the axis is defined in cInput... if (!isAxisDefined(input.inputButtonName)) { if (!isKeyDefined(negativeKeyName)) { setKey(negativeKeyName, negativeDefaultKey, negativeAlternativeKey); } if (!isKeyDefined(positiveKeyName)) { setKey(positiveKeyName, positiveDefaultKey, positiveAlternativeKey); } setAxis(input.inputButtonName, negativeKeyName, positiveKeyName); } } } } }
public static void CreateAsset <T> (T data = null, T oldFile = null) where T : ScriptableObject { T asset = ScriptableObject.CreateInstance <T> (); Object referencePath = Selection.activeObject; if (data != null) { asset = data; if (oldFile != null) { referencePath = oldFile; } } string path = AssetDatabase.GetAssetPath(referencePath); if (path == "") { path = "Assets"; } else if (Path.GetExtension(path) != "") { path = path.Replace(Path.GetFileName(AssetDatabase.GetAssetPath(referencePath)), ""); } string fileName; if (oldFile != null) { fileName = oldFile.name; } else if (asset is MoveInfo) { fileName = "New Move"; } else if (asset is UFE3D.CharacterInfo) { fileName = "New Character"; } else if (asset.GetType().ToString().Equals("UFE3D.AIInfo")) { fileName = "New AI Instructions"; } else if (asset is GlobalInfo) { fileName = "New UFE Config"; } else if (asset is StanceInfo) { fileName = "New Combat Stance"; } else { fileName = typeof(T).ToString(); } string assetPathAndName = oldFile != null? path + fileName + ".asset" : AssetDatabase.GenerateUniqueAssetPath(path + "/" + fileName + ".asset"); if (!AssetDatabase.Contains(asset)) { AssetDatabase.CreateAsset(asset, assetPathAndName); } AssetDatabase.SaveAssets(); EditorUtility.FocusProjectWindow(); Selection.activeObject = asset; if (asset is MoveInfo) { MoveEditorWindow.Init(); } else if (asset is GlobalInfo) { GlobalEditorWindow.Init(); } else if (asset.GetType().ToString().Equals("UFE3D.AIInfo")) { UFE.SearchClass("AIEditorWindow").GetMethod( "Init", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy, null, null, null ).Invoke(null, new object[] {}); } else if (asset is UFE3D.CharacterInfo) { CharacterEditorWindow.Init(); } }