文档

​
​

Development

User Acquisition

Monetization

工业

Unity Version Control

DevOps

On-prem

Gluon

Editor plug-in

Open Unity Dashboard

Unity Version Control

此页面不支持所选语言。
​
​
Unity Version Control
  • Overview
  • Cloud Repositories organization update
  • Installation
  • Use UVCS with the Unity Editor
  • Unity Version Control plugins
  • Concepts
  • Tutorials
    • Migrate from Git
    • Migrate from Perforce
    • Version Control settings
    • Configure the client
    • Version Control workflow
    • Version Control tools
      • Enable dynamic workspaces (Windows)
      • Create a label
      • Create an attribute
      • Create a mergebot
      • Use Smart Locks
      • Use Xlinks
      • Use Unity Samples
      • Use triggers
        • Create your first trigger
        • Trigger checkin samples
        • Verify label creation
        • Update files before checkout
        • Example triggers
        • Create a Slack web trigger
        • Create a Discord web trigger
      • Transfer project to a different organization
  • On-Prem
  • Gluon
  • CLI and shortcut references
  • Release Notes
  1. Unity Version Control (previously Plastic SCM)

Create your first trigger

Follow this workflow to create your first trigger for automation.
阅读时间2 分钟
最后更新于 10 个月前

This page shows a workflow for how to create and edit a trigger that validates your label names through the command line:
  1. View available triggers.
  2. Create the trigger.
  3. View a list of your existing triggers.
  4. Edit the trigger.
  5. Delete the trigger.

View trigger types

To associate a user script with a client or server event, you need to create a trigger. To show a list of all supported trigger types in your command line, you can use the
showtypes
command:
cm trigger showtypes

Create a trigger

If your label names are created according to a given naming standard, you can create a trigger that validates label names. To create this trigger on Windows, you can use the following
create
command:
cm trigger create before-mklabel "check label name" "ruby c:\plastic\triggers\validate-label.rb"
This is a sample Ruby script (
validate-label.rb
) that checks that the label name starts with
release
:
if (ENV['PLASTIC_LABEL_NAME'] !~ /^release/) then exit(1) end
The script picks the name of the label from the
PLASTIC_LABEL_NAME
environment variable and checks the contents against the regular expression
^release
, which matches a string that starts with
release
. If the label name doesn't match
release
(
!~
operator), the trigger returns the exit code
1
, which means the trigger fails and doesn't allow the
mklabel
operation to finish.

List triggers

To see any triggers that you create, you can use the list command to show all the triggers of the same type you created:
>cm trigger list before-mklabel1 Validate label c:\tmp\triggers\validate-label.bat dave

Edit triggers

To modify the script that this trigger is pointing to, you can use the trigger
edit
command. You need to indicate the trigger type and the trigger position, which is the first index that the list triggers command returns (1 in this case):
cm trigger edit before-mklabel 1 --script="c:\tmp\other-script.bat"

Delete triggers

To remove a trigger, you can use the trigger
delete
. You need to indicate the trigger type and position:
cm trigger delete before-mklabel 1

Copyright © 2026 Unity Technologies
法律信息隐私政策CookiesDocumentation Terms of Use请勿出售或分享我的个人信息您的隐私选择(Cookie 设置)

“Unity”、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属公司在美国和其他地方的商标或注册商标(此处查看更多信息)。其他名称或品牌是其各自所有者的商标。

为方便起见,一些页面是机器翻译的,可能包含不准确的内容。如有信息不一致的情况,以英文版本为准。

  • 在本页上
    • View trigger types

    • Create a trigger

    • List triggers

    • Edit triggers

    • Delete triggers


报告此页面的问题