Giter VIP home page Giter VIP logo

orange-panda / rewired-glyphs Goto Github PK

View Code? Open in Web Editor NEW
21.0 1.0 4.0 3.01 MB

An expansion for Guavaman's Rewired Unity Asset that provides a simple to use API for showing input icons to the player at runtime based on their input method and bindings.

Home Page: https://orange-panda.github.io/Rewired-Glyphs/

License: MIT License

C# 82.12% CSS 11.00% JavaScript 6.88%
extension glyphicons glyphs icons input rewired ui unity unity3d-package unitypackage

rewired-glyphs's Introduction

Rewired Input Glyphs

Rewired Input Glyphs Logo

An expansion for Guavaman's Rewired Unity Asset that provides a simple to use API for showing input icons to the player at runtime based on their input method and bindings.

Features

Features

  • Features numerous built in components to quickly show an icon for an action
  • Automatically changes sprites to show the user's most recently used device
  • Can show multiple sprites inline with text using TextMeshPro sprite sheets

Requirements

  • A Unity project of Unity 2020.3 or later
  • Ownership of the Rewired Unity asset

Quick Start Guide

  1. Download and install the Rewired asset into your Unity project
    1. See Rewired's Quick Start for more information on getting started with Rewired.
    2. Note: The Rewired asset will never be included in this package. Purchasing Rewired from the Unity Asset Store is required for this asset to function.
  2. Install the package via Git in the Package Manager
    1. Ensure you have Git installed on your system
    2. In Unity go to Window -> Package Manager
    3. Press the + icon at the top left of the Package Manager window
    4. Choose "Add package from Git URL"
    5. Enter the following into the field and press enter:
      1. Tip: You can append a version to the end of the Git URL to lock it to a specific version such as https://github.com/Orange-Panda/Rewired-Glyphs.git#2.0.0
    https://github.com/Orange-Panda/Rewired-Glyphs.git
    
    1. Refer to the official Unity documentation for more info on installing packages through Git
  3. Import the Kenney Default Glyphs (Pixel Art) or Xelu Default Glyphs sample from this package in the Package Manager.
    1. This will import CC0 licensed input sprites by Kenney or Xelu alongside GlyphMap and GlyphCollection assets that associate inputs to glyphs.
    2. By default this should import to your project at Assets/Samples/Rewired Input Glyphs/{version}/{sample name}
    3. Feel free to move these files to any location you'd prefer
    4. If you use these glyphs in your application you are encouraged to support their creator when possible
  4. Find the Rewired Input Manager prefab in your project and add the Rewired Glyph Manager component to it.
    1. This component and others in the package can be found in the Add Component menu under Rewired Glyphs
  5. Add the Glyph Collection imported from step 3 to the Rewired Glyph Manager
  6. Press the Generate TMP Sprite Sheet button on the Rewired Glyph Manager
    1. This generates TextMeshPro sprite sheets that allow for inline input glyph icons with your text.
  7. You are ready to go! Check out the usage section below to start displaying the icons in your project!

Usage

There are several ways to show input glyphs in your project such as:

  • Built-in components
  • Custom components
  • Polling the InputGlyphs API directly

Let's cover some of these methods and how to use them in your project.

Built-in Components

  • GlyphRichTextFormatter - Attach this component to a Game Object with a TMP_Text and it will format text such as <glyph "Jump"> into an inline sprite that represents that action.
    • <glyph "Jump"> will show the jump input sprite for player at index 0
    • <glyph "Move Horizontal" 1 Negative> will show the move left input sprite for player at index 1
    • <glyph 13 0> will show the action #13 input sprite for player at index 0
    • <glyph "Move Horizontal" Full> will show the move left or right input sprite for player at index 0
  • GlyphImageOutput - Show an input icon for an action, even if there is no sprite.
  • GlyphTextOutput - Show an input description for an action.
  • GlyphHybridOutput - Show an input icon for an action or fallback to text if there is no sprite available.
  • GlyphLabeledImageOutput - Show an input icon with an associated but independent TMP_Text and set their layout.

Custom Components

Custom components can be created by inheriting from GlyphDisplay. This class provides the void SetGlyph(Glyph glyph, AxisRange axisRange) method which is automatically invoked when a glyph may have changed such as a input device changes or preferences modifications.

Most of the built-in components inherit from GlyphDisplay so consider referencing them for examples.

Polling the InputGlyphs API

If you wanted tighter control over your implementation of presenting glyphs you can also use the InputGlyphs class to get glyph information yourself. Some important members to consider are the following:

  • event Action RebuildGlyphs - A static event which is invoked whenever the Glyph output of this class may have changed.
  • Glyph GetCurrentGlyph(int actionID, Pole pole, out AxisRange axisRange, int playerIndex = 0) - Get the Glyph for particular player's action.
  • void SetGlyphPreferences(HardwarePreference hardwarePreference, SymbolPreference symbolPreference) - Set the preferred symbols you want to present to the user.

Documentation

For more information check out the official documentation for articles and API reference.

Getting Help

Credits

This package is developed by Luke Mirman under the MIT License.

  • Joystick icon used in the logo and icons used in component icons are provided by Google Fonts under the Appache 2.0 license.
  • Lato font in the logo is provided by Google Fonts under the Open Font License.
  • Project sample glyph icons included in package were created by Kenney and Xelu (respectively) and distributed under Creative Commons CC0 license.
    • Some icons were altered from their original state
  • DocFX Documentation template provided by Singulink under MIT license
  • Guavaman for developing the Rewired asset this package supports

Disclaimer

The development of this package is not associated with Rewired or Guavaman. Do not contact Rewired support for any issues you encounter with this package.

rewired-glyphs's People

Contributors

orange-panda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

rewired-glyphs's Issues

[BUG] - Crashes completely when adding Image Output with Rewired Input Manager in Prefab Mode

Rewired: You are attemping to access an object that was created by a previous session or different instance of Rewired and is no longer valid. When Rewired is reset or the Rewired Input Manager is disabled or destroyed, all old object references become invalid and can no longer be used. If you deinitialize Rewired, you cannot use locally stored Rewired objects obtained prior to deinitialization and you must get new objects from the Rewired API.
------- Rewired System Info -------
Unity version: 2022.3.5f1
Rewired version: 1.1.45.0.U2022
Platform: Windows
Editor Platform: Windows
Using Unity input: False
Primary input source: RawInput
Use XInput: True
Native mouse handling: True
Enhanced device support: True

UnityEngine.Logger:LogError (string,object)
Rewired.Logger:LogErrorNow (object,bool)
Rewired.Logger:LogError (object,bool)
Rewired.Logger:LogError (object)
Rewired.ReInput:CheckInitialized (int)
Rewired.Player/ControllerHelper:GetLastActiveController ()
LMirman.RewiredGlyphs.InputGlyphs:GetCurrentGlyph (Rewired.Player,int,Rewired.Pole,Rewired.AxisRange&) (at ./Library/PackageCache/com.lmirman.rewiredglyphs@2676334172/Runtime/API/InputGlyphs.cs:128)
LMirman.RewiredGlyphs.InputGlyphs:GetCurrentGlyph (int,Rewired.Pole,Rewired.AxisRange&,int) (at ./Library/PackageCache/com.lmirman.rewiredglyphs@2676334172/Runtime/API/InputGlyphs.cs:120)
LMirman.RewiredGlyphs.Components.GlyphDisplay:UpdateGlyph () (at ./Library/PackageCache/com.lmirman.rewiredglyphs@2676334172/Runtime/Components/GlyphDisplay.cs:60)
LMirman.RewiredGlyphs.Components.GlyphDisplay:InputGlyphsOnRebuildGlyphs () (at ./Library/PackageCache/com.lmirman.rewiredglyphs@2676334172/Runtime/Components/GlyphDisplay.cs:54)
LMirman.RewiredGlyphs.InputGlyphs:InvokeRebuild (bool) (at ./Library/PackageCache/com.lmirman.rewiredglyphs@2676334172/Runtime/API/InputGlyphs.cs:329)
LMirman.RewiredGlyphs.RewiredGlyphManager:Update () (at ./Library/PackageCache/com.lmirman.rewiredglyphs@2676334172/Runtime/API/RewiredGlyphManager.cs:58)

[BUG] - GlyphRichTextFormatter not updating glyphs when inactive

Bug Description
GlyphRichTextFormatter is not updated if set to inactive in the same frame the input type changes

Reproduction Steps

  1. Have a Rewired action (e.g. Cancel) mapping to "B" for xbox controller or "ESC" for keyboard
  2. Have a window with a button with a GlyphRichTextFormatter label for that action (<glyph "Cancel">Cancel)
  3. Use the gamepad input so the button updates the glyph accordingly.
  4. Press ESC to close the window and then open again via keyboard input.
  5. The GlyphRichTextFormatter will show the glyph for gamepad input.

Expected Behavior
At step 5, the text should show the glyph for keyboard.

Technical Information(please complete the following information):

  • Unity Version: 2022.3.12f1

Possible Solution
Update the glyphs on the GlyphRichTextFormatter 's OnEnable method.
This bug may also happen in the other glyph displaying components.

[BUG] Many errors in project after importing package

Bug Description
After importing the Rewired Glyphs package, I get 26 errors in the console. Unity will not enter play mode, prompting me to fix all compiler errors first. But the errors do not show up in Visual Studio, only in the Unity Console. This first happened in a project I was working on. Tested it in empty project and it happened there as well.

Reproduction Steps
Steps to reproduce the behavior:

  1. Create new project in Unity 2020.3.25f1
  2. Import Rewired (1.1.55.0)
  3. Import TMP Essentials
  4. Import Rewired Glyphs using Package manager -> Add Package from Git URL -> https://github.com/Orange-Panda/Rewired-Glyphs.git

Expected Behavior
Successful import. No errors in console.

Example
Screenshot of errors:
Screenshot 2024-06-24 225531

Text examples of errors:

Library\PackageCache\com.lmirman.rewiredglyphs@8507d6c\Runtime\Components\GlyphRichTextFormatter.cs(200,65): error CS1026: ) expected
Library\PackageCache\com.lmirman.rewiredglyphs@8507d6c\Runtime\Components\GlyphDisplay.cs(170,58): error CS1026: ) expected
Library\PackageCache\com.lmirman.rewiredglyphs@8507d6c\Runtime\API\RewiredGlyphManager.cs(93,57): error CS1003: Syntax error, ',' expected
Library\PackageCache\com.lmirman.rewiredglyphs@8507d6c\Runtime\Components\GlyphRichTextFormatter.cs(203,6): error CS8641: 'else' cannot start a statement.

Technical Information:

  • Operating System and Version: Windows 11
  • Unity Version: 2020.3.25f1

Additional Information
I think these errors are so strange. They don't seem like "real" errors. so I suspect it can have something to do with the dev environment, some hidden settings in unity about namespaces or some other oddball technicality, but right now I am at a loss.

[REQUEST] - Add possiblity to separate between mouse glyphs and keyboard glyphs

Is your feature request related to a problem? Please describe.
I want to use glyphs in the context of keybindings remapping and the lack of distinction between mouse and keyboard glyphs is a problem.

Describe the solution you'd like
I think adding methods GetMouseGlyph and GetKeyboardGlyph in addition to the existing options would make InputGlyphs API much more flexible in terms of further extension.

Edit:
I think this could be also solved by exposing InputGlyphs.GetGlyphFromHardwareMap to the public API.

[BUG] -

Bug Description
A clear and concise description of what the bug is.

Reproduction Steps
Steps to reproduce the behavior:

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected Behavior
A clear and concise description of what you expected to happen.

Example
If possible, add screenshots or a video to help explain your problem.

Technical Information(please complete the following information):

  • Operating System and Version: [e.g. Windows 11 22H2, macOS 13.3.1]
  • Unity Version: [e.g 2020.3.42f1]

Additional Information
Add any other context about the problem here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.