123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- // Copyright (C) 2019-2021 Alexander Bogarsukov. All rights reserved.
- // See the LICENSE.md file in the project root for more information.
- using System;
- using UnityEngine;
- namespace UnityFx.Outline
- {
- /// <summary>
- /// Outline settings.
- /// </summary>
- [CreateAssetMenu(fileName = "OutlineSettings", menuName = "UnityFx/Outline/Outline Settings")]
- public sealed class OutlineSettings : ScriptableObject, IOutlineSettings
- {
- #region data
- // NOTE: There is a custom editor for OutlineSettings, so no need to show these in default inspector.
- [SerializeField, HideInInspector]
- private Color _outlineColor = Color.red;
- [SerializeField, HideInInspector, Range(OutlineResources.MinWidth, OutlineResources.MaxWidth)]
- private int _outlineWidth = 4;
- [SerializeField, HideInInspector, Range(OutlineResources.MinIntensity, OutlineResources.MaxIntensity)]
- private float _outlineIntensity = 2;
- [SerializeField, HideInInspector, Range(OutlineResources.MinAlphaCutoff, OutlineResources.MaxAlphaCutoff)]
- private float _outlineAlphaCutoff = 0.9f;
- [SerializeField, HideInInspector]
- private OutlineRenderFlags _outlineMode;
- #endregion
- #region interface
- public static bool Equals(IOutlineSettings lhs, IOutlineSettings rhs)
- {
- if (lhs == null || rhs == null)
- {
- return false;
- }
- return lhs.OutlineColor == rhs.OutlineColor &&
- lhs.OutlineWidth == rhs.OutlineWidth &&
- lhs.OutlineRenderMode == rhs.OutlineRenderMode &&
- Mathf.Approximately(lhs.OutlineIntensity, rhs.OutlineIntensity) &&
- Mathf.Approximately(lhs.OutlineAlphaCutoff, rhs.OutlineAlphaCutoff);
- }
- #endregion
- #region IOutlineSettings
- /// <inheritdoc/>
- public Color OutlineColor
- {
- get
- {
- return _outlineColor;
- }
- set
- {
- _outlineColor = value;
- }
- }
- /// <inheritdoc/>
- public int OutlineWidth
- {
- get
- {
- return _outlineWidth;
- }
- set
- {
- _outlineWidth = Mathf.Clamp(value, OutlineResources.MinWidth, OutlineResources.MaxWidth);
- }
- }
- /// <inheritdoc/>
- public float OutlineIntensity
- {
- get
- {
- return _outlineIntensity;
- }
- set
- {
- _outlineIntensity = Mathf.Clamp(value, OutlineResources.MinIntensity, OutlineResources.MaxIntensity);
- }
- }
- /// <inheritdoc/>
- public float OutlineAlphaCutoff
- {
- get
- {
- return _outlineAlphaCutoff;
- }
- set
- {
- _outlineAlphaCutoff = Mathf.Clamp(value, 0, 1);
- }
- }
- /// <inheritdoc/>
- public OutlineRenderFlags OutlineRenderMode
- {
- get
- {
- return _outlineMode;
- }
- set
- {
- _outlineMode = value;
- }
- }
- #endregion
- #region IEquatable
- /// <inheritdoc/>
- public bool Equals(IOutlineSettings other)
- {
- return Equals(this, other);
- }
- #endregion
- #region Object
- /// <inheritdoc/>
- public override bool Equals(object other)
- {
- return Equals(this, other as IOutlineSettings);
- }
- /// <inheritdoc/>
- public override int GetHashCode()
- {
- return base.GetHashCode();
- }
- #endregion
- }
- }
|