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 SumDependencyNameHashCodes(AsyncOperationHandle handle)
        {
            List <AsyncOperationHandle> deps = new List <AsyncOperationHandle>();

            handle.GetDependencies(deps);

            int sumOfDependencyHashes = 0;

            foreach (var d in deps)
            {
                unchecked
                {
                    sumOfDependencyHashes += d.DebugName.GetHashCode() + SumDependencyNameHashCodes(d);
                }
            }
            return(sumOfDependencyHashes);
        }
Exemplo n.º 3
0
    public void ChainOperationWithTypelessDependency_DoesNotReturnInvalidDependencyHandles()
    {
        //Setup
        ChainOperationTypelessDepedency <object> chainOp       = new ChainOperationTypelessDepedency <object>();
        AsyncOperationHandle <object>            chainOpHandle = new AsyncOperationHandle <object>(new ProviderOperation <object>());

        chainOp.Init(chainOpHandle, null, false);

        //Test
        List <AsyncOperationHandle> dependencies = new List <AsyncOperationHandle>();
        AsyncOperationHandle        handle       = new AsyncOperationHandle(chainOp);

        chainOpHandle.m_InternalOp.m_Version = 1;
        handle.GetDependencies(dependencies);

        //Assert
        Assert.AreEqual(0, dependencies.Count);
    }