Documentation

​
​

Development

User Acquisition

Monetization

Industry

Unity Studio

Open Unity Studio

Unity Studio

​
​
Unity Studio
  • What's new in Unity Studio
  • Introduction to Unity Studio
  • Launch Unity Studio
  • Create your first Unity Studio project
  • Develop with Unity Studio
    • The Unity Studio interface
    • Save your progress
    • GameObjects
    • Assets
    • Materials
    • Scene settings
    • Logic
      • Introduction to Logic
      • Create a Logic script
      • The Logic Editor interface
      • Methods, variables, and parameters
        • Introduction to variables, methods and parameters
        • Create a variable
        • New Variable window reference
        • Create a method
        • New Method window UI reference
      • Nodes
      • Logic examples
    • The UI Creator
    • Animation
    • AI features
  • Collaborate in Unity Studio
  • Export drafts to the Unity Editor
  • Publish and share
  • Troubleshooting Unity Studio issues
  • Report bugs and share feedback
  • Manage your analytics and marketing preferences
  1. Unity Studio
  2. Develop with Unity Studio
  3. Logic
  4. Methods, variables and parameters

Create a variable

Instructions on how to create a variable for your Logic script.
Read time 1 minute
Last updated 2 months ago

Create variables to store data that your Logic script can use and modify. Remember to assign any references after creating variables.
To create a variable, use the following steps:
  1. Open your Logic script.
  2. Select the Add (+) icon next to Variables. The New Variable window appears.
  3. Change the settings to your preferences.
  4. Select Create.

Assign references

To set variable values:
  1. Select your GameObject that has your Logic attached. The Inspector panel shows.
  2. In the Inspector, find your Logic.
  3. Either set the variable value, or drag an object from the Hierarchy panel into the variable slot.
Tip
Unity Studio highlights missing references in orange in the Logic component. Orange Bug notifications remain on the bug icon in the Scene view until you fix them.

Additional resources

  • Introduction to Logic
  • The Logic Editor interface
  • Create a Logic script
  • Methods and variables
  • Nodes

Copyright © 2026 Unity Technologies
LegalPrivacy PolicyCookiesDocumentation Terms of UseDo Not Sell or Share My Personal InformationYour Privacy Choices (Cookie Settings)

"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S and elsewhere (more info here). Other names or brands are trademarks of their respective owners.

Some pages are machine-translated for convenience, and may contain inaccuracies. In the event of conflicting information, the English version is authoritative.

  • On this page
    • Assign references

    • Additional resources


Report a problem with this page