Frédéric Vauchelles
7 年前
当前提交
75a2ac52
共有 7 个文件被更改,包括 101 次插入 和 107 次删除
-
13ScriptableRenderPipeline/Core/CoreRP/CoreUtils.cs
-
56ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/EditorReflectionSystem.cs
-
3ScriptableRenderPipeline/HDRenderPipeline/HDRP/Editor/Lighting/Reflection/HDReflectionProbeEditorUtility.cs
-
2ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/HDLightingDataAsset.cs.meta
-
67ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/HDLightingDataAsset.cs
-
67ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/ReflectionSystemSceneDictionary.cs
-
0/ScriptableRenderPipeline/HDRenderPipeline/HDRP/Lighting/Reflection/HDLightingDataAsset.cs.meta
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEditor; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class HDLightingDataAsset : ScriptableObject, ISerializationCallbackReceiver |
|||
{ |
|||
[Serializable] |
|||
class ObjectIDPair |
|||
{ |
|||
public SceneObjectIdentifier Key; |
|||
public Object Value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
List<ObjectIDPair> m_ObjectList = new List<ObjectIDPair>(); |
|||
|
|||
Dictionary<Object, SceneObjectIdentifier> m_ObjectIndex = new Dictionary<Object, SceneObjectIdentifier>(); |
|||
Dictionary<SceneObjectIdentifier, Object> m_IDIndex = new Dictionary<SceneObjectIdentifier, Object>(); |
|||
|
|||
public SceneObjectIdentifier GetIdFor(Object probe) |
|||
{ |
|||
if (m_ObjectIndex.ContainsKey(probe)) |
|||
return m_ObjectIndex[probe]; |
|||
|
|||
var id = EditorUtility.GetSceneObjectIdentifierFor(probe); |
|||
if (id == SceneObjectIdentifier.Null) |
|||
{ |
|||
Debug.LogWarningFormat("Could not get the scene object id for {0}", probe); |
|||
return SceneObjectIdentifier.Null; |
|||
} |
|||
|
|||
m_ObjectList.Add(new ObjectIDPair |
|||
{ |
|||
Key = id, |
|||
Value = probe |
|||
}); |
|||
|
|||
m_ObjectIndex[probe] = id; |
|||
m_IDIndex[id] = probe; |
|||
|
|||
return id; |
|||
} |
|||
|
|||
public void OnBeforeSerialize() |
|||
{ |
|||
for (var i = m_ObjectList.Count - 1; i >= 0; --i) |
|||
{ |
|||
if (m_ObjectList[i].Value == null) |
|||
m_ObjectList.RemoveAt(i); |
|||
} |
|||
} |
|||
|
|||
public void OnAfterDeserialize() |
|||
{ |
|||
for (var i = 0; i < m_ObjectList.Count; i++) |
|||
{ |
|||
if (m_IDIndex.ContainsKey(m_ObjectList[i].Key)) |
|||
Debug.LogErrorFormat(this, "ID {0} is a duplicated in ReflectionSystemSceneDictionary ({1}) for {2}", m_ObjectList[i].Key, this, m_ObjectList[i].Value); |
|||
|
|||
m_ObjectIndex[m_ObjectList[i].Value] = m_ObjectList[i].Key; |
|||
m_IDIndex[m_ObjectList[i].Key] = m_ObjectList[i].Value; |
|||
} |
|||
} |
|||
} |
|||
} |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEngine.Experimental.Rendering.HDPipeline |
|||
{ |
|||
public class ReflectionSystemSceneDictionary : MonoBehaviour, ISerializationCallbackReceiver |
|||
{ |
|||
[Serializable] |
|||
class ObjectIDPair |
|||
{ |
|||
public int Key; |
|||
public Object Value; |
|||
} |
|||
|
|||
[SerializeField] |
|||
List<ObjectIDPair> m_ObjectList = new List<ObjectIDPair>(); |
|||
|
|||
Dictionary<Object, int> m_ObjectIndex = new Dictionary<Object, int>(); |
|||
Dictionary<int, Object> m_IDIndex = new Dictionary<int, Object>(); |
|||
|
|||
public int GetIdFor(Object probe) |
|||
{ |
|||
if (m_ObjectIndex.ContainsKey(probe)) |
|||
return m_ObjectIndex[probe]; |
|||
|
|||
var id = FindNextId(); |
|||
m_ObjectList.Add(new ObjectIDPair |
|||
{ |
|||
Key = id, |
|||
Value = probe |
|||
}); |
|||
|
|||
m_ObjectIndex[probe] = id; |
|||
m_IDIndex[id] = probe; |
|||
|
|||
return id; |
|||
} |
|||
|
|||
public void OnBeforeSerialize() |
|||
{ |
|||
for (var i = m_ObjectList.Count - 1; i >= 0; --i) |
|||
{ |
|||
if (m_ObjectList[i].Value == null) |
|||
m_ObjectList.RemoveAt(i); |
|||
} |
|||
} |
|||
|
|||
public void OnAfterDeserialize() |
|||
{ |
|||
for (int i = 0; i < m_ObjectList.Count; i++) |
|||
{ |
|||
if (m_IDIndex.ContainsKey(m_ObjectList[i].Key)) |
|||
Debug.LogErrorFormat(this, "ID {0} is a duplicated in ReflectionSystemSceneDictionary ({1}) for {2}", m_ObjectList[i].Key, this, m_ObjectList[i].Value); |
|||
|
|||
m_ObjectIndex[m_ObjectList[i].Value] = m_ObjectList[i].Key; |
|||
m_IDIndex[m_ObjectList[i].Key] = m_ObjectList[i].Value; |
|||
} |
|||
} |
|||
|
|||
int FindNextId() |
|||
{ |
|||
var id = 0; |
|||
while (m_IDIndex.ContainsKey(id)) ++id; |
|||
return id; |
|||
} |
|||
} |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue