Skip to content

Commit 31e34e3

Browse files
committed
Merge branch 'release/0.6.0'
2 parents 6bf864f + cabd5c3 commit 31e34e3

22 files changed

+807
-122
lines changed

Assets/Examples/Prefabs/TestOutlineLayers.asset

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,18 @@ MonoBehaviour:
1919
_outlineWidth: 5
2020
_outlineIntensity: 2
2121
_outlineMode: 0
22+
_enabled: 1
2223
- _settings:
2324
_outlineSettings: {fileID: 0}
2425
_outlineColor: {r: 1, g: 1, b: 0, a: 1}
2526
_outlineWidth: 15
2627
_outlineIntensity: 2
2728
_outlineMode: 1
29+
_enabled: 1
2830
- _settings:
2931
_outlineSettings: {fileID: 0}
3032
_outlineColor: {r: 1, g: 0, b: 1, a: 1}
3133
_outlineWidth: 4
3234
_outlineIntensity: 2
3335
_outlineMode: 0
36+
_enabled: 1

Assets/Plugins/UnityFx.Outline/Editor/Scripts/OutlineBehaviourEditor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ namespace UnityFx.Outline
1212
public class OutlineBehaviourEditor : Editor
1313
{
1414
private OutlineBehaviour _effect;
15+
private bool _debugOpened;
1516
private bool _renderersOpened;
1617
private bool _camerasOpened;
1718

@@ -78,6 +79,18 @@ public override void OnInspectorGUI()
7879
EditorGUI.indentLevel -= 1;
7980
EditorGUI.EndDisabledGroup();
8081
}
82+
83+
// 4) Debug info.
84+
_debugOpened = EditorGUILayout.Foldout(_debugOpened, "Debug", true);
85+
86+
if (_debugOpened)
87+
{
88+
EditorGUI.BeginDisabledGroup(true);
89+
EditorGUI.indentLevel += 1;
90+
EditorGUILayout.IntField("Command buffer updates", _effect.NumberOfCommandBufferUpdates);
91+
EditorGUI.indentLevel -= 1;
92+
EditorGUI.EndDisabledGroup();
93+
}
8194
}
8295
}
8396
}

Assets/Plugins/UnityFx.Outline/Editor/Scripts/OutlineEditorUtility.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,18 @@ public static void RenderPreview(OutlineLayer layer, int layerIndex, bool showOb
106106
EditorGUI.indentLevel += 1;
107107
EditorGUILayout.PrefixLabel("Layer #" + layerIndex.ToString());
108108
EditorGUI.indentLevel -= 1;
109-
EditorGUILayout.IntField(layer.OutlineWidth, GUILayout.MaxWidth(100));
110-
EditorGUILayout.ColorField(layer.OutlineColor, GUILayout.MinWidth(100));
109+
110+
if (layer.Enabled)
111+
{
112+
EditorGUILayout.LabelField(layer.OutlineMode == OutlineMode.Solid ? layer.OutlineMode.ToString() : string.Format("Blurred ({0})", layer.OutlineIntensity), GUILayout.MaxWidth(70));
113+
EditorGUILayout.IntField(layer.OutlineWidth, GUILayout.MaxWidth(100));
114+
EditorGUILayout.ColorField(layer.OutlineColor, GUILayout.MinWidth(100));
115+
}
116+
else
117+
{
118+
EditorGUILayout.LabelField("Disabled.");
119+
}
120+
111121
EditorGUILayout.EndHorizontal();
112122

113123
if (showObjects)

Assets/Plugins/UnityFx.Outline/Editor/Scripts/OutlineEffectEditor.cs

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,16 @@
55
using System.Collections;
66
using System.Collections.Generic;
77
using UnityEditor;
8-
using UnityEngine;
8+
using UnityEditor.SceneManagement;
9+
using UnityEngine.Rendering;
910

1011
namespace UnityFx.Outline
1112
{
1213
[CustomEditor(typeof(OutlineEffect))]
1314
public class OutlineEffectEditor : Editor
1415
{
1516
private OutlineEffect _effect;
17+
private bool _debugOpened;
1618
private bool _previewOpened;
1719

1820
private void OnEnable()
@@ -24,6 +26,25 @@ public override void OnInspectorGUI()
2426
{
2527
base.OnInspectorGUI();
2628

29+
EditorGUI.BeginChangeCheck();
30+
var e = (CameraEvent)EditorGUILayout.EnumPopup("Render Event", _effect.RenderEvent);
31+
32+
if (e != _effect.RenderEvent)
33+
{
34+
Undo.RecordObject(_effect, "Set Render Event");
35+
_effect.RenderEvent = e;
36+
}
37+
38+
if (EditorGUI.EndChangeCheck())
39+
{
40+
EditorUtility.SetDirty(_effect.gameObject);
41+
42+
if (!EditorApplication.isPlayingOrWillChangePlaymode)
43+
{
44+
EditorSceneManager.MarkSceneDirty(_effect.gameObject.scene);
45+
}
46+
}
47+
2748
if (_effect.OutlineLayers.Count > 0)
2849
{
2950
_previewOpened = EditorGUILayout.Foldout(_previewOpened, "Preview", true);
@@ -33,6 +54,17 @@ public override void OnInspectorGUI()
3354
OutlineEditorUtility.RenderPreview(_effect.OutlineLayers, true);
3455
}
3556
}
57+
58+
_debugOpened = EditorGUILayout.Foldout(_debugOpened, "Debug", true);
59+
60+
if (_debugOpened)
61+
{
62+
EditorGUI.BeginDisabledGroup(true);
63+
EditorGUI.indentLevel += 1;
64+
EditorGUILayout.IntField("Command buffer updates", _effect.NumberOfCommandBufferUpdates);
65+
EditorGUI.indentLevel -= 1;
66+
EditorGUI.EndDisabledGroup();
67+
}
3668
}
3769
}
3870
}

Assets/Plugins/UnityFx.Outline/Editor/Scripts/OutlineLayerCollectionEditor.cs

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,23 @@ public override void OnInspectorGUI()
2929
for (var i = 0; i < _layers.Count; i++)
3030
{
3131
EditorGUILayout.Space();
32+
3233
var rect = EditorGUILayout.BeginHorizontal();
33-
EditorGUILayout.PrefixLabel("Layer #" + i.ToString());
34+
var enabled = EditorGUILayout.ToggleLeft("Layer #" + i.ToString(), _layers[i].Enabled);
35+
36+
if (enabled != _layers[i].Enabled)
37+
{
38+
if (enabled)
39+
{
40+
Undo.RecordObject(_layers, "Enable Layer");
41+
}
42+
else
43+
{
44+
Undo.RecordObject(_layers, "Disable Layer");
45+
}
46+
47+
_layers[i].Enabled = enabled;
48+
}
3449

3550
GUILayout.FlexibleSpace();
3651

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

5065
GUI.Box(rect, GUIContent.none);
5166

67+
var name = EditorGUILayout.TextField("Layer Name", _layers[i].NameTag);
68+
69+
if (name != _layers[i].NameTag)
70+
{
71+
Undo.RecordObject(_layers, "Set Layer Name");
72+
_layers[i].NameTag = name;
73+
}
74+
75+
var priority = EditorGUILayout.IntField("Layer Priority", _layers[i].Priority);
76+
77+
if (priority != _layers[i].Priority)
78+
{
79+
Undo.RecordObject(_layers, "Set Layer Priority");
80+
_layers[i].Priority = priority;
81+
}
82+
5283
OutlineEditorUtility.Render(_layers[i], _layers);
5384
}
5485
}

Assets/Plugins/UnityFx.Outline/Runtime/Scripts/Helpers.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Copyright (C) 2019 Alexander Bogarsukov. All rights reserved.
2+
// See the LICENSE.md file in the project root for more information.
3+
4+
using System.Reflection;
5+
using System.Runtime.CompilerServices;
6+
using System.Runtime.InteropServices;
7+
8+
// General Information about an assembly is controlled through the following
9+
// set of attributes. Change these attribute values to modify the information
10+
// associated with an assembly.
11+
[assembly: AssemblyTitle("UnityFx.Outline")]
12+
[assembly: AssemblyProduct("UnityFx.Outline")]
13+
[assembly: AssemblyDescription("Screen-space outlines for Unity3d.")]
14+
#if DEBUG
15+
[assembly: AssemblyConfiguration("Debug")]
16+
#else
17+
[assembly: AssemblyConfiguration("Release")]
18+
#endif
19+
[assembly: AssemblyCompany("")]
20+
[assembly: AssemblyCopyright("Copyright © Alexander Bogarsukov 2019")]
21+
[assembly: AssemblyCulture("")]
22+
23+
// Setting ComVisible to false makes the types in this assembly not visible
24+
// to COM components. If you need to access a type in this assembly from
25+
// COM, set the ComVisible attribute to true on that type.
26+
[assembly: ComVisible(false)]
27+
28+
// The following GUID is for the ID of the typelib if this project is exposed to COM.
29+
[assembly: Guid("1ace8625-97c5-4d37-a649-03975d187542")]
30+
31+
// Make internals visible to the editor assembly.
32+
[assembly: InternalsVisibleTo("UnityFx.Outline.Editor")]

Assets/Plugins/UnityFx.Outline/Runtime/Scripts/Helpers/AssemblyInfo.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineBehaviour.Renderers.cs

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ private void OnWillRenderObject()
3535
}
3636
}
3737

38-
private sealed class RendererCollection : IList<Renderer>
38+
private sealed class RendererCollection : ICollection<Renderer>
3939
{
4040
#region data
4141

@@ -73,58 +73,6 @@ public void Reset()
7373

7474
#endregion
7575

76-
#region IList
77-
78-
public Renderer this[int index]
79-
{
80-
get
81-
{
82-
return _renderers[index];
83-
}
84-
set
85-
{
86-
if (index < 0 || index >= _renderers.Count)
87-
{
88-
throw new ArgumentOutOfRangeException("index");
89-
}
90-
91-
Validate(value);
92-
Release(_renderers[index]);
93-
Init(value);
94-
95-
_renderers[index] = value;
96-
}
97-
}
98-
99-
public int IndexOf(Renderer renderer)
100-
{
101-
return _renderers.IndexOf(renderer);
102-
}
103-
104-
public void Insert(int index, Renderer renderer)
105-
{
106-
if (index < 0 || index >= _renderers.Count)
107-
{
108-
throw new ArgumentOutOfRangeException("index");
109-
}
110-
111-
Validate(renderer);
112-
Init(renderer);
113-
114-
_renderers.Insert(index, renderer);
115-
}
116-
117-
public void RemoveAt(int index)
118-
{
119-
if (index >= 0 && index < _renderers.Count)
120-
{
121-
Release(_renderers[index]);
122-
_renderers.RemoveAt(index);
123-
}
124-
}
125-
126-
#endregion
127-
12876
#region ICollection
12977

13078
public int Count

Assets/Plugins/UnityFx.Outline/Runtime/Scripts/OutlineBehaviour.cs

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,31 @@ public sealed partial class OutlineBehaviour : MonoBehaviour, IOutlineSettingsEx
3434
private Dictionary<Camera, CommandBuffer> _cameraMap = new Dictionary<Camera, CommandBuffer>();
3535
private float _cameraMapUpdateTimer;
3636

37+
#if UNITY_EDITOR
38+
39+
private int _commandBufferUpdateCounter;
40+
41+
#endif
42+
3743
#endregion
3844

3945
#region interface
4046

47+
#if UNITY_EDITOR
48+
49+
/// <summary>
50+
/// Gets number of the command buffer updates since its creation. Only available in editor.
51+
/// </summary>
52+
public int NumberOfCommandBufferUpdates
53+
{
54+
get
55+
{
56+
return _commandBufferUpdateCounter;
57+
}
58+
}
59+
60+
#endif
61+
4162
/// <summary>
4263
/// Gets or sets resources used by the effect implementation.
4364
/// </summary>
@@ -148,14 +169,20 @@ private void Update()
148169

149170
#endif
150171

151-
if (_outlineResources != null && _renderers != null && _outlineSettings.IsChanged)
172+
if (_outlineResources != null && _renderers != null && (_outlineSettings.IsChanged || _commandBuffer.sizeInBytes == 0))
152173
{
153174
using (var renderer = new OutlineRenderer(_commandBuffer, BuiltinRenderTextureType.CameraTarget))
154175
{
155176
renderer.RenderSingleObject(_renderers, _outlineSettings.OutlineMaterials);
156177
}
157178

158179
_outlineSettings.AcceptChanges();
180+
181+
#if UNITY_EDITOR
182+
183+
_commandBufferUpdateCounter++;
184+
185+
#endif
159186
}
160187
}
161188

@@ -306,6 +333,12 @@ private void CreateCommandBufferIfNeeded()
306333
{
307334
_commandBuffer = new CommandBuffer();
308335
_commandBuffer.name = string.Format("{0} - {1}", GetType().Name, name);
336+
337+
#if UNITY_EDITOR
338+
339+
_commandBufferUpdateCounter = 0;
340+
341+
#endif
309342
}
310343
}
311344

0 commit comments

Comments
 (0)