言語: 日本語
  • C#
  • JS
  • Boo

スクリプト言語

お好みのスクリプト言語を選択すると、サンプルコードがその言語で表示されます。

ScriptableWizard.OnDrawGizmos()

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Sumbission failed

For some reason your suggested change could not be submitted. Please try again in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Description

Called every frame when the wizard is visible.

Use this to draw wizard Gizmos in the scene view while creating your wizard. See Also: Gizmos class.
Draws a sphere to visualize how it will be before creating the actual "Sphere" game object.

	// C#
	// Creates a sphere where the gizmo is painted in the scene view. 
	
	using UnityEngine;
	using UnityEditor;
	
	public class ScriptableWizardOnDrawGizmos : ScriptableWizard {
	
		public Vector3 spherePosition = Vector3.zero;
		public float sphereRadius = 1;
		
		[MenuItem ("Example/OnDrawGizmos example")]
		static void CreateWindow() {
			ScriptableWizard.DisplayWizard(
				"Create a Sphere", 
				typeof(ScriptableWizardOnDrawGizmos), 
				"Create!");	
		}
			
		void OnWizardUpdate() {
			helpString = 
				"Set the sphere position and the sphere radius to draw the gizmo in the scene view";
			if(sphereRadius > 0) {
				errorString = "";
				isValid = true;
			} else {
				errorString = "Radius has to be greater than 0";
				isValid = false;
			}
		}
		
		void OnDrawGizmos () {
	    	Gizmos.color = Color.red;
		    Gizmos.DrawSphere (spherePosition, sphereRadius);
		}
		
		void OnWizardCreate() {
			GameObject createdSphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
			createdSphere.transform.position = spherePosition;
			createdSphere.transform.localScale = new Vector3(sphereRadius, sphereRadius, sphereRadius);
		}	
	}