- EdgeDetectionEditor.cs
- /
- /
- /
- /
1 using System;
2 using UnityEditor;
3 using UnityEngine;
4
5 namespace UnityStandardAssets.ImageEffects
6 {
7 [CustomEditor (typeof(EdgeDetection))]
8 class EdgeDetectionEditor : Editor
9 {
10 SerializedObject serObj;
11
12 SerializedProperty mode;
13 SerializedProperty sensitivityDepth;
14 SerializedProperty sensitivityNormals;
15
16 SerializedProperty lumThreshold;
17
18 SerializedProperty edgesOnly;
19 SerializedProperty edgesOnlyBgColor;
20
21 SerializedProperty edgeExp;
22 SerializedProperty sampleDist;
23
24
25 void OnEnable () {
26 serObj = new SerializedObject (target);
27
28 mode = serObj.FindProperty("mode");
29
30 sensitivityDepth = serObj.FindProperty("sensitivityDepth");
31 sensitivityNormals = serObj.FindProperty("sensitivityNormals");
32
33 lumThreshold = serObj.FindProperty("lumThreshold");
34
35 edgesOnly = serObj.FindProperty("edgesOnly");
36 edgesOnlyBgColor = serObj.FindProperty("edgesOnlyBgColor");
37
38 edgeExp = serObj.FindProperty("edgeExp");
39 sampleDist = serObj.FindProperty("sampleDist");
40 }
41
42
43 public override void OnInspectorGUI () {
44 serObj.Update ();
45
46 GUILayout.Label("Detects spatial differences and converts into black outlines", EditorStyles.miniBoldLabel);
47 EditorGUILayout.PropertyField (mode, new GUIContent("Mode"));
48
49 if (mode.intValue < 2) {
50 EditorGUILayout.PropertyField (sensitivityDepth, new GUIContent(" Depth Sensitivity"));
51 EditorGUILayout.PropertyField (sensitivityNormals, new GUIContent(" Normals Sensitivity"));
52 }
53 else if (mode.intValue < 4) {
54 EditorGUILayout.PropertyField (edgeExp, new GUIContent(" Edge Exponent"));
55 }
56 else {
57 // lum based mode
58 EditorGUILayout.PropertyField (lumThreshold, new GUIContent(" Luminance Threshold"));
59 }
60
61 EditorGUILayout.PropertyField (sampleDist, new GUIContent(" Sample Distance"));
62
63 EditorGUILayout.Separator ();
64
65 GUILayout.Label ("Background Options");
66 edgesOnly.floatValue = EditorGUILayout.Slider (" Edges only", edgesOnly.floatValue, 0.0f, 1.0f);
67 EditorGUILayout.PropertyField (edgesOnlyBgColor, new GUIContent (" Color"));
68
69 serObj.ApplyModifiedProperties();
70 }
71 }
72 }