摄像机区域的架构改动
This commit is contained in:
257
Assets/Sprite Shaders Ultimate/Scripts/Editor/CodingHelper.cs
Normal file
257
Assets/Sprite Shaders Ultimate/Scripts/Editor/CodingHelper.cs
Normal file
@@ -0,0 +1,257 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
public class CodingHelper : EditorWindow
|
||||
{
|
||||
public GUIContent labelContent;
|
||||
public MaterialProperty prop;
|
||||
|
||||
public static CodingHelper lastWindow;
|
||||
bool isImage;
|
||||
|
||||
void OnGUI()
|
||||
{
|
||||
//Close:
|
||||
if(labelContent == null || prop == null)
|
||||
{
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
//Style:
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
//Internal Name:
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("<b><size=14>Property Name:</size></b>", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
DisplayCode("<b>" + prop.name + "</b>", labelStyle);
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
|
||||
//Code:
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("<b><size=14>Set Function:</size></b>", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
|
||||
string codeText = default;
|
||||
string propertyText = default;
|
||||
if (prop.type == MaterialProperty.PropType.Color)
|
||||
{
|
||||
propertyText = "public Color colorValue;";
|
||||
codeText = "material.SetColor(<b>\"" + prop.name + "\"</b>, colorValue);";
|
||||
}
|
||||
else if (prop.type == MaterialProperty.PropType.Vector)
|
||||
{
|
||||
propertyText = "public Vector2 vectorValue;";
|
||||
codeText = "material.SetVector(<b>\"" + prop.name + "\"</b>, vectorValue);";
|
||||
}
|
||||
else if (prop.type == MaterialProperty.PropType.Texture)
|
||||
{
|
||||
propertyText = "public Texture textureValue;";
|
||||
codeText = "material.SetTexture(<b>\"" + prop.name + "\"</b>, textureValue);";
|
||||
}
|
||||
else
|
||||
{
|
||||
propertyText = "public float floatValue;";
|
||||
codeText = "material.SetFloat(<b>\"" + prop.name + "\"</b>, floatValue);";
|
||||
}
|
||||
|
||||
DisplayCode(codeText, labelStyle);
|
||||
|
||||
//Example:
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("<b><size=14>Example Code:</size></b>", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
lastRect.x += lastRect.width - 160;
|
||||
lastRect.width = 100;
|
||||
if (!isImage)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
if (GUI.Button(lastRect, "Sprite Renderer"))
|
||||
{
|
||||
isImage = false;
|
||||
GUI.FocusControl(null);
|
||||
Repaint();
|
||||
}
|
||||
if(isImage)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
GUI.enabled = true;
|
||||
}
|
||||
lastRect.x += 100;
|
||||
lastRect.width = 60;
|
||||
if (GUI.Button(lastRect, "UI Image"))
|
||||
{
|
||||
isImage = true;
|
||||
GUI.FocusControl(null);
|
||||
Repaint();
|
||||
}
|
||||
GUI.enabled = true;
|
||||
|
||||
|
||||
string[] lines = codeText.Split('\n');
|
||||
codeText = "";
|
||||
for(int n = 0; n < lines.Length; n++)
|
||||
{
|
||||
codeText += " " + lines[n] + ((n < lines.Length - 1) ? "\n" : "");
|
||||
}
|
||||
|
||||
string exampleText = default;
|
||||
if(isImage)
|
||||
{
|
||||
exampleText = @"using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class Example : MonoBehaviour
|
||||
{
|
||||
" + propertyText + @"
|
||||
|
||||
Material material;
|
||||
|
||||
void Start()
|
||||
{
|
||||
Image image = GetComponent<Image>();
|
||||
image.material = Instantiate(image.material);
|
||||
material = image.materialForRendering;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
" + codeText + @"
|
||||
}
|
||||
}";
|
||||
}
|
||||
else
|
||||
{
|
||||
exampleText = @"using UnityEngine;
|
||||
|
||||
public class Example : MonoBehaviour
|
||||
{
|
||||
" + propertyText + @"
|
||||
|
||||
Material material;
|
||||
|
||||
void Start()
|
||||
{
|
||||
SpriteRenderer spriteRenderer = GetComponent<SpriteRenderer>();
|
||||
material = spriteRenderer.material;
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
" + codeText + @"
|
||||
}
|
||||
}";
|
||||
}
|
||||
|
||||
DisplayCode(exampleText, labelStyle);
|
||||
|
||||
//Final:
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
EditorGUILayout.Space(); EditorGUILayout.Space();
|
||||
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("Do you need <b>more</b> help ?", labelStyle);
|
||||
EditorGUILayout.LabelField("Check out the <b>documentation</b> or <b>contact</b> me.", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
EditorGUILayout.Space();
|
||||
SSUShaderGUI.DisplaySupportInformation();
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
Rect contentRect = GUILayoutUtility.GetLastRect();
|
||||
if(Mathf.Abs(position.height - contentRect.height - 50) > 5 && contentRect.height > 400)
|
||||
{
|
||||
Rect newPosition = new Rect(position);
|
||||
newPosition.height = contentRect.height + 50;
|
||||
position = newPosition;
|
||||
}
|
||||
|
||||
Rect closeRect = new Rect(position);
|
||||
closeRect.width = 60;
|
||||
closeRect.height = 30;
|
||||
closeRect.x = position.width - 70;
|
||||
closeRect.y = position.height - 40;
|
||||
|
||||
GUIStyle buttonStyle = new GUIStyle(GUI.skin.button);
|
||||
buttonStyle.richText = true;
|
||||
if(GUI.Button(closeRect, "<size=16>Close</size>", buttonStyle))
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
|
||||
void DisplayCode(string codeText, GUIStyle labelStyle)
|
||||
{
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
|
||||
int lines = codeText.Split('\n').Length;
|
||||
|
||||
EditorGUILayout.SelectableLabel(codeText, labelStyle, GUILayout.Height(lines * 16));
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
Rect lastRect = GUILayoutUtility.GetLastRect();
|
||||
lastRect.x += lastRect.width - 115;
|
||||
lastRect.width = 115;
|
||||
lastRect.y += lastRect.height - 1;
|
||||
lastRect.height = 20;
|
||||
if (GUI.Button(lastRect, "Copy to Clipboard"))
|
||||
{
|
||||
EditorGUIUtility.systemCopyBuffer = codeText.Replace("<b>","").Replace("</b>","");
|
||||
}
|
||||
}
|
||||
|
||||
public static void Open(GUIContent labelContent, MaterialProperty prop, Shader shader, float width)
|
||||
{
|
||||
if(lastWindow != null)
|
||||
{
|
||||
lastWindow.Close();
|
||||
lastWindow = null;
|
||||
}
|
||||
|
||||
CodingHelper window = CreateInstance(typeof(CodingHelper)) as CodingHelper;
|
||||
window.ShowUtility();
|
||||
window.labelContent = labelContent;
|
||||
window.prop = prop;
|
||||
window.titleContent = new GUIContent("Coding Hints - " + labelContent.text);
|
||||
window.isImage = (Selection.activeGameObject != null && Selection.activeGameObject.GetComponent<Graphic>() != null) || shader.name.Contains("UI");
|
||||
|
||||
Vector2 position = new Vector2(window.position.x, window.position.y);
|
||||
if(Event.current != null)
|
||||
{
|
||||
position = GUIUtility.GUIToScreenPoint(Event.current.mousePosition);
|
||||
position.x -= 500 + width;
|
||||
position.y -= 300;
|
||||
}
|
||||
|
||||
window.position = new Rect(position.x, position.y, 500, 665);
|
||||
|
||||
lastWindow = window;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3174f819fec40ca4581bd178d4f57554
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
106
Assets/Sprite Shaders Ultimate/Scripts/Editor/ImageSSUEditor.cs
Normal file
106
Assets/Sprite Shaders Ultimate/Scripts/Editor/ImageSSUEditor.cs
Normal file
@@ -0,0 +1,106 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
[CustomEditor(typeof(ImageSSU))]
|
||||
[CanEditMultipleObjects]
|
||||
public class ImageSSUEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
SerializedProperty updateChanges = serializedObject.FindProperty("updateChanges");
|
||||
EditorGUILayout.PropertyField(updateChanges);
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("runtimeMaterial"));
|
||||
GUI.enabled = true;
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("Requires the <b>UI_Graphic</b> shader space.", labelStyle);
|
||||
EditorGUILayout.LabelField("Sets the material's <b>Rect Width</b> and <b>Rect Height</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("Will also <b>instantiate</b> the material at runtime.", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
//Check:
|
||||
ImageSSU image = (ImageSSU) target;
|
||||
if(image.GetComponent<RectTransform>() == null)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.red;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("Requires a <b>RectTransform</b>.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
if (image.GetComponent<Image>() == null)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.red;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("Requires an <b>Image</b>.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
else if(Application.isPlaying == false)
|
||||
{
|
||||
Material mat = image.GetComponent<Image>().material;
|
||||
|
||||
if (mat.shader.name.StartsWith("Sprite Shaders Ultimate") == false)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.red;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("Requires a <b>Sprite Shaders Ultimate</b> shader.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
else if (Mathf.RoundToInt(mat.GetFloat("_ShaderSpace")) != 5)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.red;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("Requires <b>UI_Graphic</b> shader space.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.green;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
if (updateChanges.hasMultipleDifferentValues)
|
||||
{
|
||||
EditorGUILayout.LabelField("<b>Rect Width</b> and <b>Rect Height</b> will be updated on <b>Awake()</b> or <b>Update()</b>.", labelStyle);
|
||||
}
|
||||
else if (updateChanges.boolValue)
|
||||
{
|
||||
EditorGUILayout.LabelField("<b>Rect Width</b> and <b>Rect Height</b> will be updated on <b>Awake()</b> and <b>Update()</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("Material is only updated if the RectTransform's <b>Width</b> or <b>Height</b> is <b>changed</b>.", labelStyle);
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.LabelField("<b>Rect Width</b> and <b>Rect Height</b> will be updated on <b>Awake()</b>.", labelStyle);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc5e6fae969b7d94ea2f7f8c2783ea68
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
[CustomEditor(typeof(MaterialInstancerSSU))]
|
||||
[CanEditMultipleObjects]
|
||||
public class MaterialInstancerSSUEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
GUI.enabled = false;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("runtimeMaterial"));
|
||||
GUI.enabled = true;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("Will <b>instantiate</b> materials at runtime.", labelStyle);
|
||||
EditorGUILayout.LabelField("Fixes shaders requiring a <b>unique material instance</b>.", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
//Check:
|
||||
MaterialInstancerSSU materialInstancer = (MaterialInstancerSSU)target;
|
||||
if(materialInstancer.GetComponent<Renderer>() == null && materialInstancer.GetComponent<Graphic>() == null)
|
||||
{
|
||||
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.red;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("Requires a <b>UI Graphic</b> or <b>Renderer</b> with a material.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.green;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("<b>Material</b> will be instanced on <b>Awake()</b>.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fd2c5451265d51847892f3d323a57391
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
2089
Assets/Sprite Shaders Ultimate/Scripts/Editor/SSUShaderGUI.cs
Normal file
2089
Assets/Sprite Shaders Ultimate/Scripts/Editor/SSUShaderGUI.cs
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1c300067b7dcf1a48a75091e02e68ddb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,451 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Rendering;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
[CustomEditor(typeof(ShaderFaderSSU))]
|
||||
[CanEditMultipleObjects]
|
||||
public class ShaderFaderSSUEditor : Editor
|
||||
{
|
||||
List<string> shaderProperties;
|
||||
float previewValue;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
serializedObject.UpdateIfRequiredOrScript();
|
||||
|
||||
EditorGUILayout.BeginVertical();
|
||||
|
||||
SerializedProperty property = serializedObject.GetIterator();
|
||||
bool expanded = true;
|
||||
bool displayObjectLists = true;
|
||||
bool automaticFading = true;
|
||||
while (property.NextVisible(expanded))
|
||||
{
|
||||
using (new EditorGUI.DisabledScope("m_Script" == property.propertyPath))
|
||||
{
|
||||
bool draw = true;
|
||||
|
||||
//Hide fade value.
|
||||
if (property.name == "fadeValue")
|
||||
{
|
||||
//GUI.enabled = false;
|
||||
}
|
||||
|
||||
//Hide object lists.
|
||||
if (property.name == "getChildObjects")
|
||||
{
|
||||
displayObjectLists = property.boolValue;
|
||||
}
|
||||
else if ((property.name == "renderers" || property.name == "graphics") && displayObjectLists)
|
||||
{
|
||||
draw = false;
|
||||
}
|
||||
|
||||
//Hide fading variables.
|
||||
if (property.name == "automaticFading")
|
||||
{
|
||||
automaticFading = property.boolValue;
|
||||
}
|
||||
else if ((property.name == "isFaded" || property.name == "duration" || property.name == "unscaledTime") && !automaticFading)
|
||||
{
|
||||
draw = false;
|
||||
}
|
||||
else if ((property.name == "fadeValue") && automaticFading)
|
||||
{
|
||||
draw = false;
|
||||
}
|
||||
|
||||
//Create box groups.
|
||||
if (property.name == "getChildObjects" || property.name == "automaticFading" || property.name == "floatProperties")
|
||||
{
|
||||
EditorGUILayout.EndVertical();
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
}
|
||||
|
||||
//Fix box arrow overlap.
|
||||
if (property.hasVisibleChildren)
|
||||
{
|
||||
EditorGUI.indentLevel += 1;
|
||||
}
|
||||
|
||||
//DRAW PROPERTY:
|
||||
if (draw)
|
||||
{
|
||||
if (property.name == "automaticFading")
|
||||
{
|
||||
int selected = property.boolValue ? 0 : 1;
|
||||
selected = GUILayout.Toolbar(selected, new string[] { "Automatic Fading", "Manual Fading" });
|
||||
property.boolValue = selected == 0 ? true : false;
|
||||
}
|
||||
else if (property.name == "getChildObjects")
|
||||
{
|
||||
int selected = property.boolValue ? 0 : 1;
|
||||
selected = GUILayout.Toolbar(selected, new string[] { "Get From Children", "Manual Objects" });
|
||||
property.boolValue = selected == 0 ? true : false;
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(property, true);
|
||||
}
|
||||
}
|
||||
|
||||
//Fix box arrow overlap.
|
||||
if (property.hasVisibleChildren)
|
||||
{
|
||||
EditorGUI.indentLevel -= 1;
|
||||
}
|
||||
|
||||
//Reset stuff.
|
||||
GUI.enabled = true;
|
||||
expanded = false;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorGUI.EndChangeCheck();
|
||||
|
||||
//Utility:
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
|
||||
#region Utility Buttons
|
||||
if (GUILayout.Button("Copy From"))
|
||||
{
|
||||
ShaderFaderSSU sf = (ShaderFaderSSU)target;
|
||||
foreach (Material mat in GetMaterials())
|
||||
{
|
||||
Shader shader = mat.shader;
|
||||
|
||||
for(int i = 0; i < shader.GetPropertyCount(); i++)
|
||||
{
|
||||
ShaderPropertyType propertyType = shader.GetPropertyType(i);
|
||||
string propertyName = shader.GetPropertyName(i);
|
||||
|
||||
if (SSUShaderGUI.IsKeyword(propertyName) || propertyName.StartsWith("_Enable"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (propertyType == ShaderPropertyType.Float || propertyType == ShaderPropertyType.Range)
|
||||
{
|
||||
//Float:
|
||||
float propertyValue = mat.GetFloat(propertyName);
|
||||
|
||||
bool foundProperty = false;
|
||||
foreach (FloatFaderSSU propertyFader in sf.floatProperties)
|
||||
{
|
||||
if (propertyFader.propertyName == shader.GetPropertyName(i))
|
||||
{
|
||||
propertyFader.fromValue = propertyValue;
|
||||
foundProperty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundProperty)
|
||||
{
|
||||
sf.floatProperties.Add(new FloatFaderSSU(propertyName, propertyValue, propertyValue));
|
||||
}
|
||||
}
|
||||
else if (propertyType == ShaderPropertyType.Vector)
|
||||
{
|
||||
//Vector:
|
||||
Vector4 propertyValue = mat.GetVector(propertyName);
|
||||
|
||||
bool foundProperty = false;
|
||||
foreach (VectorFaderSSU propertyFader in sf.vectorProperties)
|
||||
{
|
||||
if (propertyFader.propertyName == shader.GetPropertyName(i))
|
||||
{
|
||||
propertyFader.fromValue = propertyValue;
|
||||
foundProperty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundProperty)
|
||||
{
|
||||
sf.vectorProperties.Add(new VectorFaderSSU(propertyName, propertyValue, propertyValue));
|
||||
}
|
||||
}
|
||||
else if (propertyType == ShaderPropertyType.Color)
|
||||
{
|
||||
//Color:
|
||||
Color propertyValue = mat.GetColor(propertyName);
|
||||
|
||||
bool foundProperty = false;
|
||||
foreach (ColorFaderSSU propertyFader in sf.colorProperties)
|
||||
{
|
||||
if (propertyFader.propertyName == shader.GetPropertyName(i))
|
||||
{
|
||||
propertyFader.fromValue = propertyValue;
|
||||
foundProperty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundProperty)
|
||||
{
|
||||
sf.colorProperties.Add(new ColorFaderSSU(propertyName, propertyValue, propertyValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button("Copy To"))
|
||||
{
|
||||
ShaderFaderSSU sf = (ShaderFaderSSU)target;
|
||||
foreach (Material mat in GetMaterials())
|
||||
{
|
||||
Shader shader = mat.shader;
|
||||
|
||||
for (int i = 0; i < shader.GetPropertyCount(); i++)
|
||||
{
|
||||
ShaderPropertyType propertyType = shader.GetPropertyType(i);
|
||||
string propertyName = shader.GetPropertyName(i);
|
||||
|
||||
if (SSUShaderGUI.IsKeyword(propertyName) || propertyName.StartsWith("_Enable"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (propertyType == ShaderPropertyType.Float || propertyType == ShaderPropertyType.Range)
|
||||
{
|
||||
//Float:
|
||||
float propertyValue = mat.GetFloat(propertyName);
|
||||
|
||||
bool foundProperty = false;
|
||||
foreach (FloatFaderSSU propertyFader in sf.floatProperties)
|
||||
{
|
||||
if (propertyFader.propertyName == shader.GetPropertyName(i))
|
||||
{
|
||||
propertyFader.toValue = propertyValue;
|
||||
foundProperty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundProperty)
|
||||
{
|
||||
sf.floatProperties.Add(new FloatFaderSSU(propertyName, propertyValue, propertyValue));
|
||||
}
|
||||
}
|
||||
else if (propertyType == ShaderPropertyType.Vector)
|
||||
{
|
||||
//Vector:
|
||||
Vector4 propertyValue = mat.GetVector(propertyName);
|
||||
|
||||
bool foundProperty = false;
|
||||
foreach (VectorFaderSSU propertyFader in sf.vectorProperties)
|
||||
{
|
||||
if (propertyFader.propertyName == shader.GetPropertyName(i))
|
||||
{
|
||||
propertyFader.toValue = propertyValue;
|
||||
foundProperty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundProperty)
|
||||
{
|
||||
sf.vectorProperties.Add(new VectorFaderSSU(propertyName, propertyValue, propertyValue));
|
||||
}
|
||||
}
|
||||
else if (propertyType == ShaderPropertyType.Color)
|
||||
{
|
||||
//Color:
|
||||
Color propertyValue = mat.GetColor(propertyName);
|
||||
|
||||
bool foundProperty = false;
|
||||
foreach (ColorFaderSSU propertyFader in sf.colorProperties)
|
||||
{
|
||||
if (propertyFader.propertyName == shader.GetPropertyName(i))
|
||||
{
|
||||
propertyFader.toValue = propertyValue;
|
||||
foundProperty = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundProperty)
|
||||
{
|
||||
sf.colorProperties.Add(new ColorFaderSSU(propertyName, propertyValue, propertyValue));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (GUILayout.Button("Cleanup"))
|
||||
{
|
||||
ShaderFaderSSU sf = (ShaderFaderSSU)target;
|
||||
|
||||
//Float:
|
||||
List<FloatFaderSSU> removedFloatProperties = new List<FloatFaderSSU>();
|
||||
foreach (FloatFaderSSU propertyFader in sf.floatProperties)
|
||||
{
|
||||
if(propertyFader.fromValue == propertyFader.toValue)
|
||||
{
|
||||
removedFloatProperties.Add(propertyFader);
|
||||
}
|
||||
}
|
||||
foreach (FloatFaderSSU propertyFader in removedFloatProperties)
|
||||
{
|
||||
sf.floatProperties.Remove(propertyFader);
|
||||
}
|
||||
|
||||
//Vector:
|
||||
List<VectorFaderSSU> removedVectorProperties = new List<VectorFaderSSU>();
|
||||
foreach (VectorFaderSSU propertyFader in sf.vectorProperties)
|
||||
{
|
||||
if (propertyFader.fromValue == propertyFader.toValue)
|
||||
{
|
||||
removedVectorProperties.Add(propertyFader);
|
||||
}
|
||||
}
|
||||
foreach (VectorFaderSSU propertyFader in removedVectorProperties)
|
||||
{
|
||||
sf.vectorProperties.Remove(propertyFader);
|
||||
}
|
||||
|
||||
//Color:
|
||||
List<ColorFaderSSU> removedColorProperties = new List<ColorFaderSSU>();
|
||||
foreach (ColorFaderSSU propertyFader in sf.colorProperties)
|
||||
{
|
||||
if (propertyFader.fromValue == propertyFader.toValue)
|
||||
{
|
||||
removedColorProperties.Add(propertyFader);
|
||||
}
|
||||
}
|
||||
foreach (ColorFaderSSU propertyFader in removedColorProperties)
|
||||
{
|
||||
sf.colorProperties.Remove(propertyFader);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
#region Preview
|
||||
float lastPreview = previewValue;
|
||||
previewValue = EditorGUILayout.Slider(new GUIContent("Preview", "This will modify the materials."), previewValue, 0, 1);
|
||||
if (previewValue != lastPreview)
|
||||
{
|
||||
ShaderFaderSSU sf = (ShaderFaderSSU)target;
|
||||
float fadeFactor = sf.fadeCurve.Evaluate(previewValue);
|
||||
foreach (Material mat in GetMaterials())
|
||||
{
|
||||
sf.UpdateSingleMaterial(mat, fadeFactor);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("Fades material <b>properties</b> between two values.", labelStyle);
|
||||
EditorGUILayout.LabelField("", labelStyle);
|
||||
EditorGUILayout.LabelField("<b>Objects:</b>", labelStyle);
|
||||
EditorGUILayout.LabelField("First <b>assign</b> the objects, whose <b>materials</b> should be faded.", labelStyle);
|
||||
EditorGUILayout.LabelField("These can either be <b>children</b> of this gameobject or <b>manually</b> assigned.", labelStyle);
|
||||
EditorGUILayout.LabelField("", labelStyle);
|
||||
EditorGUILayout.LabelField("<b>Properties:</b>", labelStyle);
|
||||
EditorGUILayout.LabelField("Next you need to add the material <b>properties</b>, which you want to fade.", labelStyle);
|
||||
EditorGUILayout.LabelField("These can be <b>added</b> manually or <b>setup</b> using the <b>utility buttons</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("Only <b>floats</b>, <b>colors</b> and <b>vectors</b> can be faded. Do no try to fade <b>toggles</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("", labelStyle);
|
||||
EditorGUILayout.LabelField("<b>Quick Setup:</b>", labelStyle);
|
||||
EditorGUILayout.LabelField("First <b>modify</b> the materials to their <b>faded out</b> state and press <b>[Copy From]</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("Then <b>modify</b> the materials to their <b>faded in</b> state and press <b>[Copy To]</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("Finally press <b>[Cleanup]</b> to <b>remove</b> all <b>unmodified</b> properties.", labelStyle);
|
||||
EditorGUILayout.LabelField("", labelStyle);
|
||||
EditorGUILayout.LabelField("<b>Scripting:</b>", labelStyle);
|
||||
EditorGUILayout.LabelField("For <b>automatic fading</b> simply toggle the <b>isFaded</b> boolean at runtime.", labelStyle);
|
||||
EditorGUILayout.LabelField("For <b>manual fading</b> modify the <b>fadeValue</b> float at runtime.", labelStyle);
|
||||
EditorGUILayout.LabelField("Materials are only <b>updated</b>, when the <b>fadeValue</b> changes.", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
|
||||
HashSet<Material> GetMaterials()
|
||||
{
|
||||
HashSet<Material> materials = new HashSet<Material>();
|
||||
ShaderFaderSSU sf = (ShaderFaderSSU)target;
|
||||
|
||||
if (sf.getChildObjects)
|
||||
{
|
||||
//Auto Renderers:
|
||||
foreach (Renderer renderer in sf.gameObject.GetComponentsInChildren<Renderer>(true))
|
||||
{
|
||||
if(!materials.Contains(renderer.sharedMaterial))
|
||||
{
|
||||
materials.Add(renderer.sharedMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
//Auto Graphics:
|
||||
foreach (Graphic graphic in sf.gameObject.GetComponentsInChildren<Graphic>(true))
|
||||
{
|
||||
if (!materials.Contains(graphic.material))
|
||||
{
|
||||
materials.Add(graphic.material);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Manual Renderers:
|
||||
if (sf.renderers != null)
|
||||
{
|
||||
foreach (Renderer renderer in sf.renderers)
|
||||
{
|
||||
if (renderer != null)
|
||||
{
|
||||
if (!materials.Contains(renderer.sharedMaterial))
|
||||
{
|
||||
materials.Add(renderer.sharedMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Manual Graphics:
|
||||
if (sf.graphics != null)
|
||||
{
|
||||
foreach (Graphic graphic in sf.graphics)
|
||||
{
|
||||
if (graphic != null)
|
||||
{
|
||||
if (!materials.Contains(graphic.material))
|
||||
{
|
||||
materials.Add(graphic.material);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return materials;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d88dd009f38e59546ab469e496106f4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
[CreateAssetMenu(fileName = "ShaderName", menuName = "Shader/SSU Shader Hint (ignore this)")]
|
||||
public class ShaderHintSSU : ScriptableObject
|
||||
{
|
||||
[Header("Main:")]
|
||||
[TextArea(6, 10)]
|
||||
public string shaderDescription;
|
||||
public List<HintText> hints = new List<HintText>();
|
||||
public List<string> lines = new List<string>();
|
||||
public string spaceHint = "";
|
||||
|
||||
[Header("Extra Help:")]
|
||||
public bool requiresFullRectMesh = false;
|
||||
public bool requiresSpriteSheetFix = false;
|
||||
public bool requiresInstancing = false;
|
||||
public bool requiresTiling = false;
|
||||
|
||||
[Header("Performance:")]
|
||||
public float benchmarkValue = 0f;
|
||||
public int textureSamples = 0;
|
||||
public string textureToggle = "";
|
||||
public string textureToggleExtra = "";
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class HintText
|
||||
{
|
||||
public string property = "";
|
||||
public string text = "";
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 344c00355f060794ea582079ebb0a81f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,50 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
[CustomEditor(typeof(SpriteSheetSSU))]
|
||||
[CanEditMultipleObjects]
|
||||
public class SpriteSheetSSUEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
SerializedProperty updateChanges = serializedObject.FindProperty("updateChanges");
|
||||
EditorGUILayout.PropertyField(updateChanges);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("Only supports <b>images</b> and <b>sprite renderers</b>.", labelStyle);
|
||||
EditorGUILayout.LabelField("Requires the <b>Sprite Sheet Fix</b> option enabled.", labelStyle);
|
||||
EditorGUILayout.LabelField("Sets the material's <b>Sprite Sheet Rect</b> to fix shader issues.", labelStyle);
|
||||
EditorGUILayout.LabelField("Will also <b>instantiate</b> materials at runtime.", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
//Check:
|
||||
SpriteSheetSSU targetComponent = (SpriteSheetSSU) target;
|
||||
if(targetComponent.GetComponent<Image>() == null && targetComponent.GetComponent<SpriteRenderer>() == null)
|
||||
{
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.red;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("Requires a <b>Sprite Renderer</b> or <b>Image</b> component.", labelStyle);
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 871ff7f74daabe5459cbb50de60b7b4a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,48 @@
|
||||
#if UNITY_EDITOR
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace SpriteShadersUltimate
|
||||
{
|
||||
[CustomEditor(typeof(UnscaledTimeSSU))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UnscaledTimeSSUEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
//Properties:
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("dontDestroyOnLoad"));
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
//Additional Information:
|
||||
GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
|
||||
labelStyle.richText = true;
|
||||
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
GUI.color = new Color(1, 1, 1, 0.7f);
|
||||
EditorGUILayout.LabelField("Allows you to use <b>unscaled time</b> in SSU shaders.", labelStyle);
|
||||
EditorGUILayout.LabelField("Attach this to <b>any</b> gameobject.", labelStyle);
|
||||
EditorGUILayout.LabelField("You only need <b>one</b> of this component in your scene.", labelStyle);
|
||||
GUI.color = Color.white;
|
||||
EditorGUILayout.EndVertical();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
GUI.color = Color.green;
|
||||
EditorGUILayout.BeginVertical("Helpbox");
|
||||
EditorGUILayout.LabelField("<b>Unscaled Time</b> can be used.", labelStyle);
|
||||
if(serializedObject.FindProperty("dontDestroyOnLoad").boolValue)
|
||||
{
|
||||
EditorGUILayout.LabelField("This gameobject will <b>not</b> be <b>destroyed</b> when the scene <b>changes</b>.", labelStyle);
|
||||
}
|
||||
EditorGUILayout.EndVertical();
|
||||
GUI.color = Color.white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 171f6fcb1c2b4b349a2353d6ba0c3a91
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user