Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

I can’t use « public » anymore

Discussion in 'Scripting' started by Raclette, Nov 18, 2015.

  1. Raclette

    Raclette

    Joined:
    Oct 16, 2012
    Posts:
    15
    Hello I have a very strange issue,

    now if I use « public » I have this error: « error CS1525: Unexpected symbol `public’ »
    I created a new project with a simple test script and I have the same problem.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class Test : MonoBehaviour {
    5.  
    6.     // Use this for initialization
    7.     void Start () {
    8.    
    9.         public float test = 100f;
    10.     }
    11.  
    12. }
    13.  
    Do you understand why?

    Thank you
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
    you don't use public on variables inside functions...
     
    Kiwasi and Sonnenspeer like this.
  3. Raclette

    Raclette

    Joined:
    Oct 16, 2012
    Posts:
    15
    Oups yeah sorry. Thank you!