Post by retsura on Feb 13, 2018 2:27:41 GMT
Hi,
I am creating my own Input Handler script based on Tactics RPG input controller, but i get an error:
Here is my code:
I have googled here and there, and all the answer i got is that i have to make my class public. yet my InputController class has already public.
Instead if I make either the class or the EventHandler not public, the error is gone, but of course, the code also not work.
I use the similar EventHandler for different project (includeng Tatics RPG), yet they work perfectly fine. I wonder if i miss something.
Btw, ButtonList in code above is an Enum listing name of some button.
For InfoEventArgs, its the raw copy from Tactics Rpg:
I am creating my own Input Handler script based on Tactics RPG input controller, but i get an error:
"Inconsistent accessibility: event type `System.EventHandler<InfoEventArgs<ButtonList>>' is less accessible than event `InputController.tombol'"
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using UnityEngine.EventSystems;
public class InputController : MonoBehaviour {
//This line get the error
public static event EventHandler<InfoEventArgs<ButtonList>> tombol;
public void OnArrowDown(){
tombol(this, new InfoEventArgs <ButtonList> (ButtonList.ArrowDown));
Debug.Log ("Tombol Arah Bawah Pressed");
}
public void OnArrowUp(){
tombol(this, new InfoEventArgs <ButtonList> (ButtonList.ArrowUp));
Debug.Log ("Tombol Arah Atas Pressed");
}
public void OnArrowRight(){
tombol(this, new InfoEventArgs <ButtonList> (ButtonList.ArrowRight));
Debug.Log ("Tombol Arah Kanan Pressed");
}
public void OnArrowLeft(){
tombol(this, new InfoEventArgs <ButtonList> (ButtonList.ArrowLeft));
Debug.Log ("Tombol Arah Kiri Pressed");
}
public void OnAction1(){
tombol(this, new InfoEventArgs <ButtonList> (ButtonList.Action1));
Debug.Log ("Tombol Next Pressed");
}
public void OnAction2(){
tombol(this, new InfoEventArgs <ButtonList> (ButtonList.Action2));
Debug.Log ("Tombol Next Pressed");
}
}
I have googled here and there, and all the answer i got is that i have to make my class public. yet my InputController class has already public.
Instead if I make either the class or the EventHandler not public, the error is gone, but of course, the code also not work.
I use the similar EventHandler for different project (includeng Tatics RPG), yet they work perfectly fine. I wonder if i miss something.
Btw, ButtonList in code above is an Enum listing name of some button.
For InfoEventArgs, its the raw copy from Tactics Rpg:
public class InfoEventArgs<T> : EventArgs {
public T info;
public InfoEventArgs(){
info = default(T);
}
public InfoEventArgs(T info){
this.info = info;
}
}