Skip to content

Commit

Permalink
Merge branch 'release/0.6.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
abogarsukov committed Sep 26, 2019
2 parents 6bf864f + cabd5c3 commit 31e34e3
Show file tree
Hide file tree
Showing 22 changed files with 807 additions and 122 deletions.
3 changes: 3 additions & 0 deletions Assets/Examples/Prefabs/TestOutlineLayers.asset
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,18 @@ MonoBehaviour:
_outlineWidth: 5
_outlineIntensity: 2
_outlineMode: 0
_enabled: 1
- _settings:
_outlineSettings: {fileID: 0}
_outlineColor: {r: 1, g: 1, b: 0, a: 1}
_outlineWidth: 15
_outlineIntensity: 2
_outlineMode: 1
_enabled: 1
- _settings:
_outlineSettings: {fileID: 0}
_outlineColor: {r: 1, g: 0, b: 1, a: 1}
_outlineWidth: 4
_outlineIntensity: 2
_outlineMode: 0
_enabled: 1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace UnityFx.Outline
public class OutlineBehaviourEditor : Editor
{
private OutlineBehaviour _effect;
private bool _debugOpened;
private bool _renderersOpened;
private bool _camerasOpened;

Expand Down Expand Up @@ -78,6 +79,18 @@ public override void OnInspectorGUI()
EditorGUI.indentLevel -= 1;
EditorGUI.EndDisabledGroup();
}

// 4) Debug info.
_debugOpened = EditorGUILayout.Foldout(_debugOpened, "Debug", true);

if (_debugOpened)
{
EditorGUI.BeginDisabledGroup(true);
EditorGUI.indentLevel += 1;
EditorGUILayout.IntField("Command buffer updates", _effect.NumberOfCommandBufferUpdates);
EditorGUI.indentLevel -= 1;
EditorGUI.EndDisabledGroup();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,18 @@ public static void RenderPreview(OutlineLayer layer, int layerIndex, bool showOb
EditorGUI.indentLevel += 1;
EditorGUILayout.PrefixLabel("Layer #" + layerIndex.ToString());
EditorGUI.indentLevel -= 1;
EditorGUILayout.IntField(layer.OutlineWidth, GUILayout.MaxWidth(100));
EditorGUILayout.ColorField(layer.OutlineColor, GUILayout.MinWidth(100));

if (layer.Enabled)
{
EditorGUILayout.LabelField(layer.OutlineMode == OutlineMode.Solid ? layer.OutlineMode.ToString() : string.Format("Blurred ({0})", layer.OutlineIntensity), GUILayout.MaxWidth(70));
EditorGUILayout.IntField(layer.OutlineWidth, GUILayout.MaxWidth(100));
EditorGUILayout.ColorField(layer.OutlineColor, GUILayout.MinWidth(100));
}
else
{
EditorGUILayout.LabelField("Disabled.");
}

EditorGUILayout.EndHorizontal();

if (showObjects)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEditor.SceneManagement;
using UnityEngine.Rendering;

namespace UnityFx.Outline
{
[CustomEditor(typeof(OutlineEffect))]
public class OutlineEffectEditor : Editor
{
private OutlineEffect _effect;
private bool _debugOpened;
private bool _previewOpened;

private void OnEnable()
Expand All @@ -24,6 +26,25 @@ public override void OnInspectorGUI()
{
base.OnInspectorGUI();

EditorGUI.BeginChangeCheck();
var e = (CameraEvent)EditorGUILayout.EnumPopup("Render Event", _effect.RenderEvent);

if (e != _effect.RenderEvent)
{
Undo.RecordObject(_effect, "Set Render Event");
_effect.RenderEvent = e;
}

if (EditorGUI.EndChangeCheck())
{
EditorUtility.SetDirty(_effect.gameObject);

if (!EditorApplication.isPlayingOrWillChangePlaymode)
{
EditorSceneManager.MarkSceneDirty(_effect.gameObject.scene);
}
}

if (_effect.OutlineLayers.Count > 0)
{
_previewOpened = EditorGUILayout.Foldout(_previewOpened, "Preview", true);
Expand All @@ -33,6 +54,17 @@ public override void OnInspectorGUI()
OutlineEditorUtility.RenderPreview(_effect.OutlineLayers, true);
}
}

_debugOpened = EditorGUILayout.Foldout(_debugOpened, "Debug", true);

if (_debugOpened)
{
EditorGUI.BeginDisabledGroup(true);
EditorGUI.indentLevel += 1;
EditorGUILayout.IntField("Command buffer updates", _effect.NumberOfCommandBufferUpdates);
EditorGUI.indentLevel -= 1;
EditorGUI.EndDisabledGroup();
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,23 @@ public override void OnInspectorGUI()
for (var i = 0; i < _layers.Count; i++)
{
EditorGUILayout.Space();

var rect = EditorGUILayout.BeginHorizontal();
EditorGUILayout.PrefixLabel("Layer #" + i.ToString());
var enabled = EditorGUILayout.ToggleLeft("Layer #" + i.ToString(), _layers[i].Enabled);

if (enabled != _layers[i].Enabled)
{
if (enabled)
{
Undo.RecordObject(_layers, "Enable Layer");
}
else
{
Undo.RecordObject(_layers, "Disable Layer");
}

_layers[i].Enabled = enabled;
}

GUILayout.FlexibleSpace();

Expand All @@ -49,6 +64,22 @@ public override void OnInspectorGUI()

GUI.Box(rect, GUIContent.none);

var name = EditorGUILayout.TextField("Layer Name", _layers[i].NameTag);

if (name != _layers[i].NameTag)
{
Undo.RecordObject(_layers, "Set Layer Name");
_layers[i].NameTag = name;
}

var priority = EditorGUILayout.IntField("Layer Priority", _layers[i].Priority);

if (priority != _layers[i].Priority)
{
Undo.RecordObject(_layers, "Set Layer Priority");
_layers[i].Priority = priority;
}

OutlineEditorUtility.Render(_layers[i], _layers);
}
}
Expand Down
8 changes: 8 additions & 0 deletions Assets/Plugins/UnityFx.Outline/Runtime/Scripts/Helpers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved.
// See the LICENSE.md file in the project root for more information.

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("UnityFx.Outline")]
[assembly: AssemblyProduct("UnityFx.Outline")]
[assembly: AssemblyDescription("Screen-space outlines for Unity3d.")]
#if DEBUG
[assembly: AssemblyConfiguration("Debug")]
#else
[assembly: AssemblyConfiguration("Release")]
#endif
[assembly: AssemblyCompany("")]
[assembly: AssemblyCopyright("Copyright © Alexander Bogarsukov 2019")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM.
[assembly: Guid("1ace8625-97c5-4d37-a649-03975d187542")]

// Make internals visible to the editor assembly.
[assembly: InternalsVisibleTo("UnityFx.Outline.Editor")]

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private void OnWillRenderObject()
}
}

private sealed class RendererCollection : IList<Renderer>
private sealed class RendererCollection : ICollection<Renderer>
{
#region data

Expand Down Expand Up @@ -73,58 +73,6 @@ public void Reset()

#endregion

#region IList

public Renderer this[int index]
{
get
{
return _renderers[index];
}
set
{
if (index < 0 || index >= _renderers.Count)
{
throw new ArgumentOutOfRangeException("index");
}

Validate(value);
Release(_renderers[index]);
Init(value);

_renderers[index] = value;
}
}

public int IndexOf(Renderer renderer)
{
return _renderers.IndexOf(renderer);
}

public void Insert(int index, Renderer renderer)
{
if (index < 0 || index >= _renderers.Count)
{
throw new ArgumentOutOfRangeException("index");
}

Validate(renderer);
Init(renderer);

_renderers.Insert(index, renderer);
}

public void RemoveAt(int index)
{
if (index >= 0 && index < _renderers.Count)
{
Release(_renderers[index]);
_renderers.RemoveAt(index);
}
}

#endregion

#region ICollection

public int Count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,31 @@ public sealed partial class OutlineBehaviour : MonoBehaviour, IOutlineSettingsEx
private Dictionary<Camera, CommandBuffer> _cameraMap = new Dictionary<Camera, CommandBuffer>();
private float _cameraMapUpdateTimer;

#if UNITY_EDITOR

private int _commandBufferUpdateCounter;

#endif

#endregion

#region interface

#if UNITY_EDITOR

/// <summary>
/// Gets number of the command buffer updates since its creation. Only available in editor.
/// </summary>
public int NumberOfCommandBufferUpdates
{
get
{
return _commandBufferUpdateCounter;
}
}

#endif

/// <summary>
/// Gets or sets resources used by the effect implementation.
/// </summary>
Expand Down Expand Up @@ -148,14 +169,20 @@ private void Update()

#endif

if (_outlineResources != null && _renderers != null && _outlineSettings.IsChanged)
if (_outlineResources != null && _renderers != null && (_outlineSettings.IsChanged || _commandBuffer.sizeInBytes == 0))
{
using (var renderer = new OutlineRenderer(_commandBuffer, BuiltinRenderTextureType.CameraTarget))
{
renderer.RenderSingleObject(_renderers, _outlineSettings.OutlineMaterials);
}

_outlineSettings.AcceptChanges();

#if UNITY_EDITOR

_commandBufferUpdateCounter++;

#endif
}
}

Expand Down Expand Up @@ -306,6 +333,12 @@ private void CreateCommandBufferIfNeeded()
{
_commandBuffer = new CommandBuffer();
_commandBuffer.name = string.Format("{0} - {1}", GetType().Name, name);

#if UNITY_EDITOR

_commandBufferUpdateCounter = 0;

#endif
}
}

Expand Down
Loading

0 comments on commit 31e34e3

Please sign in to comment.