|
1 |
| -using System.Collections; |
2 |
| -using System.Collections.Generic; |
3 |
| -using UnityEngine; |
4 |
| -using UnityEditor; |
5 |
| - |
6 |
| -[CustomEditor(typeof(CubeMosaicGenerator))] |
7 |
| - |
8 |
| -public class CubeMosaicGeneratorEditor : Editor |
9 |
| -{ |
10 |
| - public override void OnInspectorGUI() |
11 |
| - { |
12 |
| - CubeMosaicGenerator cmg = (CubeMosaicGenerator)target; |
13 |
| - |
14 |
| - //Version info in BOLD and blue text |
15 |
| - GUIStyle style = new GUIStyle(); |
16 |
| - style.richText = true; |
17 |
| - style.fontStyle = FontStyle.Bold; |
18 |
| - style.normal.textColor = Color.yellow; |
19 |
| - GUILayout.Label("<size=20><b>Cube Mosaic Generator - v" + cmg.versionString + "</b></size>", style); |
20 |
| - |
21 |
| - //If a new version is available, show a button to open the download page |
22 |
| - if (cmg.newVersionAvailable) |
23 |
| - { |
24 |
| - if (GUILayout.Button("Download new version")) |
25 |
| - { |
26 |
| - Application.OpenURL("https://github.com/AlexInABox/mer-mosaic-generator/releases/latest"); |
27 |
| - } |
28 |
| - } |
29 |
| - |
30 |
| - DrawDefaultInspector(); |
31 |
| - |
32 |
| - //if the quality value is greater than 0.8 show a warning |
33 |
| - if (cmg.quality >= 0.1f) |
34 |
| - { |
35 |
| - EditorGUILayout.HelpBox("A quality value of 0.1 or higher is not recommended. This will result in a very high amount of primitives. Also Unity might crash or stall!", MessageType.Warning); |
36 |
| - } |
37 |
| - |
38 |
| - |
39 |
| - if (GUILayout.Button("Generate Mosaic")) |
40 |
| - { |
41 |
| - cmg.GenerateMosaic(); |
42 |
| - } |
43 |
| - |
44 |
| - if (GUILayout.Button("Clear Mosaic")) |
45 |
| - { |
46 |
| - cmg.removeExistingCubes(); |
47 |
| - } |
48 |
| - |
49 |
| - //Text that shows the amount of children in the parent object |
50 |
| - if (cmg.transform.childCount > 0) |
51 |
| - { |
52 |
| - if (cmg.useLightsources) |
53 |
| - { |
54 |
| - GUILayout.Label("Current amount of lightsources: " + cmg.transform.GetChild(0).childCount); |
55 |
| - } |
56 |
| - else |
57 |
| - { |
58 |
| - GUILayout.Label("Current amount of primitives: " + cmg.transform.childCount); |
59 |
| - } |
60 |
| - } |
61 |
| - |
62 |
| - //Foldout for the advanced settings |
63 |
| - cmg.showAdvancedSettings = EditorGUILayout.Foldout(cmg.showAdvancedSettings, "Advanced Settings"); |
64 |
| - |
65 |
| - if (cmg.showAdvancedSettings) |
66 |
| - { |
67 |
| - EditorGUI.indentLevel++; |
68 |
| - //Show the advanced settings if the foldout is open |
69 |
| - cmg.cubePrefab = (GameObject)EditorGUILayout.ObjectField("Cube Prefab", cmg.cubePrefab, typeof(GameObject), true); |
70 |
| - cmg.useLightsources = EditorGUILayout.Toggle("Use Lightsources", cmg.useLightsources); |
71 |
| - |
72 |
| - cmg.sameColorMargin = EditorGUILayout.Slider("Same Color Margin", cmg.sameColorMargin, 0.01f, 1f); |
73 |
| - |
74 |
| - EditorGUI.indentLevel--; |
75 |
| - } |
76 |
| - |
77 |
| - if (cmg.useLightsources) |
78 |
| - { |
79 |
| - EditorGUILayout.HelpBox("Lightsources are still experimental and therefore might not work properly in-game!", MessageType.Error); |
80 |
| - } |
81 |
| - } |
82 |
| -} |
| 1 | +using System.Collections; |
| 2 | +using System.Collections.Generic; |
| 3 | +using UnityEngine; |
| 4 | +using UnityEditor; |
| 5 | + |
| 6 | +[CustomEditor(typeof(PixelArt))] |
| 7 | + |
| 8 | +public class PixelArtEditor : Editor |
| 9 | +{ |
| 10 | + public override void OnInspectorGUI() |
| 11 | + { |
| 12 | + PixelArt cmg = (PixelArt)target; |
| 13 | + |
| 14 | + //Version info in BOLD and blue text |
| 15 | + GUIStyle style = new GUIStyle(); |
| 16 | + style.richText = true; |
| 17 | + style.fontStyle = FontStyle.Bold; |
| 18 | + style.normal.textColor = new Color(0.9f, 0f, 0.2f, 1f); |
| 19 | + GUILayout.Label("<size=20><b>PixelArt - (v" + cmg.versionString + ")</b></size>", style); |
| 20 | + |
| 21 | + DrawDefaultInspector(); |
| 22 | + |
| 23 | + //if the quality value is greater than 0.8 show a warning |
| 24 | + if (cmg.quality >= 0.1f) |
| 25 | + { |
| 26 | + EditorGUILayout.HelpBox("A quality value of 0.1 or higher is not recommended. This will result in a very high amount of primitives. Also Unity might crash or stall!", MessageType.Warning); |
| 27 | + } |
| 28 | + |
| 29 | + |
| 30 | + if (GUILayout.Button("Generate Mosaic")) |
| 31 | + { |
| 32 | + cmg.GenerateMosaic(); |
| 33 | + } |
| 34 | + |
| 35 | + if (GUILayout.Button("Clear Mosaic")) |
| 36 | + { |
| 37 | + cmg.removeExistingCubes(); |
| 38 | + } |
| 39 | + |
| 40 | + //Text that shows the amount of children in the parent object |
| 41 | + if (cmg.transform.childCount > 0) |
| 42 | + { |
| 43 | + if (cmg.useLightsources) |
| 44 | + { |
| 45 | + GUILayout.Label("Current amount of lightsources: " + cmg.transform.GetChild(0).childCount); |
| 46 | + } |
| 47 | + else |
| 48 | + { |
| 49 | + GUILayout.Label("Current amount of primitives: " + cmg.transform.childCount); |
| 50 | + } |
| 51 | + } |
| 52 | + |
| 53 | + //Foldout for the advanced settings |
| 54 | + cmg.showAdvancedSettings = EditorGUILayout.Foldout(cmg.showAdvancedSettings, "Advanced Settings"); |
| 55 | + |
| 56 | + if (cmg.showAdvancedSettings) |
| 57 | + { |
| 58 | + EditorGUI.indentLevel++; |
| 59 | + //Show the advanced settings if the foldout is open |
| 60 | + cmg.cubePrefab = (GameObject)EditorGUILayout.ObjectField("Cube Prefab", cmg.cubePrefab, typeof(GameObject), true); |
| 61 | + cmg.useLightsources = EditorGUILayout.Toggle("Use Lightsources", cmg.useLightsources); |
| 62 | + |
| 63 | + cmg.sameColorMargin = EditorGUILayout.Slider("Same Color Margin", cmg.sameColorMargin, 0.01f, 1f); |
| 64 | + |
| 65 | + EditorGUI.indentLevel--; |
| 66 | + } |
| 67 | + |
| 68 | + if (cmg.useLightsources) |
| 69 | + { |
| 70 | + EditorGUILayout.HelpBox("Lightsources are still experimental and therefore might not work properly in-game!", MessageType.Error); |
| 71 | + } |
| 72 | + } |
| 73 | +} |
0 commit comments