Question by
elifnurber · Oct 10, 2020 at 04:04 PM ·
erroraccessing from any script
CS0122 'Move1.MoveClick()' is inaccessible due to its protection level. I cound not acces a funtion from another script. I got this error.
I tried so many way to acces MoveClick(); function from ButtonController script but i got error -> CS0122 'Move1.MoveClick()' is inaccessible due to its protection. But i couldnt find anything. Everything is public.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Move1 : MonoBehaviour
{
public void MoveClick()
{
Debug.Log("You are moving...");
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ButtonController : MonoBehaviour
{
public Button firstButton;
public Move1 move = GameObject.FindObjectOfType(typeof(Move1)) as Move1;
public void Start()
{
firstButton.onClick.AddListener(move.MoveClick());
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613013510im_/https://answers.unity.com/themes/thub/images/avi.jpg)