Imported UI Assets
This commit is contained in:
@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[ExecuteInEditMode]
|
||||
[RequireComponent(typeof(Image))]
|
||||
public class GradientFilter : MonoBehaviour
|
||||
{
|
||||
// Settings
|
||||
public Filter selectedFilter = Filter.Dawn;
|
||||
[Range(0.1f, 0.9f)] public float opacity = 0.5f;
|
||||
|
||||
// Helpers
|
||||
Image bgImage;
|
||||
public List<Sprite> filters = new List<Sprite>();
|
||||
|
||||
public enum Filter
|
||||
{
|
||||
Aqua,
|
||||
Dawn,
|
||||
Dusk,
|
||||
Emerald,
|
||||
Kylo,
|
||||
Memory,
|
||||
Mice,
|
||||
Pinky,
|
||||
Retro,
|
||||
Rock,
|
||||
Sunset,
|
||||
Violet,
|
||||
Warm,
|
||||
Random
|
||||
}
|
||||
|
||||
void Awake()
|
||||
{
|
||||
bgImage = GetComponent<Image>();
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
UpdateFilter();
|
||||
}
|
||||
|
||||
public void UpdateFilter()
|
||||
{
|
||||
if (selectedFilter == Filter.Random && Application.isPlaying) { bgImage.sprite = filters[Random.Range(0, filters.Count - 1)]; }
|
||||
else if (filters.Count >= (int)selectedFilter + 1) { bgImage.sprite = filters[(int)selectedFilter]; }
|
||||
|
||||
bgImage.color = new Color(bgImage.color.r, bgImage.color.g, bgImage.color.g, opacity);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8e3e9639631415b45a26cc6cb44a3ca9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: d1fb40f1c5df87343b0f5e2753b4ff09, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Rendering/GradientFilter.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,36 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(GradientFilter))]
|
||||
public class GradientFilterEditor : Editor
|
||||
{
|
||||
private GradientFilter gfTarget;
|
||||
private GUISkin customSkin;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
gfTarget = (GradientFilter)target;
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var selectedFilter = serializedObject.FindProperty("selectedFilter");
|
||||
var opacity = serializedObject.FindProperty("opacity");
|
||||
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 6);
|
||||
HeatUIEditorHandler.DrawProperty(selectedFilter, customSkin, "Selected Filter");
|
||||
HeatUIEditorHandler.DrawProperty(opacity, customSkin, "Opacity");
|
||||
|
||||
gfTarget.UpdateFilter();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d6d0b91be5d63e94e8679d6a88e1a9de
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Rendering/GradientFilterEditor.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,142 @@
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
public class GraphicsManager : MonoBehaviour
|
||||
{
|
||||
// Resources
|
||||
[SerializeField] private Dropdown resolutionDropdown;
|
||||
|
||||
// Settings
|
||||
[SerializeField] private bool initializeResolutions = true;
|
||||
|
||||
// Helpers
|
||||
Resolution[] resolutions;
|
||||
|
||||
public enum TextureOption { FullRes, HalfRes, QuarterRes, EighthResh }
|
||||
public enum AnisotropicOption { None, PerTexture, ForcedOn }
|
||||
|
||||
void Awake()
|
||||
{
|
||||
if (initializeResolutions == true && resolutionDropdown != null)
|
||||
{
|
||||
InitializeResolutions();
|
||||
}
|
||||
}
|
||||
|
||||
public void InitializeResolutions()
|
||||
{
|
||||
resolutions = Screen.resolutions;
|
||||
resolutionDropdown.items.Clear();
|
||||
|
||||
int currentResolutionIndex = 0;
|
||||
|
||||
for (int i = 0; i < resolutions.Length; i++)
|
||||
{
|
||||
int index = i;
|
||||
string option = resolutions[i].width + "x" + resolutions[i].height;
|
||||
|
||||
resolutionDropdown.CreateNewItem(option, false);
|
||||
resolutionDropdown.items[i].onItemSelection.AddListener(delegate { SetResolution(index); });
|
||||
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
#if !UNITY_EDITOR
|
||||
if (resolutions[i].refreshRateRatio.numerator != Screen.currentResolution.refreshRateRatio.numerator) { resolutionDropdown.items[i].isInvisible = true; }
|
||||
#endif
|
||||
if (resolutions[i].width == Screen.currentResolution.width
|
||||
&& resolutions[i].height == Screen.currentResolution.height
|
||||
&& resolutions[i].refreshRateRatio.numerator == Screen.currentResolution.refreshRateRatio.numerator)
|
||||
{
|
||||
currentResolutionIndex = index;
|
||||
}
|
||||
#else
|
||||
#if !UNITY_EDITOR
|
||||
if (resolutions[i].refreshRate != Screen.currentResolution.refreshRate) { resolutionDropdown.items[i].isInvisible = true; }
|
||||
#endif
|
||||
if (resolutions[i].width == Screen.currentResolution.width
|
||||
&& resolutions[i].height == Screen.currentResolution.height
|
||||
&& resolutions[i].refreshRate == Screen.currentResolution.refreshRate)
|
||||
{
|
||||
currentResolutionIndex = index;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
resolutionDropdown.selectedItemIndex = currentResolutionIndex;
|
||||
resolutionDropdown.Initialize();
|
||||
}
|
||||
|
||||
public void SetResolution(int resolutionIndex)
|
||||
{
|
||||
#if !UNITY_EDITOR
|
||||
Screen.SetResolution(resolutions[resolutionIndex].width, resolutions[resolutionIndex].height, Screen.fullScreen);
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetVSync(bool value)
|
||||
{
|
||||
if (value == true) { QualitySettings.vSyncCount = 2; }
|
||||
else { QualitySettings.vSyncCount = 0; }
|
||||
}
|
||||
|
||||
public void SetFrameRate(int value)
|
||||
{
|
||||
Application.targetFrameRate = value;
|
||||
}
|
||||
|
||||
public void SetWindowFullscreen()
|
||||
{
|
||||
Screen.fullScreen = true;
|
||||
Screen.fullScreenMode = FullScreenMode.ExclusiveFullScreen;
|
||||
}
|
||||
|
||||
public void SetWindowBorderless()
|
||||
{
|
||||
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
|
||||
}
|
||||
|
||||
public void SetWindowWindowed()
|
||||
{
|
||||
Screen.fullScreen = false;
|
||||
Screen.fullScreenMode = FullScreenMode.Windowed;
|
||||
}
|
||||
|
||||
public void SetTextureQuality(TextureOption option)
|
||||
{
|
||||
#if UNITY_2022_2_OR_NEWER
|
||||
if (option == TextureOption.FullRes) { QualitySettings.globalTextureMipmapLimit = 0; }
|
||||
else if (option == TextureOption.HalfRes) { QualitySettings.globalTextureMipmapLimit = 1; }
|
||||
else if (option == TextureOption.QuarterRes) { QualitySettings.globalTextureMipmapLimit = 2; }
|
||||
else if (option == TextureOption.EighthResh) { QualitySettings.globalTextureMipmapLimit = 3; }
|
||||
#else
|
||||
if (option == TextureOption.FullRes) { QualitySettings.masterTextureLimit = 0; }
|
||||
else if (option == TextureOption.HalfRes) { QualitySettings.masterTextureLimit = 1; }
|
||||
else if (option == TextureOption.QuarterRes) { QualitySettings.masterTextureLimit = 2; }
|
||||
else if (option == TextureOption.EighthResh) { QualitySettings.masterTextureLimit = 3; }
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetTextureQuality(int index)
|
||||
{
|
||||
if (index == 0) { SetTextureQuality(TextureOption.FullRes); }
|
||||
else if (index == 1) { SetTextureQuality(TextureOption.HalfRes); }
|
||||
else if (index == 2) { SetTextureQuality(TextureOption.QuarterRes); }
|
||||
else if (index == 3) { SetTextureQuality(TextureOption.EighthResh); }
|
||||
}
|
||||
|
||||
public void SetAnisotropicFiltering(AnisotropicOption option)
|
||||
{
|
||||
if (option == AnisotropicOption.ForcedOn) { QualitySettings.anisotropicFiltering = AnisotropicFiltering.ForceEnable; }
|
||||
else if (option == AnisotropicOption.PerTexture) { QualitySettings.anisotropicFiltering = AnisotropicFiltering.Enable; }
|
||||
else if (option == AnisotropicOption.None) { QualitySettings.anisotropicFiltering = AnisotropicFiltering.Disable; }
|
||||
}
|
||||
|
||||
public void SetAnisotropicFiltering(int index)
|
||||
{
|
||||
if (index == 2) { SetAnisotropicFiltering(AnisotropicOption.ForcedOn); }
|
||||
else if (index == 1) { SetAnisotropicFiltering(AnisotropicOption.PerTexture); }
|
||||
else if (index == 0) { SetAnisotropicFiltering(AnisotropicOption.None); }
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df84ef1238138a845bc92e746d9ba811
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 3ea6a52a10aa2be498e7033f34948323, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Rendering/GraphicsManager.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,38 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[CanEditMultipleObjects]
|
||||
[CustomEditor(typeof(GraphicsManager))]
|
||||
public class GraphicsManagerEditor : Editor
|
||||
{
|
||||
private GraphicsManager gmTarget;
|
||||
private GUISkin customSkin;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
gmTarget = (GraphicsManager)target;
|
||||
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var resolutionDropdown = serializedObject.FindProperty("resolutionDropdown");
|
||||
|
||||
var initializeResolutions = serializedObject.FindProperty("initializeResolutions");
|
||||
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Core Header", 6);
|
||||
HeatUIEditorHandler.DrawPropertyCW(resolutionDropdown, customSkin, "Resolution Dropdown", 132);
|
||||
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 10);
|
||||
initializeResolutions.boolValue = HeatUIEditorHandler.DrawToggle(initializeResolutions.boolValue, customSkin, "Initialize Resolutions");
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5868e3c0a2a5f584d923705e204e3fbb
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Rendering/GraphicsManagerEditor.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,464 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[DisallowMultipleComponent]
|
||||
[RequireComponent(typeof(Image))]
|
||||
[AddComponentMenu("Heat UI/Effects/UI Gradient")]
|
||||
public class UIGradient : BaseMeshEffect
|
||||
{
|
||||
[SerializeField] Type _gradientType;
|
||||
[SerializeField] Blend _blendMode = Blend.Multiply;
|
||||
[SerializeField] bool _modifyVertices = true;
|
||||
[SerializeField] [Range(-1, 1)] float _offset = 0f;
|
||||
[SerializeField] [Range(0.1f, 10)] float _zoom = 1f;
|
||||
|
||||
[SerializeField]
|
||||
UnityEngine.Gradient _effectGradient = new UnityEngine.Gradient() { colorKeys = new GradientColorKey[] { new GradientColorKey(Color.black, 0), new GradientColorKey(Color.white, 1) } };
|
||||
|
||||
public Blend BlendMode
|
||||
{
|
||||
get { return _blendMode; }
|
||||
set
|
||||
{
|
||||
_blendMode = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public UnityEngine.Gradient EffectGradient
|
||||
{
|
||||
get { return _effectGradient; }
|
||||
set
|
||||
{
|
||||
_effectGradient = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public Type GradientType
|
||||
{
|
||||
get { return _gradientType; }
|
||||
set
|
||||
{
|
||||
_gradientType = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public bool ModifyVertices
|
||||
{
|
||||
get { return _modifyVertices; }
|
||||
set
|
||||
{
|
||||
_modifyVertices = value;
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float Offset
|
||||
{
|
||||
get { return _offset; }
|
||||
set
|
||||
{
|
||||
_offset = Mathf.Clamp(value, -1f, 1f);
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public float Zoom
|
||||
{
|
||||
get { return _zoom; }
|
||||
set
|
||||
{
|
||||
_zoom = Mathf.Clamp(value, 0.1f, 10f);
|
||||
graphic.SetVerticesDirty();
|
||||
}
|
||||
}
|
||||
|
||||
public enum Type
|
||||
{
|
||||
Horizontal,
|
||||
Vertical,
|
||||
Diamond
|
||||
}
|
||||
|
||||
public enum Blend
|
||||
{
|
||||
Override,
|
||||
Add,
|
||||
Multiply
|
||||
}
|
||||
|
||||
public override void ModifyMesh(VertexHelper helper)
|
||||
{
|
||||
if (!IsActive() || helper.currentVertCount == 0)
|
||||
return;
|
||||
|
||||
List<UIVertex> _vertexList = new List<UIVertex>();
|
||||
helper.GetUIVertexStream(_vertexList);
|
||||
int nCount = _vertexList.Count;
|
||||
|
||||
switch (GradientType)
|
||||
{
|
||||
case Type.Horizontal:
|
||||
case Type.Vertical:
|
||||
{
|
||||
Rect bounds = GetBounds(_vertexList);
|
||||
float min = bounds.xMin;
|
||||
float w = bounds.width;
|
||||
Func<UIVertex, float> GetPosition = v => v.position.x;
|
||||
|
||||
if (GradientType == Type.Vertical)
|
||||
{
|
||||
min = bounds.yMin;
|
||||
w = bounds.height;
|
||||
GetPosition = v => v.position.y;
|
||||
}
|
||||
|
||||
float width = w == 0f ? 0f : 1f / w / Zoom;
|
||||
float zoomOffset = (1 - (1 / Zoom)) * 0.5f;
|
||||
float offset = (Offset * (1 - zoomOffset)) - zoomOffset;
|
||||
|
||||
if (ModifyVertices)
|
||||
SplitTrianglesAtGradientStops(_vertexList, bounds, zoomOffset, helper);
|
||||
|
||||
UIVertex vertex = new UIVertex();
|
||||
for (int i = 0; i < helper.currentVertCount; i++)
|
||||
{
|
||||
helper.PopulateUIVertex(ref vertex, i);
|
||||
vertex.color = BlendColor(vertex.color, EffectGradient.Evaluate((GetPosition(vertex) - min) * width - offset));
|
||||
helper.SetUIVertex(vertex, i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case Type.Diamond:
|
||||
{
|
||||
Rect bounds = GetBounds(_vertexList);
|
||||
float height = bounds.height == 0f ? 0f : 1f / bounds.height / Zoom;
|
||||
float radius = bounds.center.y / 2f;
|
||||
Vector3 center = (Vector3.right + Vector3.up) * radius + Vector3.forward * _vertexList[0].position.z;
|
||||
|
||||
if (ModifyVertices)
|
||||
{
|
||||
helper.Clear();
|
||||
for (int i = 0; i < nCount; i++) helper.AddVert(_vertexList[i]);
|
||||
|
||||
UIVertex centralVertex = new UIVertex();
|
||||
centralVertex.position = center;
|
||||
centralVertex.normal = _vertexList[0].normal;
|
||||
centralVertex.uv0 = new Vector2(0.5f, 0.5f);
|
||||
centralVertex.color = Color.white;
|
||||
helper.AddVert(centralVertex);
|
||||
|
||||
for (int i = 1; i < nCount; i++) helper.AddTriangle(i - 1, i, nCount);
|
||||
helper.AddTriangle(0, nCount - 1, nCount);
|
||||
}
|
||||
|
||||
UIVertex vertex = new UIVertex();
|
||||
|
||||
for (int i = 0; i < helper.currentVertCount; i++)
|
||||
{
|
||||
helper.PopulateUIVertex(ref vertex, i);
|
||||
vertex.color = BlendColor(vertex.color, EffectGradient.Evaluate(
|
||||
Vector3.Distance(vertex.position, center) * height - Offset));
|
||||
helper.SetUIVertex(vertex, i);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Rect GetBounds(List<UIVertex> vertices)
|
||||
{
|
||||
float left = vertices[0].position.x;
|
||||
float right = left;
|
||||
float bottom = vertices[0].position.y;
|
||||
float top = bottom;
|
||||
|
||||
for (int i = vertices.Count - 1; i >= 1; --i)
|
||||
{
|
||||
float x = vertices[i].position.x;
|
||||
float y = vertices[i].position.y;
|
||||
|
||||
if (x > right)
|
||||
right = x;
|
||||
else if (x < left)
|
||||
left = x;
|
||||
|
||||
if (y > top)
|
||||
top = y;
|
||||
else if (y < bottom)
|
||||
bottom = y;
|
||||
}
|
||||
|
||||
return new Rect(left, bottom, right - left, top - bottom);
|
||||
}
|
||||
|
||||
void SplitTrianglesAtGradientStops(List<UIVertex> _vertexList, Rect bounds, float zoomOffset, VertexHelper helper)
|
||||
{
|
||||
List<float> stops = FindStops(zoomOffset, bounds);
|
||||
if (stops.Count > 0)
|
||||
{
|
||||
helper.Clear();
|
||||
int nCount = _vertexList.Count;
|
||||
|
||||
for (int i = 0; i < nCount; i += 3)
|
||||
{
|
||||
float[] positions = GetPositions(_vertexList, i);
|
||||
List<int> originIndices = new List<int>(3);
|
||||
List<UIVertex> starts = new List<UIVertex>(3);
|
||||
List<UIVertex> ends = new List<UIVertex>(2);
|
||||
|
||||
for (int s = 0; s < stops.Count; s++)
|
||||
{
|
||||
int initialCount = helper.currentVertCount;
|
||||
bool hadEnds = ends.Count > 0;
|
||||
bool earlyStart = false;
|
||||
|
||||
for (int p = 0; p < 3; p++)
|
||||
{
|
||||
if (!originIndices.Contains(p) && positions[p] < stops[s])
|
||||
{
|
||||
int p1 = (p + 1) % 3;
|
||||
var start = _vertexList[p + i];
|
||||
|
||||
if (positions[p1] > stops[s])
|
||||
{
|
||||
originIndices.Insert(0, p);
|
||||
starts.Insert(0, start);
|
||||
earlyStart = true;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
originIndices.Add(p);
|
||||
starts.Add(start);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (originIndices.Count == 0)
|
||||
continue;
|
||||
if (originIndices.Count == 3)
|
||||
break;
|
||||
|
||||
foreach (var start in starts)
|
||||
helper.AddVert(start);
|
||||
|
||||
ends.Clear();
|
||||
foreach (int index in originIndices)
|
||||
{
|
||||
int oppositeIndex = (index + 1) % 3;
|
||||
|
||||
if (positions[oppositeIndex] < stops[s])
|
||||
oppositeIndex = (oppositeIndex + 1) % 3;
|
||||
ends.Add(CreateSplitVertex(_vertexList[index + i], _vertexList[oppositeIndex + i], stops[s]));
|
||||
}
|
||||
|
||||
if (ends.Count == 1)
|
||||
{
|
||||
int oppositeIndex = (originIndices[0] + 2) % 3;
|
||||
ends.Add(CreateSplitVertex(_vertexList[originIndices[0] + i], _vertexList[oppositeIndex + i], stops[s]));
|
||||
}
|
||||
|
||||
foreach (var end in ends)
|
||||
helper.AddVert(end);
|
||||
|
||||
if (hadEnds)
|
||||
{
|
||||
helper.AddTriangle(initialCount - 2, initialCount, initialCount + 1);
|
||||
helper.AddTriangle(initialCount - 2, initialCount + 1, initialCount - 1);
|
||||
|
||||
if (starts.Count > 0)
|
||||
{
|
||||
if (earlyStart)
|
||||
helper.AddTriangle(initialCount - 2, initialCount + 3, initialCount);
|
||||
else
|
||||
helper.AddTriangle(initialCount + 1, initialCount + 3, initialCount - 1);
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
int vertexCount = helper.currentVertCount;
|
||||
helper.AddTriangle(initialCount, vertexCount - 2, vertexCount - 1);
|
||||
|
||||
if (starts.Count > 1)
|
||||
helper.AddTriangle(initialCount, vertexCount - 1, initialCount + 1);
|
||||
}
|
||||
|
||||
starts.Clear();
|
||||
}
|
||||
|
||||
if (ends.Count > 0)
|
||||
{
|
||||
if (starts.Count == 0)
|
||||
{
|
||||
for (int p = 0; p < 3; p++)
|
||||
{
|
||||
if (!originIndices.Contains(p) && positions[p] > stops[stops.Count - 1])
|
||||
{
|
||||
int p1 = (p + 1) % 3;
|
||||
UIVertex end = _vertexList[p + i];
|
||||
|
||||
if (positions[p1] > stops[stops.Count - 1])
|
||||
starts.Insert(0, end);
|
||||
else
|
||||
starts.Add(end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var start in starts)
|
||||
helper.AddVert(start);
|
||||
|
||||
int vertexCount = helper.currentVertCount;
|
||||
|
||||
if (starts.Count > 1)
|
||||
{
|
||||
helper.AddTriangle(vertexCount - 4, vertexCount - 2, vertexCount - 1);
|
||||
helper.AddTriangle(vertexCount - 4, vertexCount - 1, vertexCount - 3);
|
||||
}
|
||||
|
||||
else if (starts.Count > 0)
|
||||
helper.AddTriangle(vertexCount - 3, vertexCount - 1, vertexCount - 2);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
helper.AddVert(_vertexList[i]);
|
||||
helper.AddVert(_vertexList[i + 1]);
|
||||
helper.AddVert(_vertexList[i + 2]);
|
||||
int vertexCount = helper.currentVertCount;
|
||||
helper.AddTriangle(vertexCount - 3, vertexCount - 2, vertexCount - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float[] GetPositions(List<UIVertex> _vertexList, int index)
|
||||
{
|
||||
float[] positions = new float[3];
|
||||
|
||||
if (GradientType == Type.Horizontal)
|
||||
{
|
||||
positions[0] = _vertexList[index].position.x;
|
||||
positions[1] = _vertexList[index + 1].position.x;
|
||||
positions[2] = _vertexList[index + 2].position.x;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
positions[0] = _vertexList[index].position.y;
|
||||
positions[1] = _vertexList[index + 1].position.y;
|
||||
positions[2] = _vertexList[index + 2].position.y;
|
||||
}
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
List<float> FindStops(float zoomOffset, Rect bounds)
|
||||
{
|
||||
List<float> stops = new List<float>();
|
||||
var offset = Offset * (1 - zoomOffset);
|
||||
var startBoundary = zoomOffset - offset;
|
||||
var endBoundary = (1 - zoomOffset) - offset;
|
||||
|
||||
foreach (var color in EffectGradient.colorKeys)
|
||||
{
|
||||
if (color.time >= endBoundary)
|
||||
break;
|
||||
|
||||
if (color.time > startBoundary)
|
||||
stops.Add((color.time - startBoundary) * Zoom);
|
||||
}
|
||||
|
||||
foreach (var alpha in EffectGradient.alphaKeys)
|
||||
{
|
||||
if (alpha.time >= endBoundary)
|
||||
break;
|
||||
|
||||
if (alpha.time > startBoundary)
|
||||
stops.Add((alpha.time - startBoundary) * Zoom);
|
||||
}
|
||||
|
||||
float min = bounds.xMin;
|
||||
float size = bounds.width;
|
||||
|
||||
if (GradientType == Type.Vertical)
|
||||
{
|
||||
min = bounds.yMin;
|
||||
size = bounds.height;
|
||||
}
|
||||
|
||||
stops.Sort();
|
||||
|
||||
for (int i = 0; i < stops.Count; i++)
|
||||
{
|
||||
stops[i] = (stops[i] * size) + min;
|
||||
|
||||
if (i > 0 && Math.Abs(stops[i] - stops[i - 1]) < 2)
|
||||
{
|
||||
stops.RemoveAt(i);
|
||||
--i;
|
||||
}
|
||||
}
|
||||
|
||||
return stops;
|
||||
}
|
||||
|
||||
UIVertex CreateSplitVertex(UIVertex vertex1, UIVertex vertex2, float stop)
|
||||
{
|
||||
if (GradientType == Type.Horizontal)
|
||||
{
|
||||
float sx = vertex1.position.x - stop;
|
||||
float dx = vertex1.position.x - vertex2.position.x;
|
||||
float dy = vertex1.position.y - vertex2.position.y;
|
||||
float uvx = vertex1.uv0.x - vertex2.uv0.x;
|
||||
float uvy = vertex1.uv0.y - vertex2.uv0.y;
|
||||
float ratio = sx / dx;
|
||||
float splitY = vertex1.position.y - (dy * ratio);
|
||||
|
||||
UIVertex splitVertex = new UIVertex();
|
||||
splitVertex.position = new Vector3(stop, splitY, vertex1.position.z);
|
||||
splitVertex.normal = vertex1.normal;
|
||||
splitVertex.uv0 = new Vector2(vertex1.uv0.x - (uvx * ratio), vertex1.uv0.y - (uvy * ratio));
|
||||
splitVertex.color = Color.white;
|
||||
return splitVertex;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
float sy = vertex1.position.y - stop;
|
||||
float dy = vertex1.position.y - vertex2.position.y;
|
||||
float dx = vertex1.position.x - vertex2.position.x;
|
||||
float uvx = vertex1.uv0.x - vertex2.uv0.x;
|
||||
float uvy = vertex1.uv0.y - vertex2.uv0.y;
|
||||
float ratio = sy / dy;
|
||||
float splitX = vertex1.position.x - (dx * ratio);
|
||||
|
||||
UIVertex splitVertex = new UIVertex();
|
||||
splitVertex.position = new Vector3(splitX, stop, vertex1.position.z);
|
||||
splitVertex.normal = vertex1.normal;
|
||||
splitVertex.uv0 = new Vector2(vertex1.uv0.x - (uvx * ratio), vertex1.uv0.y - (uvy * ratio));
|
||||
splitVertex.color = Color.white;
|
||||
return splitVertex;
|
||||
}
|
||||
}
|
||||
|
||||
Color BlendColor(Color colorA, Color colorB)
|
||||
{
|
||||
switch (BlendMode)
|
||||
{
|
||||
default: return colorB;
|
||||
case Blend.Add: return colorA + colorB;
|
||||
case Blend.Multiply: return colorA * colorB;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eed80fc8fbc6f4c42be1e380b740a191
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: d1fb40f1c5df87343b0f5e2753b4ff09, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Rendering/UIGradient.cs
|
||||
uploadId: 629893
|
@ -0,0 +1,38 @@
|
||||
#if UNITY_EDITOR
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Michsky.UI.Heat
|
||||
{
|
||||
[CustomEditor(typeof(UIGradient))]
|
||||
public class UIGradientEditor : Editor
|
||||
{
|
||||
private GUISkin customSkin;
|
||||
private int currentTab;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
if (EditorGUIUtility.isProSkin == true) { customSkin = HeatUIEditorHandler.GetDarkEditor(customSkin); }
|
||||
else { customSkin = HeatUIEditorHandler.GetLightEditor(customSkin); }
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var _effectGradient = serializedObject.FindProperty("_effectGradient");
|
||||
var _gradientType = serializedObject.FindProperty("_gradientType");
|
||||
var _offset = serializedObject.FindProperty("_offset");
|
||||
var _zoom = serializedObject.FindProperty("_zoom");
|
||||
var _modifyVertices = serializedObject.FindProperty("_modifyVertices");
|
||||
|
||||
HeatUIEditorHandler.DrawHeader(customSkin, "Options Header", 6);
|
||||
HeatUIEditorHandler.DrawPropertyCW(_effectGradient, customSkin, "Gradient", 100);
|
||||
HeatUIEditorHandler.DrawPropertyCW(_gradientType, customSkin, "Type", 100);
|
||||
HeatUIEditorHandler.DrawPropertyCW(_offset, customSkin, "Offset", 100);
|
||||
HeatUIEditorHandler.DrawPropertyCW(_zoom, customSkin, "Zoom", 100);
|
||||
_modifyVertices.boolValue = HeatUIEditorHandler.DrawToggle(_modifyVertices.boolValue, customSkin, "Complex Gradient");
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
@ -0,0 +1,18 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08f772f3c37ee1d49918bc58eb30ab96
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
AssetOrigin:
|
||||
serializedVersion: 1
|
||||
productId: 264857
|
||||
packageName: Heat - Complete Modern UI
|
||||
packageVersion: 1.0.4
|
||||
assetPath: Assets/Heat - Complete Modern UI/Scripts/Rendering/UIGradientEditor.cs
|
||||
uploadId: 629893
|
Reference in New Issue
Block a user