static void Open(Action <GameObject> onAddButtonPushed, Func <IEnumerable <GameObject> > objectEnumerator) { if (pickerWindow == null) { pickerWindow = CreateInstance <SingleObjectPickerWindow>(); pickerWindow.titleContent = new GUIContent("Select Object"); } pickerWindow.OnAddButtonPushed = (x) => { onAddButtonPushed(x.FirstOrDefault()); }; pickerWindow.treeView = new PickerTreeView <GameObject>( new TreeViewState(), objectEnumerator, EditorGUIUtility.IconContent("PrefabNormal Icon").image as Texture2D); pickerWindow.treeView.TreeViewCanMultiSelect = false; pickerWindow.treeView.ItemDoubleClicked = (x) => { onAddButtonPushed(x); pickerWindow.Close(); }; pickerWindow.treeView.Reload(); pickerWindow.ShowAuxWindow(); }
/// <summary> /// ReductionNodeのGUI作成 /// </summary> /// <param name="reductionSettingsNode">ReductionSettingsNode</param> void MakeReductionSettings(ReductionSettingsNode reductionSettingsNode) { foldoutStartAndEnd = EditorGUILayout.Foldout(foldoutStartAndEnd, "Start and End"); if (!foldoutStartAndEnd) { return; } ++EditorGUI.indentLevel; // Start propStart.floatValue = EditorGUILayout.Slider("Start", propStart.floatValue, 0.01f, 1000.0f); // End propEnd.floatValue = EditorGUILayout.Slider("End", propEnd.floatValue, 0.01f, 1000.0f); // Refer Object propReferObject.boolValue = EditorGUILayout.Toggle("Refer Object", propReferObject.boolValue); EditorGUI.BeginDisabledGroup(!propReferObject.boolValue); // object ++EditorGUI.indentLevel; // Object var targetObjectName = propObject.objectReferenceValue ? propObject.objectReferenceValue.name : "None (Game Object)"; EditorGUILayout.LabelField( new GUIContent("Object"), new GUIContent( targetObjectName, EditorGUIUtility.IconContent("PrefabNormal Icon").image), GUI.skin.FindStyle("ObjectField")); // フィールド右側の☉ボタンの範囲 var objectFieldRect = GUILayoutUtility.GetLastRect(); var pickerButtonRect = objectFieldRect; pickerButtonRect.x += pickerButtonRect.width - 15; pickerButtonRect.width = 15; if (Event.current.type == EventType.MouseDown && Event.current.button == 0) // 左クリック { if (pickerButtonRect.Contains(Event.current.mousePosition)) { // ☉ボタンのクリック SingleObjectPickerWindow.OpenAllObjectPicker(x => { serializedObject.Update(); propObject.objectReferenceValue = x; serializedObject.ApplyModifiedProperties(); }); } else if (objectFieldRect.Contains(Event.current.mousePosition)) { // テキストフィールドのクリック EditorGUIUtility.PingObject(propObject.objectReferenceValue); // ↓ On Double Click //Selection.activeObject = propObject.objectReferenceValue; } } --EditorGUI.indentLevel; EditorGUI.EndDisabledGroup(); // End of Object // Curve // MEMO: 2017/07/14 Unity2017にて、Serializeされた変数から直接呼び出すと // エディタでの反映が上手くいかないため、第二引数をバッファ変数から読ませる propCurve.animationCurveValue = EditorGUILayout.CurveField("Reduction Curve", curve, // propCurve.animationCurveValue, Color.green, new Rect(0.0f, 0.0f, 1.0f, 1.0f)); --EditorGUI.indentLevel; }