Skip to content

Commit

Permalink
Merge branch 'release/0.7.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
abogarsukov committed Nov 26, 2019
2 parents 31e34e3 + 22c016e commit 726ee12
Show file tree
Hide file tree
Showing 22 changed files with 661 additions and 702 deletions.
6 changes: 6 additions & 0 deletions Assets/Examples/Prefabs/TestOutlineLayers.asset
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,24 @@ MonoBehaviour:
_outlineWidth: 5
_outlineIntensity: 2
_outlineMode: 0
_name:
_zOrder: 0
_enabled: 1
- _settings:
_outlineSettings: {fileID: 0}
_outlineColor: {r: 1, g: 1, b: 0, a: 1}
_outlineWidth: 15
_outlineIntensity: 2
_outlineMode: 1
_name:
_zOrder: 0
_enabled: 1
- _settings:
_outlineSettings: {fileID: 0}
_outlineColor: {r: 1, g: 0, b: 1, a: 1}
_outlineWidth: 4
_outlineIntensity: 2
_outlineMode: 0
_name:
_zOrder: 0
_enabled: 1
8 changes: 8 additions & 0 deletions Assets/Examples/Scripts/OutlineEffectBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,14 @@ private void Awake()
_outlineEffect.OutlineLayers.Add(_outlineLayer);
}
}

foreach (var go in _outlineGos)
{
if (go)
{
_outlineLayer.Add(go);
}
}
}

private void OnValidate()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace UnityFx.Outline
/// <summary>
/// Defines outline settings.
/// </summary>
public interface IOutlineSettings
public interface IOutlineSettings : IEquatable<IOutlineSettings>
{
/// <summary>
/// Gets or sets outline color.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,11 @@ private void Update()

if (_outlineResources != null && _renderers != null && (_outlineSettings.IsChanged || _commandBuffer.sizeInBytes == 0))
{
_commandBuffer.Clear();

using (var renderer = new OutlineRenderer(_commandBuffer, BuiltinRenderTextureType.CameraTarget))
{
renderer.RenderSingleObject(_renderers, _outlineSettings.OutlineMaterials);
renderer.Render(_renderers, _outlineSettings.OutlineResources, _outlineSettings);
}

_outlineSettings.AcceptChanges();
Expand Down Expand Up @@ -297,6 +299,16 @@ public OutlineMode OutlineMode

#endregion

#region IEquatable

/// <inheritdoc/>
public bool Equals(IOutlineSettings other)
{
return OutlineSettings.Equals(_outlineSettings, other);
}

#endregion

#region implementation

private void RemoveDestroyedCameras()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,17 +264,15 @@ private void Reset()

private void FillCommandBuffer()
{
_commandBuffer.Clear();

if (_outlineResources && _outlineResources.IsValid)
{
using (var renderer = new OutlineRenderer(_commandBuffer, BuiltinRenderTextureType.CameraTarget))
{
_outlineLayers.Render(renderer, _outlineResources);
}
}
else
{
_commandBuffer.Clear();
}

_changed = false;

Expand Down
58 changes: 42 additions & 16 deletions Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,25 @@ public bool TryGetRenderers(GameObject go, out ICollection<Renderer> renderers)
return false;
}

/// <summary>
/// Renders the layers.
/// </summary>
public void Render(OutlineRenderer renderer, OutlineResources resources)
{
if (_enabled)
{
_settings.SetResources(resources);

foreach (var kvp in _outlineObjects)
{
if (kvp.Key && kvp.Key.activeInHierarchy)
{
renderer.Render(kvp.Value, _settings.OutlineResources, _settings);
}
}
}
}

#endregion

#region internals
Expand Down Expand Up @@ -257,22 +276,6 @@ internal void SetCollection(OutlineLayerCollection collection)
}
}

internal void Render(OutlineRenderer renderer, OutlineResources resources)
{
if (_enabled)
{
_settings.SetResources(resources);

foreach (var kvp in _outlineObjects)
{
if (kvp.Key && kvp.Key.activeInHierarchy)
{
renderer.RenderSingleObject(kvp.Value, _settings.OutlineMaterials);
}
}
}
}

#endregion

#region IOutlineSettingsEx
Expand Down Expand Up @@ -452,8 +455,19 @@ public void AcceptChanges()

#endregion

#region IEquatable

/// <inheritdoc/>
public bool Equals(IOutlineSettings other)
{
return OutlineSettings.Equals(this, other);
}

#endregion

#region Object

/// <inheritdoc/>
public override string ToString()
{
var text = new StringBuilder();
Expand Down Expand Up @@ -496,6 +510,18 @@ public override string ToString()
return string.Format("{0}", text);
}

/// <inheritdoc/>
public override bool Equals(object other)
{
return OutlineSettings.Equals(this, other as IOutlineSettings);
}

/// <inheritdoc/>
public override int GetHashCode()
{
return base.GetHashCode();
}

#endregion

#region implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,24 @@ public OutlineLayer[] SortedLayers
{
get
{
UpdateSortedLayersIdNeeded();
UpdateSortedLayersIfNeeded();
return _sortedLayers.ToArray();
}
}

/// <summary>
/// Renders all layers.
/// </summary>
public void Render(OutlineRenderer renderer, OutlineResources resources)
{
UpdateSortedLayersIfNeeded();

foreach (var layer in _sortedLayers)
{
layer.Render(renderer, resources);
}
}

#endregion

#region internals
Expand All @@ -78,16 +91,6 @@ internal void UpdateChanged()
}
}

internal void Render(OutlineRenderer renderer, OutlineResources resources)
{
UpdateSortedLayersIdNeeded();

foreach (var layer in _sortedLayers)
{
layer.Render(renderer, resources);
}
}

#endregion

#region ScriptableObject
Expand Down Expand Up @@ -327,7 +330,7 @@ public void AcceptChanges()

#region implementation

private void UpdateSortedLayersIdNeeded()
private void UpdateSortedLayersIfNeeded()
{
if (_orderChanged)
{
Expand Down
Loading

0 comments on commit 726ee12

Please sign in to comment.