浏览代码
[shader graph]
[shader graph]
*Fix exposition of vector properties *Change validation (graph wholeistic) *Add view layer callback for when nodes change internally (need repaint) *Add missing pool classes/main
当前提交
abcc9002
共有 24 个文件被更改,包括 331 次插入 和 174 次删除
-
47UnityProject/Assets/UnityShaderEditor/Editor/Source/BaseMaterialGraph.cs
-
39UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/DrawableMaterialNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialGraphDataSource.cs
-
3UnityProject/Assets/UnityShaderEditor/Editor/Source/Drawing/MaterialWindow.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Editors/MaterialGraphEditor.cs
-
6UnityProject/Assets/UnityShaderEditor/Editor/Source/MaterialSubGraph.cs
-
16UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/AddNode.cs
-
123UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BaseMaterialNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/BlendNode.cs
-
8UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/ColorNode.cs
-
6UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PixelShaderNode.cs
-
78UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/PropertyNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/SubGraphNode.cs
-
2UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/SwizzleNode.cs
-
14UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/TextureNode.cs
-
8UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector1Node.cs
-
11UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector2Node.cs
-
14UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector3Node.cs
-
14UnityProject/Assets/UnityShaderEditor/Editor/Source/Nodes/Vector4Node.cs
-
15UnityProject/Assets/UnityShaderEditor/Editor/Source/PixelGraph.cs
-
20UnityProject/Assets/UnityShaderEditor/Editor/Source/Util/ListPool.cs
-
12UnityProject/Assets/UnityShaderEditor/Editor/Source/Util/ListPool.cs.meta
-
49UnityProject/Assets/UnityShaderEditor/Editor/Source/Util/ObjectPool.cs
-
12UnityProject/Assets/UnityShaderEditor/Editor/Source/Util/ObjectPool.cs.meta
|
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEditor.MaterialGraph |
|||
{ |
|||
internal static class ListPool<T> |
|||
{ |
|||
// Object pool to avoid allocations.
|
|||
private static readonly ObjectPool<List<T>> s_ListPool = new ObjectPool<List<T>>(null, l => l.Clear()); |
|||
|
|||
public static List<T> Get() |
|||
{ |
|||
return s_ListPool.Get(); |
|||
} |
|||
|
|||
public static void Release(List<T> toRelease) |
|||
{ |
|||
s_ListPool.Release(toRelease); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 10e666e06d86d864d9d607de2f213fdc |
|||
timeCreated: 1453393151 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using UnityEngine.Events; |
|||
|
|||
namespace UnityEditor.MaterialGraph |
|||
{ |
|||
internal class ObjectPool<T> where T : new() |
|||
{ |
|||
private readonly Stack<T> m_Stack = new Stack<T>(); |
|||
private readonly UnityAction<T> m_ActionOnGet; |
|||
private readonly UnityAction<T> m_ActionOnRelease; |
|||
|
|||
public int countAll { get; private set; } |
|||
public int countActive { get { return countAll - countInactive; } } |
|||
public int countInactive { get { return m_Stack.Count; } } |
|||
|
|||
public ObjectPool(UnityAction<T> actionOnGet, UnityAction<T> actionOnRelease) |
|||
{ |
|||
m_ActionOnGet = actionOnGet; |
|||
m_ActionOnRelease = actionOnRelease; |
|||
} |
|||
|
|||
public T Get() |
|||
{ |
|||
T element; |
|||
if (m_Stack.Count == 0) |
|||
{ |
|||
element = new T(); |
|||
countAll++; |
|||
} |
|||
else |
|||
{ |
|||
element = m_Stack.Pop(); |
|||
} |
|||
if (m_ActionOnGet != null) |
|||
m_ActionOnGet(element); |
|||
return element; |
|||
} |
|||
|
|||
public void Release(T element) |
|||
{ |
|||
if (m_Stack.Count > 0 && ReferenceEquals(m_Stack.Peek(), element)) |
|||
Debug.LogError("Internal error. Trying to destroy object that is already released to pool."); |
|||
if (m_ActionOnRelease != null) |
|||
m_ActionOnRelease(element); |
|||
m_Stack.Push(element); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: a47156f8a364c344d9a2cc4bd904afc8 |
|||
timeCreated: 1453393151 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue