기술 자료

​
​

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)

Checkin samples

Refer to examples of triggers that run before a check in operation.
읽는 시간 3분
최근 업데이트: 7달 전

There are multiple ways that you can use triggers that apply before a contributor checks in any changes. Refer to the following sections for examples:
  • Apply a code beautifier to your files
  • Apply a modifying action to items in block
  • Check that there are check in comments

Apply a code beautifier to .java files

This sample is a Ruby script that processes all java files through a code beautifier. This example uses Ruby, but you can use any tool.
참고
This example runs
cm cat
individually for each affected file, runs
jindent
on it, creates a shelf for the changed file, and then deletes it from the disk. To improve performance, refer to Apply a modifying action to items in block.
#!/usr/bin/env ruby# temp file that will be used for jindenttmpfile = "c:\\tmp\\triggers\\trigger-validate.java"# Process each line of stdinSTDIN.readlines.each_with_index do |line, index| # split into item, revspec and wkspec splitted = line.split(';') # pick item name from item spec filename = splitted[0].split('#')[0] # if it is a .java file, apply jindent if (filename =~ /\.java$/) then # revspec is after the first ; revspec = splitted[1]; # extract revision content from repository to temp file res = system("cm cat #{revspec} --file=\"#{tmpfile}\"") # execute jindent on temp file (jindent should be on path) if (res) then res = system("jindent \"#{tmpfile}\"") end # if jindent failed, signal the trigger failed too if (!res || $? != 0) then exit(1) end # store the re-formatted file on Plastic repository if (res) then system("cm shelveset #{revspec} --file=\"#{tmpfile}\"") end # delete the temp file if (res) then system("del \"#{tmpfile}\"") end end #ifend #each

Sample trigger creation command (on Windows)

To create the trigger that applies the code beautifier before checkin, you can use the following command:
cm trigger create before-checkin "apply jindent" "ruby c:\triggers\jindent.rb"

Apply a modifying action to items in block

This is the same example as above, except that this example runs
cm cat
and shelves the files in block, which greatly improves performance.
#!/usr/bin/rubytmpdir = 'c:\\tmp\\triggers\\'$files = []$cat_shelve_specs = []# Apply command sending revision infodef commandOnSpecs(cmd) IO.popen(cmd, "w") do |io| $cat_shelve_specs.each do |spec| puts 'catting ' + spec io.puts spec end endend# Process stdinSTDIN.readlines.each do |line| itemspec, revspec, wkspec = line.split(';') filename, branchspec, revno = itemspec.split('#') # this may have problems with long paths filename.gsub!(/\//, '_') # replace / with _ in filenames filename = tmpdir + filename # add tmpdir $files << filename $cat_shelve_specs << "#{revspec};#{filename}"end# cat files on temp directorycommandOnSpecs("cm cat -")# Apply action on files$files.each { |file| system("jindent \"#{file}\"") }# shelve filescommandOnSpecs("cm shelveset -")# remove temp files$files.each { |file| File.delete file }

Sample trigger creation command (on Windows)

cm trigger create before-checkin "apply block jindent" "ruby c:\triggers\jindent.rb"

Ensure that there are check in comments

You can use a trigger to ensure that any contributor who checks in changes provides comments.
The following sample ruby script checks the
PLASTIC_COMMENT
environment variable:
c = ENV['PLASTIC_COMMENT']if (c == nil || c == '') then exit(1) end
If the
PLASTIC_COMMENT
environment variable is empty and there is no comment, this script exits with a status code of 1 and the command fails. As a
before-checkin
trigger, UVCS throws an exception that aborts the check in operation and notifies the user.

Sample trigger creation command

cm trigger create before-checkin "comment required" "ruby c:\triggers\check-comments.rb"

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

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

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

  • 보고 있는 페이지
    • Apply a code beautifier to .java files

    • Sample trigger creation command (on Windows)

    • Apply a modifying action to items in block

    • Sample trigger creation command (on Windows)

    • Ensure that there are check in comments

      • Sample trigger creation command


이 페이지의 문제 보고