The board administrator and developer will be on vacation until the end of July. Therefore replies will be slower than usual.

Easy Input Input Handler

nathanj
Posts: 218
Joined: Sun Sep 25, 2016 5:38 am

Easy Input Input Handler

Postby nathanj » Tue Aug 08, 2017 11:39 pm

Hey, Everyone

Here is a custom Input handler to work with Ootii's Easy Input. Note that this script requires that Easy Input has a unique Tag of "EasyInput"

I'm working on a Trigger Item Handler but for some reason it's not working. I'll post it when it's done.

Code: Select all

/// <summary>
/// This script provides a custom input handler for Devdog's Inventory Pro and Quest System Pro.
/// </summary>
///

using Devdog.General;
using System;
using System.Collections.Generic;
using Devdog.General.UI;
using UnityEngine;
using UnityEngine.Assertions;
using UnityEngine.EventSystems;
using com.ootii.Input;

namespace VS.ootii.Input
{
    public class EasyInputInputHandler : TriggerInputHandler
    {

        public string ootiiActionName = "ActionAlias";
        private Transform _eiTransform;
        private Sprite uiIcon;
       
        public EasyInputSource _input;
        private InputAlias _alias;
     

        public override void Awake()
        {
            base.Awake();
            //this method will assign EasyInput component to an instance of a Gameobject
            if (_input == null)
            {
                _input = GameObject.FindGameObjectWithTag("EasyInput").GetComponent<com.ootii.Input.EasyInputSource>();
            }

            //search each of the input alias to see if one of them is named after our public string "PickupItem". If so, assign _alias to that instance
            foreach (InputAlias _DAA in _input.DefaultActionAliases)
            {
                if (_DAA.Name == ootiiActionName)
                {
                    _alias = _DAA;
                }
                else
                {
                    _alias.Name = ootiiActionName;
                }
            }
        }

 
        public override bool AreKeysDown()
        {
            if (triggerKeyCode == KeyCode.None)
            {
                return _input.IsJustPressed(_alias.Name);
            }

            return UnityEngine.Input.GetKeyDown(triggerKeyCode);
        }

        public override string ToString()
        {
            return ootiiActionName;
        }
    }
}

Return to “Share custom components”

Who is online

Users browsing this forum: No registered users and 1 guest