Version: 5.4

ExecuteInEditMode

class in UnityEngine

マニュアルに切り替える

説明

スクリプトを Edit モードで実行します

By default, script components are only executed in play mode. By adding this attribute, each script component will also have its callback functions executed while the Editor is not in playmode.

The functions are not called constantly like they are in play mode.
- Update is only called when something in the scene changed.
- OnGUI is called when the Game View recieves an Event.
- OnRenderObject and the other rendering callback functions are called on every repaint of the Scene View or Game View.

using UnityEngine;
using System.Collections;

[ExecuteInEditMode] public class ExampleClass : MonoBehaviour { public Transform target; void Update() { if (target) transform.LookAt(target); } }