Skip to content

Commit

Permalink
Fixes #1
Browse files Browse the repository at this point in the history
* Add more features with InputterTester
  • Loading branch information
MrRobinOfficial committed Jul 23, 2022
1 parent 8bcc432 commit d0e85ff
Show file tree
Hide file tree
Showing 51 changed files with 4,071 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Editor.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

28 changes: 28 additions & 0 deletions Editor/ExtensionProcessorEditor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using UnityEditor;
using UnityEngine;
using UnityEngine.InputSystem.Editor;

namespace Inputter
{
public class ExtensionProcessorEditor : InputParameterEditor<ExtensionProcessor>
{
public override void OnGUI()
{
var style = new GUIStyle
{
normal = new GUIStyleState
{
textColor = Color.grey,
},
fontStyle = FontStyle.Italic,
wordWrap = true,
};

EditorGUILayout.LabelField("Note: Action Type must be of Pass Through, in order to work", style);
EditorGUILayout.Space(10f);

target.sensitivitySpeed = EditorGUILayout.FloatField("Sensitivity Speed", target.sensitivitySpeed);
target.gravitySpeed = EditorGUILayout.FloatField("Gravity Speed", target.gravitySpeed);
}
}
}
11 changes: 11 additions & 0 deletions Editor/ExtensionProcessorEditor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions Editor/Inputter.Editor.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "Inputter.Runtime.Editor",
"rootNamespace": "",
"references": [
"GUID:4cb071ee81692854ab0e0c65eb9ba25e",
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Editor/Inputter.Editor.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions Editor/Inputter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEditor;

namespace Inputter.Editor
{
/// <summary>
/// Adds the given define symbols to PlayerSettings define symbols.
/// Just add your own define symbols to the Symbols property at the below.
/// </summary>
[InitializeOnLoad]
public class Inputter : UnityEditor.Editor
{
/// <summary>
/// Symbols that will be added to the editor
/// </summary>
public static readonly string[] Symbols = new[]
{
"INPUTTER"
};

/// <summary>
/// Add define symbols as soon as Unity gets done compiling.
/// </summary>
static Inputter()
{
var definesString = PlayerSettings.GetScriptingDefineSymbolsForGroup(EditorUserBuildSettings.selectedBuildTargetGroup);

var allDefines = definesString.Split(';').ToList();

allDefines.AddRange(Symbols.Except(allDefines));

PlayerSettings.SetScriptingDefineSymbolsForGroup(
EditorUserBuildSettings.selectedBuildTargetGroup,
string.Join(";", allDefines.ToArray()));
}

}
}
11 changes: 11 additions & 0 deletions Editor/Inputter.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2021 MrRobin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
7 changes: 7 additions & 0 deletions LICENSE.txt.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions README.md.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Runtime.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions Runtime/ExtensionProcessor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#if UNITY_EDITOR
using UnityEditor;
#endif

using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Scripting;

namespace Inputter
{
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
[Preserve]
public class ExtensionProcessor: InputProcessor<float>
{
[Tooltip("Sensitivity Speed")]
public float sensitivitySpeed = 0;

[Tooltip("Gravity Speed")]
public float gravitySpeed = 0;

[HideInInspector]
private float previousValue = 0f;

public override float Process(float value, InputControl control)
{
if (value == 0)
previousValue = Mathf.MoveTowards(previousValue, 0f, gravitySpeed * Time.unscaledDeltaTime);

previousValue = Mathf.MoveTowards(previousValue, value, sensitivitySpeed * Time.unscaledDeltaTime);
return previousValue;
}

#if UNITY_EDITOR
static ExtensionProcessor() => Initialize();
#endif

[RuntimeInitializeOnLoadMethod]
static void Initialize() => InputSystem.RegisterProcessor<ExtensionProcessor>();
}
}
11 changes: 11 additions & 0 deletions Runtime/ExtensionProcessor.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions Runtime/Inputter.Runtime.asmdef
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "Inputter.Runtime",
"rootNamespace": "",
"references": [
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": true,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
7 changes: 7 additions & 0 deletions Runtime/Inputter.Runtime.asmdef.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit d0e85ff

Please sign in to comment.