暂存
This commit is contained in:
1 parent
a2b44262f7
commit
2b390717c2
130 files changed
+21774
-2581
No files matched your search
@@ -0,0 +1,86 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
public class BaseMeshEffectEditor : Editor
|
||||
{
|
||||
List<MaterialEditor> _materialEditors = new List<MaterialEditor> ();
|
||||
|
||||
protected virtual void OnEnable ()
|
||||
{
|
||||
ClearMaterialEditors ();
|
||||
}
|
||||
|
||||
protected virtual void OnDisable ()
|
||||
{
|
||||
ClearMaterialEditors ();
|
||||
}
|
||||
|
||||
void ClearMaterialEditors ()
|
||||
{
|
||||
foreach (var e in _materialEditors)
|
||||
{
|
||||
if (e)
|
||||
{
|
||||
DestroyImmediate (e);
|
||||
}
|
||||
}
|
||||
_materialEditors.Clear ();
|
||||
}
|
||||
|
||||
protected void ShowMaterialEditors (Material [] materials, int startIndex, int count)
|
||||
{
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
if (_materialEditors.Count == i)
|
||||
{
|
||||
_materialEditors.Add (null);
|
||||
}
|
||||
|
||||
var mat = materials [startIndex + i];
|
||||
var editor = _materialEditors [i];
|
||||
if (editor && editor.target != mat)
|
||||
{
|
||||
DestroyImmediate (editor);
|
||||
editor = null;
|
||||
}
|
||||
|
||||
if (!editor)
|
||||
{
|
||||
editor = _materialEditors [i] = Editor.CreateEditor (mat) as MaterialEditor;
|
||||
}
|
||||
|
||||
editor.DrawHeader ();
|
||||
editor.OnInspectorGUI ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected void ShowCanvasChannelsWarning ()
|
||||
{
|
||||
BaseMeshEffect effect = target as BaseMeshEffect;
|
||||
if (!effect || !effect.graphic)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#if UNITY_5_6_OR_NEWER
|
||||
AdditionalCanvasShaderChannels channels = effect.requiredChannels;
|
||||
var canvas = effect.graphic.canvas;
|
||||
if (canvas && (canvas.additionalShaderChannels & channels) != channels)
|
||||
{
|
||||
EditorGUILayout.BeginHorizontal ();
|
||||
EditorGUILayout.HelpBox (string.Format ("Enable {1} of Canvas.additionalShaderChannels to use {0}.", effect.GetType ().Name, channels), MessageType.Warning);
|
||||
if (GUILayout.Button ("Fix"))
|
||||
{
|
||||
canvas.additionalShaderChannels |= channels;
|
||||
}
|
||||
EditorGUILayout.EndHorizontal ();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ddf2f64ff7af4a9f9b5ba45f40302bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// Remove deprecated files in old .unitypackage, after compiling.
|
||||
/// </summary>
|
||||
public class DeprecatedRemover
|
||||
{
|
||||
/// <summary>
|
||||
/// GUIDs of deprecated files.
|
||||
/// </summary>
|
||||
static readonly List<string> DeprecatedFiles = new List<string>()
|
||||
{
|
||||
"156b57fee6ef941958e66a129ce387e2", // UICustomEffect.cs
|
||||
"a4961e148a8cd4fe0b84dddc2741894a", // UICustomEffectEditor.cs
|
||||
"7b1ed09bdf5e54042b5cd1fbe69361bf", // MaterialBundle.cs
|
||||
};
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[UnityEditor.InitializeOnLoadMethod]
|
||||
static void RemoveFiles()
|
||||
{
|
||||
// The deprecated file path that exists.
|
||||
var files = DeprecatedFiles.Select(x => AssetDatabase.GUIDToAssetPath(x))
|
||||
.Where(x => File.Exists(x))
|
||||
.ToArray();
|
||||
|
||||
if (files.Any())
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendFormat("<b><color=orange>[{0}]</color></b> {1} files have been removed.\n", typeof(DeprecatedRemover).Name, files.Length);
|
||||
|
||||
foreach (var path in files)
|
||||
{
|
||||
AssetDatabase.DeleteAsset(path);
|
||||
sb.AppendFormat(" - {0}\n", path);
|
||||
}
|
||||
|
||||
AssetDatabase.Refresh();
|
||||
UnityEngine.Debug.Log(sb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6955fce24c79542af9ba39b3cf6f610f
|
||||
timeCreated: 1536108312
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,181 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIDissolve))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIDissolveEditor : BaseMeshEffectEditor
|
||||
{
|
||||
static int s_NoiseTexId;
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable ();
|
||||
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
|
||||
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
|
||||
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
|
||||
_spWidth = serializedObject.FindProperty("m_Width");
|
||||
_spColor = serializedObject.FindProperty("m_Color");
|
||||
_spSoftness = serializedObject.FindProperty("m_Softness");
|
||||
_spColorMode = serializedObject.FindProperty("m_ColorMode");
|
||||
_spNoiseTexture = serializedObject.FindProperty("m_NoiseTexture");
|
||||
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
|
||||
_spReverse = serializedObject.FindProperty("m_Reverse");
|
||||
var player = serializedObject.FindProperty("m_Player");
|
||||
_spPlay = player.FindPropertyRelative("play");
|
||||
_spDuration = player.FindPropertyRelative("duration");
|
||||
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
|
||||
_spLoop = player.FindPropertyRelative("loop");
|
||||
_spLoopDelay = player.FindPropertyRelative("loopDelay");
|
||||
_spUpdateMode = player.FindPropertyRelative("updateMode");
|
||||
|
||||
s_NoiseTexId = Shader.PropertyToID ("_NoiseTex");
|
||||
|
||||
_shader = Shader.Find ("TextMeshPro/Distance Field (UIDissolve)");
|
||||
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIDissolve)");
|
||||
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIDissolve)");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
foreach (var d in targets.Cast<UIDissolve> ())
|
||||
{
|
||||
var mat = d.material;
|
||||
if (d.isTMPro && mat && mat.HasProperty(s_NoiseTexId))
|
||||
{
|
||||
ColorMode colorMode =
|
||||
mat.IsKeywordEnabled ("ADD") ? ColorMode.Add
|
||||
: mat.IsKeywordEnabled ("SUBTRACT") ? ColorMode.Subtract
|
||||
: mat.IsKeywordEnabled ("FILL") ? ColorMode.Fill
|
||||
: ColorMode.Multiply;
|
||||
|
||||
Texture noiseTexture = mat.GetTexture(s_NoiseTexId);
|
||||
|
||||
if (d.colorMode != colorMode || d.noiseTexture != noiseTexture)
|
||||
{
|
||||
var so = new SerializedObject (d);
|
||||
so.FindProperty ("m_ColorMode").intValue = (int)colorMode;
|
||||
so.FindProperty ("m_NoiseTexture").objectReferenceValue = noiseTexture;
|
||||
so.ApplyModifiedProperties ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectFactor);
|
||||
EditorGUILayout.PropertyField(_spWidth);
|
||||
EditorGUILayout.PropertyField(_spSoftness);
|
||||
EditorGUILayout.PropertyField(_spColor);
|
||||
|
||||
bool isAnyTMPro = targets.Cast<UIDissolve>().Any(x => x.isTMPro);
|
||||
using (new EditorGUI.DisabledGroupScope (isAnyTMPro))
|
||||
{
|
||||
EditorGUILayout.PropertyField (_spColorMode);
|
||||
EditorGUILayout.PropertyField (_spNoiseTexture);
|
||||
}
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectArea);
|
||||
EditorGUILayout.PropertyField(_spKeepAspectRatio);
|
||||
|
||||
//================
|
||||
// Effect player.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spPlay);
|
||||
EditorGUILayout.PropertyField(_spDuration);
|
||||
EditorGUILayout.PropertyField(_spInitialPlayDelay);
|
||||
EditorGUILayout.PropertyField(_spLoop);
|
||||
EditorGUILayout.PropertyField(_spLoopDelay);
|
||||
EditorGUILayout.PropertyField(_spUpdateMode);
|
||||
EditorGUILayout.PropertyField(_spReverse);
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Play", "ButtonLeft"))
|
||||
{
|
||||
(target as UIDissolve).Play();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Stop", "ButtonRight"))
|
||||
{
|
||||
(target as UIDissolve).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
var c = target as UIDissolve;
|
||||
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {
|
||||
if(mat.shader == _spriteShader)
|
||||
{
|
||||
mat.shaderKeywords = c.material.shaderKeywords;
|
||||
mat.SetTexture ("_NoiseTex", c.material.GetTexture ("_NoiseTex"));
|
||||
}
|
||||
});
|
||||
ShowCanvasChannelsWarning ();
|
||||
|
||||
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spEffectFactor;
|
||||
SerializedProperty _spWidth;
|
||||
SerializedProperty _spColor;
|
||||
SerializedProperty _spSoftness;
|
||||
SerializedProperty _spColorMode;
|
||||
SerializedProperty _spNoiseTexture;
|
||||
SerializedProperty _spEffectArea;
|
||||
SerializedProperty _spKeepAspectRatio;
|
||||
SerializedProperty _spReverse;
|
||||
SerializedProperty _spPlay;
|
||||
SerializedProperty _spLoop;
|
||||
SerializedProperty _spLoopDelay;
|
||||
SerializedProperty _spDuration;
|
||||
SerializedProperty _spInitialPlayDelay;
|
||||
SerializedProperty _spUpdateMode;
|
||||
|
||||
Shader _shader;
|
||||
Shader _mobileShader;
|
||||
Shader _spriteShader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f7f7349a5d61649b69946853317db047
|
||||
timeCreated: 1538806040
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,188 @@
|
||||
using UnityEditor;
|
||||
using UnityEditor.UI;
|
||||
using UnityEngine;
|
||||
using DesamplingRate = Assets.Scripts.UI.UIEffect.UIEffectCapturedImage.DesamplingRate;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffectCapturedImage editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIEffectCapturedImage))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIEffectCapturedImageEditor : RawImageEditor
|
||||
{
|
||||
//################################
|
||||
// Constant or Static Members.
|
||||
//################################
|
||||
|
||||
public enum QualityMode : int
|
||||
{
|
||||
Fast = (DesamplingRate.x2 << 0) + (DesamplingRate.x2 << 4) + (FilterMode.Bilinear << 8) + (2 << 10),
|
||||
Medium = (DesamplingRate.x1 << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (3 << 10),
|
||||
Detail = (DesamplingRate.None << 0) + (DesamplingRate.x1 << 4) + (FilterMode.Bilinear << 8) + (5 << 10),
|
||||
Custom = -1,
|
||||
}
|
||||
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
_spTexture = serializedObject.FindProperty("m_Texture");
|
||||
_spColor = serializedObject.FindProperty("m_Color");
|
||||
_spRaycastTarget = serializedObject.FindProperty("m_RaycastTarget");
|
||||
_spDesamplingRate = serializedObject.FindProperty("m_DesamplingRate");
|
||||
_spReductionRate = serializedObject.FindProperty("m_ReductionRate");
|
||||
_spFilterMode = serializedObject.FindProperty("m_FilterMode");
|
||||
_spIterations = serializedObject.FindProperty("m_BlurIterations");
|
||||
_spKeepSizeToRootCanvas = serializedObject.FindProperty("m_FitToScreen");
|
||||
_spBlurMode = serializedObject.FindProperty("m_BlurMode");
|
||||
_spCaptureOnEnable = serializedObject.FindProperty("m_CaptureOnEnable");
|
||||
|
||||
|
||||
_customAdvancedOption = (qualityMode == QualityMode.Custom);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var graphic = (target as UIEffectCapturedImage);
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Basic properties.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spTexture);
|
||||
EditorGUILayout.PropertyField(_spColor);
|
||||
EditorGUILayout.PropertyField(_spRaycastTarget);
|
||||
|
||||
//================
|
||||
// Capture effect.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Capture Effect", EditorStyles.boldLabel);
|
||||
UIEffectEditor.DrawEffectProperties(serializedObject, "m_EffectColor");
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
GUILayout.Space(10);
|
||||
EditorGUILayout.LabelField("Advanced Option", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(_spCaptureOnEnable);// CaptureOnEnable.
|
||||
EditorGUILayout.PropertyField(_spKeepSizeToRootCanvas);// Keep Graphic Size To RootCanvas.
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
QualityMode quality = qualityMode;
|
||||
quality = (QualityMode)EditorGUILayout.EnumPopup("Quality Mode", quality);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
_customAdvancedOption = (quality == QualityMode.Custom);
|
||||
qualityMode = quality;
|
||||
}
|
||||
|
||||
// When qualityMode is `Custom`, show advanced option.
|
||||
if (_customAdvancedOption)
|
||||
{
|
||||
if (_spBlurMode.intValue != 0)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spIterations);// Iterations.
|
||||
}
|
||||
DrawDesamplingRate(_spReductionRate);// Reduction rate.
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Result Texture Setting", EditorStyles.boldLabel);
|
||||
|
||||
EditorGUILayout.PropertyField(_spFilterMode);// Filter Mode.
|
||||
DrawDesamplingRate(_spDesamplingRate);// Desampling rate.
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Capture", "ButtonLeft"))
|
||||
{
|
||||
graphic.Release();
|
||||
EditorApplication.delayCall += graphic.Capture;
|
||||
}
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!(target as UIEffectCapturedImage).capturedTexture);
|
||||
if (GUILayout.Button("Release", "ButtonRight"))
|
||||
{
|
||||
graphic.Release();
|
||||
}
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
const int Bits4 = (1 << 4) - 1;
|
||||
const int Bits2 = (1 << 2) - 1;
|
||||
bool _customAdvancedOption = false;
|
||||
SerializedProperty _spTexture;
|
||||
SerializedProperty _spColor;
|
||||
SerializedProperty _spRaycastTarget;
|
||||
SerializedProperty _spDesamplingRate;
|
||||
SerializedProperty _spReductionRate;
|
||||
SerializedProperty _spFilterMode;
|
||||
SerializedProperty _spBlurMode;
|
||||
SerializedProperty _spIterations;
|
||||
SerializedProperty _spKeepSizeToRootCanvas;
|
||||
SerializedProperty _spCaptureOnEnable;
|
||||
|
||||
QualityMode qualityMode
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_customAdvancedOption)
|
||||
return QualityMode.Custom;
|
||||
|
||||
int qualityValue = (_spDesamplingRate.intValue << 0)
|
||||
+ (_spReductionRate.intValue << 4)
|
||||
+ (_spFilterMode.intValue << 8)
|
||||
+ (_spIterations.intValue << 10);
|
||||
|
||||
return System.Enum.IsDefined(typeof(QualityMode), qualityValue) ? (QualityMode)qualityValue : QualityMode.Custom;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value != QualityMode.Custom)
|
||||
{
|
||||
int qualityValue = (int)value;
|
||||
_spDesamplingRate.intValue = (qualityValue >> 0) & Bits4;
|
||||
_spReductionRate.intValue = (qualityValue >> 4) & Bits4;
|
||||
_spFilterMode.intValue = (qualityValue >> 8) & Bits2;
|
||||
_spIterations.intValue = (qualityValue >> 10) & Bits4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Draws the desampling rate.
|
||||
/// </summary>
|
||||
void DrawDesamplingRate(SerializedProperty sp)
|
||||
{
|
||||
using (new EditorGUILayout.HorizontalScope())
|
||||
{
|
||||
EditorGUILayout.PropertyField(sp);
|
||||
int w, h;
|
||||
(target as UIEffectCapturedImage).GetDesamplingSize((UIEffectCapturedImage.DesamplingRate)sp.intValue, out w, out h);
|
||||
GUILayout.Label(string.Format("{0}x{1}", w, h), EditorStyles.miniLabel);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2476309c9b71d614ab97a2f9651b3333
|
||||
timeCreated: 1487152293
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,253 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
using System;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIEffect))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIEffectEditor : BaseMeshEffectEditor
|
||||
{
|
||||
static readonly GUIContent contentEffectColor = new GUIContent ("Effect Color");
|
||||
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
|
||||
/// <summary>
|
||||
/// Draw effect properties.
|
||||
/// </summary>
|
||||
public static void DrawEffectProperties(SerializedObject serializedObject, string colorProperty = "m_Color")
|
||||
{
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
var spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
var spToneMode = serializedObject.FindProperty("m_EffectMode");
|
||||
EditorGUILayout.PropertyField(spToneMode);
|
||||
|
||||
// When tone is enable, show parameters.
|
||||
if (spToneMode.intValue != (int)EffectMode.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//================
|
||||
// Color setting.
|
||||
//================
|
||||
var spColorMode = serializedObject.FindProperty("m_ColorMode");
|
||||
EditorGUILayout.PropertyField(spColorMode);
|
||||
|
||||
// When color is enable, show parameters.
|
||||
//if (spColorMode.intValue != (int)ColorMode.Multiply)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
SerializedProperty spColor = serializedObject.FindProperty(colorProperty);
|
||||
if (spColor == null && serializedObject.targetObject is UIEffect) {
|
||||
spColor = new SerializedObject (serializedObject.targetObjects.Select(x=>(x as UIEffect).targetGraphic).ToArray()).FindProperty(colorProperty);
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false);
|
||||
#else
|
||||
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ()) {
|
||||
spColor.serializedObject.ApplyModifiedProperties ();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//================
|
||||
// Blur setting.
|
||||
//================
|
||||
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
|
||||
EditorGUILayout.PropertyField(spBlurMode);
|
||||
|
||||
// When blur is enable, show parameters.
|
||||
if (spBlurMode.intValue != (int)BlurMode.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
|
||||
|
||||
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
|
||||
if (spAdvancedBlur != null)
|
||||
{
|
||||
EditorGUILayout.PropertyField(spAdvancedBlur);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
}
|
||||
|
||||
int GetEnum<T>(Material mat)
|
||||
{
|
||||
Type type = typeof(T);
|
||||
string[] names = System.Enum.GetNames (type);
|
||||
int[] values = System.Enum.GetValues (type) as int[];
|
||||
|
||||
int mode = 0;
|
||||
for(int i=0;i<names.Length;i++)
|
||||
{
|
||||
if (mat.IsKeywordEnabled (names [i].ToUpper()))
|
||||
mode = values [i];
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
foreach (var d in targets.Cast<UIEffect> ())
|
||||
{
|
||||
var mat = d.material;
|
||||
if (d.isTMPro && mat)
|
||||
{
|
||||
var so = new SerializedObject (d);
|
||||
EffectMode eMode = (EffectMode)GetEnum<EffectMode> (mat);
|
||||
ColorMode cMode = (ColorMode)GetEnum<ColorMode> (mat);
|
||||
BlurMode bMode = (BlurMode)GetEnum<BlurMode> (mat);
|
||||
bool aBlur = mat.IsKeywordEnabled("EX");
|
||||
if (d.effectMode != eMode || d.colorMode != cMode || d.blurMode != bMode || so.FindProperty ("m_AdvancedBlur").boolValue != aBlur)
|
||||
{
|
||||
so.FindProperty ("m_EffectMode").intValue = (int)eMode;
|
||||
so.FindProperty ("m_ColorMode").intValue = (int)cMode;
|
||||
so.FindProperty ("m_BlurMode").intValue = (int)bMode;
|
||||
so.FindProperty ("m_AdvancedBlur").boolValue = aBlur;
|
||||
so.ApplyModifiedProperties ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
serializedObject.Update();
|
||||
bool isAnyTMPro = targets.Cast<UIEffect>().Any(x => x.isTMPro);
|
||||
var c = target as UIEffect;
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
var spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
var spToneMode = serializedObject.FindProperty("m_EffectMode");
|
||||
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
|
||||
EditorGUILayout.PropertyField(spToneMode);
|
||||
|
||||
// When tone is enable, show parameters.
|
||||
if (spToneMode.intValue != (int)EffectMode.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectFactor"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//================
|
||||
// Color setting.
|
||||
//================
|
||||
var spColorMode = serializedObject.FindProperty("m_ColorMode");
|
||||
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
|
||||
EditorGUILayout.PropertyField(spColorMode);
|
||||
|
||||
// When color is enable, show parameters.
|
||||
//if (spColorMode.intValue != (int)ColorMode.Multiply)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
|
||||
SerializedProperty spColor = serializedObject.FindProperty("m_Color");
|
||||
if (spColor == null && serializedObject.targetObject is UIEffect) {
|
||||
spColor = new SerializedObject (serializedObject.targetObjects.Select(x=>(x as UIEffect).targetGraphic).ToArray()).FindProperty(!isAnyTMPro ? "m_Color" : "m_fontColor");
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck ();
|
||||
EditorGUI.showMixedValue = spColor.hasMultipleDifferentValues;
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false);
|
||||
#else
|
||||
spColor.colorValue = EditorGUILayout.ColorField (contentEffectColor, spColor.colorValue, true, false, false, null);
|
||||
#endif
|
||||
if (EditorGUI.EndChangeCheck ()) {
|
||||
spColor.serializedObject.ApplyModifiedProperties ();
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorFactor"));
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
//================
|
||||
// Blur setting.
|
||||
//================
|
||||
var spBlurMode = serializedObject.FindProperty("m_BlurMode");
|
||||
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
|
||||
EditorGUILayout.PropertyField(spBlurMode);
|
||||
|
||||
// When blur is enable, show parameters.
|
||||
if (spBlurMode.intValue != (int)BlurMode.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
|
||||
|
||||
var spAdvancedBlur = serializedObject.FindProperty("m_AdvancedBlur");
|
||||
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
|
||||
EditorGUILayout.PropertyField(spAdvancedBlur);
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {});
|
||||
ShowCanvasChannelsWarning ();
|
||||
|
||||
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable ();
|
||||
|
||||
_shader = Shader.Find ("TextMeshPro/Distance Field (UIEffect)");
|
||||
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIEffect)");
|
||||
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIEffect)");
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
Shader _shader;
|
||||
Shader _mobileShader;
|
||||
Shader _spriteShader;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f7e9f2ce1cb543ca88606769affbe24
|
||||
timeCreated: 1487152293
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,102 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIGradient))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIGradientEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Direction.
|
||||
//================
|
||||
var spDirection = serializedObject.FindProperty("m_Direction");
|
||||
EditorGUILayout.PropertyField(spDirection);
|
||||
|
||||
|
||||
//================
|
||||
// Color.
|
||||
//================
|
||||
var spColor1 = serializedObject.FindProperty("m_Color1");
|
||||
var spColor2 = serializedObject.FindProperty("m_Color2");
|
||||
var spColor3 = serializedObject.FindProperty("m_Color3");
|
||||
var spColor4 = serializedObject.FindProperty("m_Color4");
|
||||
switch ((UIGradient.Direction)spDirection.intValue)
|
||||
{
|
||||
case UIGradient.Direction.Horizontal:
|
||||
EditorGUILayout.PropertyField(spColor1, new GUIContent("Left"));
|
||||
EditorGUILayout.PropertyField(spColor2, new GUIContent("Right"));
|
||||
break;
|
||||
case UIGradient.Direction.Vertical:
|
||||
EditorGUILayout.PropertyField(spColor1, new GUIContent("Top"));
|
||||
EditorGUILayout.PropertyField(spColor2, new GUIContent("Bottom"));
|
||||
break;
|
||||
case UIGradient.Direction.Angle:
|
||||
EditorGUILayout.PropertyField(spColor1, new GUIContent("Color 1"));
|
||||
EditorGUILayout.PropertyField(spColor2, new GUIContent("Color 2"));
|
||||
break;
|
||||
case UIGradient.Direction.Diagonal:
|
||||
Rect r = EditorGUILayout.GetControlRect(false, 34);
|
||||
|
||||
r = EditorGUI.PrefixLabel(r, new GUIContent("Diagonal Color"));
|
||||
float w = r.width / 2;
|
||||
|
||||
EditorGUI.PropertyField(new Rect(r.x, r.y, w, 16), spColor3, GUIContent.none);
|
||||
EditorGUI.PropertyField(new Rect(r.x + w, r.y, w, 16), spColor4, GUIContent.none);
|
||||
EditorGUI.PropertyField(new Rect(r.x, r.y + 18, w, 16), spColor1, GUIContent.none);
|
||||
EditorGUI.PropertyField(new Rect(r.x + w, r.y + 18, w, 16), spColor2, GUIContent.none);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
//================
|
||||
// Angle.
|
||||
//================
|
||||
if ((int)UIGradient.Direction.Angle <= spDirection.intValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Rotation"));
|
||||
}
|
||||
|
||||
|
||||
//================
|
||||
// Offset.
|
||||
//================
|
||||
if ((int)UIGradient.Direction.Diagonal == spDirection.intValue)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset1"), new GUIContent("Vertical Offset"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset2"), new GUIContent("Horizontal Offset"));
|
||||
}
|
||||
else
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Offset1"), new GUIContent("Offset"));
|
||||
}
|
||||
|
||||
|
||||
//================
|
||||
// Advanced options.
|
||||
//================
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Advanced Options", EditorStyles.boldLabel);
|
||||
EditorGUI.indentLevel++;
|
||||
{
|
||||
//if ((target as UIGradient).targetGraphic is Text)
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_GradientStyle"));
|
||||
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_ColorSpace"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_IgnoreAspectRatio"));
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c28dcc885fbba4a5187a6a1aa5fb1b3b
|
||||
timeCreated: 1515895646
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,84 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIHsvModifier))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIHsvModifierEditor : BaseMeshEffectEditor
|
||||
{
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable ();
|
||||
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spTargetColor = serializedObject.FindProperty("m_TargetColor");
|
||||
_spRange = serializedObject.FindProperty("m_Range");
|
||||
_spHue = serializedObject.FindProperty("m_Hue");
|
||||
_spSaturation = serializedObject.FindProperty("m_Saturation");
|
||||
_spValue = serializedObject.FindProperty("m_Value");
|
||||
|
||||
_shader = Shader.Find ("TextMeshPro/Distance Field (UIHsvModifier)");
|
||||
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIHsvModifier)");
|
||||
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIHsvModifier)");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spTargetColor);
|
||||
EditorGUILayout.PropertyField(_spRange);
|
||||
EditorGUILayout.PropertyField(_spHue);
|
||||
EditorGUILayout.PropertyField(_spSaturation);
|
||||
EditorGUILayout.PropertyField(_spValue);
|
||||
|
||||
var c = target as UIHsvModifier;
|
||||
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {});
|
||||
ShowCanvasChannelsWarning ();
|
||||
|
||||
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spTargetColor;
|
||||
SerializedProperty _spRange;
|
||||
SerializedProperty _spHue;
|
||||
SerializedProperty _spSaturation;
|
||||
SerializedProperty _spValue;
|
||||
|
||||
Shader _shader;
|
||||
Shader _mobileShader;
|
||||
Shader _spriteShader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f002ba0ac474d487b936bc046dda56b4
|
||||
timeCreated: 1538806052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,54 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIShadow editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIShadow))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIShadowEditor : Editor
|
||||
{
|
||||
UIEffect uiEffect;
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
uiEffect = (target as UIShadow).GetComponent<UIEffect>();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Shadow setting.
|
||||
//================
|
||||
var spShadowMode = serializedObject.FindProperty("m_Style");
|
||||
EditorGUILayout.PropertyField(spShadowMode);
|
||||
|
||||
// When shadow is enable, show parameters.
|
||||
if (spShadowMode.intValue != (int)ShadowStyle.None)
|
||||
{
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectDistance"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_EffectColor"));
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_UseGraphicAlpha"));
|
||||
|
||||
if (uiEffect && uiEffect.blurMode != BlurMode.None)
|
||||
{
|
||||
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_BlurFactor"));
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6e76e7f628f09af449321b4776123f13
|
||||
timeCreated: 1487152293
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,135 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UIShiny))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UIShinyEditor : BaseMeshEffectEditor
|
||||
{
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable ();
|
||||
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
|
||||
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
|
||||
_spWidth = serializedObject.FindProperty("m_Width");
|
||||
_spRotation = serializedObject.FindProperty("m_Rotation");
|
||||
_spSoftness = serializedObject.FindProperty("m_Softness");
|
||||
_spBrightness = serializedObject.FindProperty("m_Brightness");
|
||||
_spGloss = serializedObject.FindProperty("m_Gloss");
|
||||
var player = serializedObject.FindProperty("m_Player");
|
||||
_spPlay = player.FindPropertyRelative("play");
|
||||
_spDuration = player.FindPropertyRelative("duration");
|
||||
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
|
||||
_spLoop = player.FindPropertyRelative("loop");
|
||||
_spLoopDelay = player.FindPropertyRelative("loopDelay");
|
||||
_spUpdateMode = player.FindPropertyRelative("updateMode");
|
||||
|
||||
|
||||
_shader = Shader.Find ("TextMeshPro/Distance Field (UIShiny)");
|
||||
_mobileShader = Shader.Find ("TextMeshPro/Mobile/Distance Field (UIShiny)");
|
||||
_spriteShader = Shader.Find ("TextMeshPro/Sprite (UIShiny)");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectFactor);
|
||||
EditorGUILayout.PropertyField(_spWidth);
|
||||
EditorGUILayout.PropertyField(_spRotation);
|
||||
EditorGUILayout.PropertyField(_spSoftness);
|
||||
EditorGUILayout.PropertyField(_spBrightness);
|
||||
EditorGUILayout.PropertyField(_spGloss);
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectArea);
|
||||
|
||||
//================
|
||||
// Effect player.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spPlay);
|
||||
EditorGUILayout.PropertyField(_spDuration);
|
||||
EditorGUILayout.PropertyField(_spInitialPlayDelay);
|
||||
EditorGUILayout.PropertyField(_spLoop);
|
||||
EditorGUILayout.PropertyField(_spLoopDelay);
|
||||
EditorGUILayout.PropertyField(_spUpdateMode);
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Play", "ButtonLeft"))
|
||||
{
|
||||
(target as UIShiny).Play();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Stop", "ButtonRight"))
|
||||
{
|
||||
(target as UIShiny).Stop();
|
||||
}
|
||||
}
|
||||
|
||||
var c = target as UIShiny;
|
||||
c.ShowTMProWarning (_shader, _mobileShader, _spriteShader, mat => {});
|
||||
ShowCanvasChannelsWarning ();
|
||||
|
||||
ShowMaterialEditors (c.materials, 1, c.materials.Length - 1);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spEffectFactor;
|
||||
SerializedProperty _spWidth;
|
||||
SerializedProperty _spRotation;
|
||||
SerializedProperty _spSoftness;
|
||||
SerializedProperty _spBrightness;
|
||||
SerializedProperty _spGloss;
|
||||
SerializedProperty _spEffectArea;
|
||||
SerializedProperty _spPlay;
|
||||
SerializedProperty _spLoop;
|
||||
SerializedProperty _spLoopDelay;
|
||||
SerializedProperty _spDuration;
|
||||
SerializedProperty _spInitialPlayDelay;
|
||||
SerializedProperty _spUpdateMode;
|
||||
|
||||
Shader _shader;
|
||||
Shader _mobileShader;
|
||||
Shader _spriteShader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0080e984bad7545cd957d9121e99f988
|
||||
timeCreated: 1538806052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,190 @@
|
||||
using UnityEditor;
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Assets.Scripts.UI.UIEffect.Editors
|
||||
{
|
||||
/// <summary>
|
||||
/// UIEffect editor.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(UITransitionEffect))]
|
||||
[CanEditMultipleObjects]
|
||||
public class UITransitionEffectEditor : BaseMeshEffectEditor
|
||||
{
|
||||
static int s_NoiseTexId;
|
||||
|
||||
//################################
|
||||
// Public/Protected Members.
|
||||
//################################
|
||||
/// <summary>
|
||||
/// This function is called when the object becomes enabled and active.
|
||||
/// </summary>
|
||||
protected override void OnEnable()
|
||||
{
|
||||
base.OnEnable();
|
||||
|
||||
_spMaterial = serializedObject.FindProperty("m_EffectMaterial");
|
||||
_spEffectMode = serializedObject.FindProperty("m_EffectMode");
|
||||
_spEffectFactor = serializedObject.FindProperty("m_EffectFactor");
|
||||
_spEffectArea = serializedObject.FindProperty("m_EffectArea");
|
||||
_spKeepAspectRatio = serializedObject.FindProperty("m_KeepAspectRatio");
|
||||
_spDissolveWidth = serializedObject.FindProperty("m_DissolveWidth");
|
||||
_spDissolveSoftness = serializedObject.FindProperty("m_DissolveSoftness");
|
||||
_spDissolveColor = serializedObject.FindProperty("m_DissolveColor");
|
||||
_spTransitionTexture = serializedObject.FindProperty("m_TransitionTexture");
|
||||
var player = serializedObject.FindProperty("m_Player");
|
||||
_spPlay = player.FindPropertyRelative("play");
|
||||
_spDuration = player.FindPropertyRelative("duration");
|
||||
_spInitialPlayDelay = player.FindPropertyRelative("initialPlayDelay");
|
||||
_spLoop = player.FindPropertyRelative("loop");
|
||||
_spLoopDelay = player.FindPropertyRelative("loopDelay");
|
||||
_spUpdateMode = player.FindPropertyRelative("updateMode");
|
||||
_spPassRayOnHidden = serializedObject.FindProperty("m_PassRayOnHidden");
|
||||
|
||||
s_NoiseTexId = Shader.PropertyToID("_NoiseTex");
|
||||
|
||||
_shader = Shader.Find("TextMeshPro/Distance Field (UITransition)");
|
||||
_mobileShader = Shader.Find("TextMeshPro/Mobile/Distance Field (UITransition)");
|
||||
_spriteShader = Shader.Find("TextMeshPro/Sprite (UITransition)");
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Implement this function to make a custom inspector.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
foreach (var d in targets.Cast<UITransitionEffect> ())
|
||||
{
|
||||
var mat = d.material;
|
||||
if (d.isTMPro && mat && mat.HasProperty (s_NoiseTexId))
|
||||
{
|
||||
Texture noiseTexture = mat.GetTexture (s_NoiseTexId);
|
||||
UITransitionEffect.EffectMode mode =
|
||||
mat.IsKeywordEnabled ("CUTOFF") ? UITransitionEffect.EffectMode.Cutoff
|
||||
: mat.IsKeywordEnabled ("FADE") ? UITransitionEffect.EffectMode.Fade
|
||||
: mat.IsKeywordEnabled ("DISSOLVE") ? UITransitionEffect.EffectMode.Dissolve
|
||||
: (UITransitionEffect.EffectMode)0;
|
||||
|
||||
if (mode == (UITransitionEffect.EffectMode)0)
|
||||
{
|
||||
mode = UITransitionEffect.EffectMode.Cutoff;
|
||||
mat.EnableKeyword ("CUTOFF");
|
||||
}
|
||||
|
||||
bool hasChanged = d.transitionTexture != noiseTexture || d.effectMode != mode;
|
||||
|
||||
if (hasChanged)
|
||||
{
|
||||
var so = new SerializedObject (d);
|
||||
so.FindProperty ("m_TransitionTexture").objectReferenceValue = noiseTexture;
|
||||
so.FindProperty ("m_EffectMode").intValue = (int)mode;
|
||||
so.ApplyModifiedProperties ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
//================
|
||||
// Effect material.
|
||||
//================
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.PropertyField(_spMaterial);
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
//================
|
||||
// Effect setting.
|
||||
//================
|
||||
bool isAnyTMPro = targets.Cast<UITransitionEffect>().Any(x => x.isTMPro);
|
||||
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
|
||||
EditorGUILayout.PropertyField(_spEffectMode);
|
||||
|
||||
EditorGUI.indentLevel++;
|
||||
EditorGUILayout.PropertyField(_spEffectFactor);
|
||||
if (_spEffectMode.intValue == (int)UITransitionEffect.EffectMode.Dissolve)
|
||||
{
|
||||
EditorGUILayout.PropertyField(_spDissolveWidth);
|
||||
EditorGUILayout.PropertyField(_spDissolveSoftness);
|
||||
EditorGUILayout.PropertyField(_spDissolveColor);
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
//================
|
||||
// Advanced option.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spEffectArea);
|
||||
using (new EditorGUI.DisabledGroupScope(isAnyTMPro))
|
||||
EditorGUILayout.PropertyField(_spTransitionTexture);
|
||||
EditorGUILayout.PropertyField(_spKeepAspectRatio);
|
||||
EditorGUILayout.PropertyField(_spPassRayOnHidden);
|
||||
|
||||
//================
|
||||
// Effect player.
|
||||
//================
|
||||
EditorGUILayout.PropertyField(_spPlay);
|
||||
EditorGUILayout.PropertyField(_spDuration);
|
||||
EditorGUILayout.PropertyField(_spInitialPlayDelay);
|
||||
EditorGUILayout.PropertyField(_spLoop);
|
||||
EditorGUILayout.PropertyField(_spLoopDelay);
|
||||
EditorGUILayout.PropertyField(_spUpdateMode);
|
||||
|
||||
// Debug.
|
||||
using (new EditorGUI.DisabledGroupScope(!Application.isPlaying))
|
||||
using (new EditorGUILayout.HorizontalScope(EditorStyles.helpBox))
|
||||
{
|
||||
GUILayout.Label("Debug");
|
||||
|
||||
if (GUILayout.Button("Show", "ButtonLeft"))
|
||||
{
|
||||
(target as UITransitionEffect).Show();
|
||||
}
|
||||
|
||||
if (GUILayout.Button("Hide", "ButtonRight"))
|
||||
{
|
||||
(target as UITransitionEffect).Hide();
|
||||
}
|
||||
}
|
||||
|
||||
var current = target as UITransitionEffect;
|
||||
current.ShowTMProWarning(_shader, _mobileShader, _spriteShader, mat =>
|
||||
{
|
||||
if (mat.shader == _spriteShader)
|
||||
{
|
||||
mat.shaderKeywords = current.material.shaderKeywords;
|
||||
mat.SetTexture(s_NoiseTexId, current.material.GetTexture(s_NoiseTexId));
|
||||
}
|
||||
});
|
||||
ShowCanvasChannelsWarning();
|
||||
|
||||
ShowMaterialEditors(current.materials, 1, current.materials.Length - 1);
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
//################################
|
||||
// Private Members.
|
||||
//################################
|
||||
SerializedProperty _spMaterial;
|
||||
SerializedProperty _spEffectMode;
|
||||
SerializedProperty _spEffectFactor;
|
||||
SerializedProperty _spEffectArea;
|
||||
SerializedProperty _spKeepAspectRatio;
|
||||
SerializedProperty _spDissolveWidth;
|
||||
SerializedProperty _spDissolveSoftness;
|
||||
SerializedProperty _spDissolveColor;
|
||||
SerializedProperty _spTransitionTexture;
|
||||
SerializedProperty _spPlay;
|
||||
SerializedProperty _spLoop;
|
||||
SerializedProperty _spLoopDelay;
|
||||
SerializedProperty _spDuration;
|
||||
SerializedProperty _spInitialPlayDelay;
|
||||
SerializedProperty _spUpdateMode;
|
||||
SerializedProperty _spPassRayOnHidden;
|
||||
|
||||
Shader _shader;
|
||||
Shader _mobileShader;
|
||||
Shader _spriteShader;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 631f363a54c834f1f846f823b31bd321
|
||||
timeCreated: 1538806067
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in new issue
Block a user