Version: 5.3 (switch to 5.4b)
言語English
  • C#
  • JS

スクリプト言語

好きな言語を選択してください。選択した言語でスクリプトコードが表示されます。

EditorPrefs.SetBool

フィードバック

ありがとうございます

この度はドキュメントの品質向上のためにご意見・ご要望をお寄せいただき、誠にありがとうございます。頂いた内容をドキュメントチームで確認し、必要に応じて修正を致します。

閉じる

送信に失敗しました

なんらかのエラーが発生したため送信が出来ませんでした。しばらく経ってから<a>もう一度送信</a>してください。ドキュメントの品質向上のために時間を割いて頂き誠にありがとうございます。

閉じる

キャンセル

マニュアルに切り替える
public static function SetBool(key: string, value: bool): void;
public static void SetBool(string key, bool value);

パラメーター

説明

key で識別される設定情報の値を設定します。


rotations/positions の値を丸めるための設定を行う

	// Simple script that lets you round rotations and
	// round your positions of your selected objects.
	// and it remembers which option is being active

class EditorPrefsBool extends EditorWindow {

var showRoundPosition : boolean = true; var showRoundRotation : boolean = true;

@MenuItem("Examples/Round positions-rotations") static function Init() { var window = GetWindow(EditorPrefsBool); window.Show(); } function OnGUI() { showRoundPosition = EditorGUILayout.BeginToggleGroup("Round Position",showRoundPosition); if(GUILayout.Button("Round Position!")) DoRoundPosition(); EditorGUILayout.EndToggleGroup(); showRoundRotation = EditorGUILayout.BeginToggleGroup("Round Rotation", showRoundRotation); if(GUILayout.Button("Round Rotation!")) DoRoundRotation(); EditorGUILayout.EndToggleGroup(); }

function DoRoundPosition() { for (var t : Transform in Selection.transforms) t.localPosition = Vector3(Mathf.Round(t.localPosition.x), Mathf.Round(t.localPosition.z), Mathf.Round(t.localPosition.y)); } function DoRoundRotation() { for (var t : Transform in Selection.transforms) t.rotation = Quaternion.Euler( Vector3(Mathf.Round(t.eulerAngles.x / 45f) * 45f, Mathf.Round(t.eulerAngles.y / 45f) * 45f, Mathf.Round(t.eulerAngles.z / 45f) * 45f)); } function OnFocus() { if(EditorPrefs.HasKey("ShowRoundPosition")) showRoundPosition = EditorPrefs.GetBool("ShowRoundPosition"); if(EditorPrefs.HasKey("ShowRoundRotation")) showRoundPosition = EditorPrefs.GetBool("ShowRoundRotation"); }

function OnLostFocus() { EditorPrefs.SetBool("ShowRoundPosition", showRoundPosition); EditorPrefs.SetBool("ShowRoundRotation", showRoundRotation); } function OnDestroy() { EditorPrefs.SetBool("ShowRoundPosition", showRoundPosition); EditorPrefs.SetBool("ShowRoundRotation", showRoundRotation); } }