#this is in managerUi cs but when i

1 messages · Page 1 of 1 (latest)

zinc bramble
#

what exactly is the issue you're having?

unkempt finch
#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;

public class managerUi : MonoBehaviour
{
    public managerWeaponChange mngrWeaponChange;
    // Start is called before the first frame update
    void Start()
    {
        mngrWeaponChange = GameObject.FindGameObjectWithTag("Player").GetComponent<managerWeaponChange>();
    }
    public void ButtonWeaponChange()
    {
        Debug.Log(EventSystem.current.currentSelectedGameObject);
        GameObject tempBtn = EventSystem.current.currentSelectedGameObject;
        int tempBtnIndex = tempBtn.transform.GetSiblingIndex();

        mngrWeaponChange.ChangeWeapon(tempBtnIndex);
        //Debug.Log (tempBtn + ":" + tempBtnIndex);
    }
    
}
#

this is manageUi.cs

#

this is KeyPress.cs

#
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;

public class KeyPress : MonoBehaviour
{
    public KeyCode _Key;
    public Button managerUi;
    void Awake()
    {
        managerUi = GetComponent<Button>();
    }
    void Update()
    {
        if(Input.GetKeyDown(_Key))
        {
            FadeToColor(managerUi.colors.pressedColor);
            managerUi.onClick.Invoke();
        }
        else if(Input.GetKeyUp(_Key))
        {
            FadeToColor(managerUi.colors.normalColor);
        }
    }

    void FadeToColor(Color color)
    {
        Graphic graphic = GetComponent<Graphic>();
        graphic.CrossFadeColor(color, managerUi.colors.fadeDuration, true, true);
    }

}```
uncut bane
#

relax

#

no one cares about this code

#

no one needs to see it

unkempt finch
uncut bane
#

click the replace button

unkempt finch
uncut bane
#

yes

unkempt finch
#

replace with the inputsystem?

uncut bane
#

yes

zinc bramble
#

the one under the big red error icon

unkempt finch
#

done

#

what now?

uncut bane
#

now see if it works

unkempt finch
#

ok

#

no :((

unkempt finch
hexed mica
#

GameObject tempBtn = EventSystem.current.currentSelectedGameObject; is null, fix that

zinc bramble
#

bro you gotta learn about naming conventions

#

your code is really hard to read. also, you should be able to assign tempbtn in the inspector