void OnResourceManagerDiagnosticEvent(AsyncOperationHandle op, ResourceManager.DiagnosticEventType type, int eventValue, object context) { var hashCode = op.GetHashCode(); DiagnosticInfo diagInfo = null; if (type == ResourceManager.DiagnosticEventType.AsyncOperationDestroy) { if (m_cachedDiagnosticInfo.TryGetValue(hashCode, out diagInfo)) { m_cachedDiagnosticInfo.Remove(hashCode); } } else { if (!m_cachedDiagnosticInfo.TryGetValue(hashCode, out diagInfo)) { m_dependencyBuffer.Clear(); op.GetDependencies(m_dependencyBuffer); var depIds = new int[m_dependencyBuffer.Count]; for (int i = 0; i < depIds.Length; i++) { depIds[i] = m_dependencyBuffer[i].GetHashCode(); } m_cachedDiagnosticInfo.Add(hashCode, diagInfo = new DiagnosticInfo() { ObjectId = hashCode, DisplayName = op.DebugName, Dependencies = depIds }); } } m_eventCollector.PostEvent(diagInfo.CreateEvent("ResourceManager", type, Time.frameCount, eventValue)); }
internal int CalculateCompletedOperationHashcode(AsyncOperationHandle handle) { unchecked { if (handle.Result == null) { return(handle.GetHashCode()); } return(handle.Result.GetHashCode() + handle.Result.GetType().GetHashCode()); } }
internal int CalculateHashCode(AsyncOperationHandle handle) { int sumOfDependencyHashes = SumDependencyNameHashCodes(handle); bool nameChangesWithState = handle.DebugName.Contains("result=") && handle.DebugName.Contains("status="); // We default to the regular hash code in the case of operations with names that change with their state // since their names aren't a reliable way to reference them if (nameChangesWithState) { return(handle.GetHashCode()); } //its okay if this overflows unchecked { return(handle.DebugName.GetHashCode() + sumOfDependencyHashes); } }