기술 자료

​
​

Development

User Acquisition

Monetization

산업 분야

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

Introduction to variables, methods, and parameters

Use methods, variables, and parameters to store data, perform actions, and control the flow of your Logic scripts.
읽는 시간 3분
최근 업데이트: 2달 전

Variables

A variable is a container you can use to store information like numbers, text, colors, or references to objects to use in your Logic scripts.
For example:
  • You operate a solar-plus-battery site.
  • You create a variable named
    BatteryStateOfCharge
    to store the battery’s current charge level.
  • BatteryStateOfCharge
    is a number that changes as the battery charges and discharges.
  • You make
    BatteryStateOfCharge
    a
    float
    type to hold decimal values for precise control.
  • When sensors report a new reading, you update
    BatteryStateOfCharge
    . If it drops below a threshold, your Logic triggers an alert.
For instructions on how to create a variable, refer to Create a variable.

Methods

Use methods to group a set of actions together that perform a specific task. Methods can also help keep your Logic scripts modular and organized.
For example:
  • You have a door in your scene that you want to open when the user clicks on it.
  • You create a method called
    OpenDoor
    that contains the logic to open the door:
    • Animate the door object as it opens.
    • Play a creaking sound.
  • Then, whenever you want to open the door in your logic, you just call the
    OpenDoor
    method instead of rewriting the same logic over and over again.
For instructions on how to create a method, refer to Create a method.

Return values

A method can return a value after it runs. This is useful when you want to get some information back from the method.
For example, with the
OpenDoor
example, you might want to know when the door finishes opening. You can modify the method to return a true/false value, which returns
true
when the door is open.
In this case, the return type of the method is a Bool value. However, if you don't want to return any value, you can set the return type to Void. The method performs the action but doesn't return anything.
For more information about return types, refer to New Method window reference.

Use methods in your logic

If you create a method with a return type other than Void, you can drag the method node from the right panel into the Logic Editor.
참고
Select the node to swap its type between expression (round node, returns a value), and statement (square node, executes, and ignores the returned value). This lets you use the method in different ways depending on your Logic script's needs.

Parameters

A parameter is a variable that you pass into a method when you use it. Parameters let you reuse the same method but with different inputs each time.
For example:
  • You want to create a notification that shows the user different messages.
  • You create a method called
    ShowNotification
    and give it a parameter called
    Message
    of type
    String
    .
  • You give the method the following logic:
    • Display the
      Message
      text on the screen.
    • Animate the UI element to slide in and out.
    • Play a notification sound.
  • Now, whenever you want to show a notification, you call the
    ShowNotification
    method and pass in the message you want to display:
    • You have a new message.
    • An error occurred.
This way, you can use the same method to show different messages without rewriting the logic each time.
You can create parameters when you create a method. For information about parameter properties, refer to Parameter details.

Additional resources

  • Create a variable
  • Create a method
  • New Method window reference

Copyright © 2026 Unity Technologies
법률 정보개인정보 처리방침쿠키Documentation Terms of Use개인 정보 판매 또는 공유 금지개인정보 보호 선택(쿠키 설정)

'Unity', Unity 로고 및 기타 Unity 상표는 미국 및 기타 지역 내 Unity Technologies 또는 그 계열사의 상표 또는 등록상표입니다(자세한 내용은 여기에서 확인하세요). 기타 명칭 또는 브랜드는 해당 소유자의 상표입니다.

일부 페이지는 편의를 위해 기계 번역되었으며 부정확한 내용이 있을 수 있습니다. 정보가 상충되는 경우, 영어 버전을 우선으로 참조하세요.

  • 보고 있는 페이지
    • Variables

    • Methods

      • Return values

      • Use methods in your logic

    • Parameters

    • Additional resources


이 페이지의 문제 보고