1 using System;
2 using
UnityEditor;
3 using
UnityEngine;
4
5 namespace
UnityStandardAssets.ImageEffects
6 {
7     
[CustomEditor (typeof(CameraMotionBlur))]
8     
class CameraMotionBlurEditor : Editor
9     {
10         SerializedObject serObj;
11
12         SerializedProperty filterType;
13         SerializedProperty preview;
14         SerializedProperty previewScale;
15         SerializedProperty movementScale;
16         SerializedProperty jitter;
17         SerializedProperty rotationScale;
18         SerializedProperty maxVelocity;
19         SerializedProperty minVelocity;
20         SerializedProperty velocityScale;
21         SerializedProperty velocityDownsample;
22         SerializedProperty noiseTexture;
23         SerializedProperty showVelocity;
24         SerializedProperty showVelocityScale;
25         SerializedProperty excludeLayers;
26
27         
void OnEnable () {
28             serObj =
new SerializedObject (target);
29
30             filterType = serObj.FindProperty (
"filterType");
31
32             preview = serObj.FindProperty (
"preview");
33             previewScale = serObj.FindProperty (
"previewScale");
34
35             movementScale = serObj.FindProperty (
"movementScale");
36             rotationScale = serObj.FindProperty (
"rotationScale");
37
38             maxVelocity = serObj.FindProperty (
"maxVelocity");
39             minVelocity = serObj.FindProperty (
"minVelocity");
40
41             jitter = serObj.FindProperty (
"jitter");
42
43             excludeLayers = serObj.FindProperty (
"excludeLayers");
44
45             velocityScale = serObj.FindProperty (
"velocityScale");
46             velocityDownsample = serObj.FindProperty (
"velocityDownsample");
47
48             noiseTexture = serObj.FindProperty (
"noiseTexture");
49         }
50
51
52         
public override void OnInspectorGUI () {
53             serObj.Update ();
54
55             EditorGUILayout.LabelField(
"Simulates camera based motion blur", EditorStyles.miniLabel);
56
57             EditorGUILayout.PropertyField (filterType,
new GUIContent("Technique"));
58             
if (filterType.enumValueIndex == 3 && !(target as CameraMotionBlur).Dx11Support()) {
59                 EditorGUILayout.HelpBox(
"DX11 mode not supported (need shader model 5)", MessageType.Info);
60             }
61             EditorGUILayout.PropertyField (velocityScale,
new GUIContent(" Velocity Scale"));
62             
if (filterType.enumValueIndex >= 2) {
63                 EditorGUILayout.LabelField(
" Tile size used during reconstruction filter:", EditorStyles.miniLabel);
64                 EditorGUILayout.Slider(maxVelocity,
2.0f, 10.0f, new GUIContent(" Velocity Max"));
65             }
66             
else
67                 EditorGUILayout.Slider (maxVelocity,
2.0f, 10.0f, new GUIContent(" Velocity Max"));
68             EditorGUILayout.Slider(minVelocity,
0.0f, 10.0f, new GUIContent(" Velocity Min"));
69
70             EditorGUILayout.Separator ();
71
72             EditorGUILayout.LabelField(
"Technique Specific");
73
74             
if (filterType.enumValueIndex == 0) {
75                 
// portal style motion blur
76                 EditorGUILayout.PropertyField (rotationScale,
new GUIContent(" Camera Rotation"));
77                 EditorGUILayout.PropertyField (movementScale,
new GUIContent(" Camera Movement"));
78             }
79             
else {
80                 
// "plausible" blur or cheap, local blur
81                 EditorGUILayout.PropertyField (excludeLayers,
new GUIContent(" Exclude Layers"));
82                 EditorGUILayout.PropertyField (velocityDownsample,
new GUIContent(" Velocity Downsample"));
83                 velocityDownsample.intValue = velocityDownsample.intValue <
1 ? 1 : velocityDownsample.intValue;
84                 
if (filterType.enumValueIndex >= 2) { // only display jitter for reconstruction
85                     EditorGUILayout.PropertyField (noiseTexture,
new GUIContent(" Sample Jitter"));
86                     EditorGUILayout.Slider (jitter,
0.0f, 10.0f, new GUIContent(" Jitter Strength"));
87                 }
88             }
89
90             EditorGUILayout.Separator ();
91
92             EditorGUILayout.PropertyField (preview,
new GUIContent("Preview"));
93             
if (preview.boolValue)
94                 EditorGUILayout.PropertyField (previewScale,
new GUIContent(""));
95
96             serObj.ApplyModifiedProperties();
97         }
98     }
99 }


Tìm kết quả nhanh