-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cc5f52d
commit 09ef668
Showing
5 changed files
with
578 additions
and
616 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
155 changes: 73 additions & 82 deletions
155
Misc/Scripts/CubeMosaicGeneratorEditor.cs → Misc/Scripts/PixelArtEditor.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,82 +1,73 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
[CustomEditor(typeof(CubeMosaicGenerator))] | ||
|
||
public class CubeMosaicGeneratorEditor : Editor | ||
{ | ||
public override void OnInspectorGUI() | ||
{ | ||
CubeMosaicGenerator cmg = (CubeMosaicGenerator)target; | ||
|
||
//Version info in BOLD and blue text | ||
GUIStyle style = new GUIStyle(); | ||
style.richText = true; | ||
style.fontStyle = FontStyle.Bold; | ||
style.normal.textColor = Color.yellow; | ||
GUILayout.Label("<size=20><b>Cube Mosaic Generator - v" + cmg.versionString + "</b></size>", style); | ||
|
||
//If a new version is available, show a button to open the download page | ||
if (cmg.newVersionAvailable) | ||
{ | ||
if (GUILayout.Button("Download new version")) | ||
{ | ||
Application.OpenURL("https://github.com/AlexInABox/mer-mosaic-generator/releases/latest"); | ||
} | ||
} | ||
|
||
DrawDefaultInspector(); | ||
|
||
//if the quality value is greater than 0.8 show a warning | ||
if (cmg.quality >= 0.1f) | ||
{ | ||
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); | ||
} | ||
|
||
|
||
if (GUILayout.Button("Generate Mosaic")) | ||
{ | ||
cmg.GenerateMosaic(); | ||
} | ||
|
||
if (GUILayout.Button("Clear Mosaic")) | ||
{ | ||
cmg.removeExistingCubes(); | ||
} | ||
|
||
//Text that shows the amount of children in the parent object | ||
if (cmg.transform.childCount > 0) | ||
{ | ||
if (cmg.useLightsources) | ||
{ | ||
GUILayout.Label("Current amount of lightsources: " + cmg.transform.GetChild(0).childCount); | ||
} | ||
else | ||
{ | ||
GUILayout.Label("Current amount of primitives: " + cmg.transform.childCount); | ||
} | ||
} | ||
|
||
//Foldout for the advanced settings | ||
cmg.showAdvancedSettings = EditorGUILayout.Foldout(cmg.showAdvancedSettings, "Advanced Settings"); | ||
|
||
if (cmg.showAdvancedSettings) | ||
{ | ||
EditorGUI.indentLevel++; | ||
//Show the advanced settings if the foldout is open | ||
cmg.cubePrefab = (GameObject)EditorGUILayout.ObjectField("Cube Prefab", cmg.cubePrefab, typeof(GameObject), true); | ||
cmg.useLightsources = EditorGUILayout.Toggle("Use Lightsources", cmg.useLightsources); | ||
|
||
cmg.sameColorMargin = EditorGUILayout.Slider("Same Color Margin", cmg.sameColorMargin, 0.01f, 1f); | ||
|
||
EditorGUI.indentLevel--; | ||
} | ||
|
||
if (cmg.useLightsources) | ||
{ | ||
EditorGUILayout.HelpBox("Lightsources are still experimental and therefore might not work properly in-game!", MessageType.Error); | ||
} | ||
} | ||
} | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEditor; | ||
|
||
[CustomEditor(typeof(PixelArt))] | ||
|
||
public class PixelArtEditor : Editor | ||
{ | ||
public override void OnInspectorGUI() | ||
{ | ||
PixelArt cmg = (PixelArt)target; | ||
|
||
//Version info in BOLD and blue text | ||
GUIStyle style = new GUIStyle(); | ||
style.richText = true; | ||
style.fontStyle = FontStyle.Bold; | ||
style.normal.textColor = new Color(0.9f, 0f, 0.2f, 1f); | ||
GUILayout.Label("<size=20><b>PixelArt - (v" + cmg.versionString + ")</b></size>", style); | ||
|
||
DrawDefaultInspector(); | ||
|
||
//if the quality value is greater than 0.8 show a warning | ||
if (cmg.quality >= 0.1f) | ||
{ | ||
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); | ||
} | ||
|
||
|
||
if (GUILayout.Button("Generate Mosaic")) | ||
{ | ||
cmg.GenerateMosaic(); | ||
} | ||
|
||
if (GUILayout.Button("Clear Mosaic")) | ||
{ | ||
cmg.removeExistingCubes(); | ||
} | ||
|
||
//Text that shows the amount of children in the parent object | ||
if (cmg.transform.childCount > 0) | ||
{ | ||
if (cmg.useLightsources) | ||
{ | ||
GUILayout.Label("Current amount of lightsources: " + cmg.transform.GetChild(0).childCount); | ||
} | ||
else | ||
{ | ||
GUILayout.Label("Current amount of primitives: " + cmg.transform.childCount); | ||
} | ||
} | ||
|
||
//Foldout for the advanced settings | ||
cmg.showAdvancedSettings = EditorGUILayout.Foldout(cmg.showAdvancedSettings, "Advanced Settings"); | ||
|
||
if (cmg.showAdvancedSettings) | ||
{ | ||
EditorGUI.indentLevel++; | ||
//Show the advanced settings if the foldout is open | ||
cmg.cubePrefab = (GameObject)EditorGUILayout.ObjectField("Cube Prefab", cmg.cubePrefab, typeof(GameObject), true); | ||
cmg.useLightsources = EditorGUILayout.Toggle("Use Lightsources", cmg.useLightsources); | ||
|
||
cmg.sameColorMargin = EditorGUILayout.Slider("Same Color Margin", cmg.sameColorMargin, 0.01f, 1f); | ||
|
||
EditorGUI.indentLevel--; | ||
} | ||
|
||
if (cmg.useLightsources) | ||
{ | ||
EditorGUILayout.HelpBox("Lightsources are still experimental and therefore might not work properly in-game!", MessageType.Error); | ||
} | ||
} | ||
} |
Oops, something went wrong.