Public variables

From ETC Public Wiki
Jump to: navigation, search

Overview


  • Public variables are very useful in Unity.
  • Once you declared a variable public in script, you can access it through the editor.
  • If your public variable is a component object, you can also drag and drop the component to the script through the editor.
  • However, any initial value for the public variable will be overridden by the editor.
  • You would have to initialize it in the start function. For it to not be overridden by the value in the editor.