Author Topic: UICenterOnClick.OnClick() inaccessible due to its protection level  (Read 3932 times)

gamedivisionuk

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 36
    • View Profile
Im getting a problem with UICenterOnClick
Assets/My Files/SearchButton.cs(17,67): error CS0122: `UICenterOnClick.OnClick()' is inaccessible due to its protection level


here is the code,could anyone tell me what i'm doing wrong thanks

using UnityEngine;
using System.Collections;

public class SearchButton : MonoBehaviour {

   public Transform gridContainer;
   public UILabel searchLabel;
   void OnPress ()
   {
      UILabel[] labels = gridContainer.GetComponentsInChildren<UILabel>();
      foreach( UILabel l in labels )
      {
         print("searching " +l.text + " inside " +searchLabel.text);
         if (l.text.Contains(searchLabel.text))
         {
            print("Found");
            l.GetComponent<UICenterOnClick>().OnClick();
            return;
         }
      }
   }
   
}

gamedivisionuk

  • Newbie
  • *
  • Thank You
  • -Given: 1
  • -Receive: 0
  • Posts: 36
    • View Profile
Re: UICenterOnClick.OnClick() inaccessible due to its protection level
« Reply #1 on: June 11, 2014, 03:55:38 PM »
solved by making the void OnClick () public in the UICenterOnClick.cs file