Ejemplo n.º 1
0
    private static int GetItemIdMatchingRecursive(HierarchyFrameDataView frameData, int itemId, Func <string, bool> predicate)
    {
        string searchString = "";

        var functionName = frameData.GetItemName(itemId);

        searchString += functionName;
        var goInstanceId = frameData.GetItemInstanceID(itemId);

        if (goInstanceId > 0)
        {
            var go       = EditorUtility.InstanceIDToObject(goInstanceId);
            var typeName = go.GetType().Name;
            searchString += $" - {go.name} ({typeName})";
        }

        var isMatch = predicate(searchString);

        if (isMatch)
        {
            return(itemId);
        }
        else
        {
            var itemChildrenIds = new List <int>();
            frameData.GetItemChildren(itemId, itemChildrenIds);
            foreach (var childId in itemChildrenIds)
            {
                var foundId = GetItemIdMatchingRecursive(frameData, childId, predicate);
                if (foundId != -1)
                {
                    return(foundId);
                }
            }
        }

        return(-1);
    }
Ejemplo n.º 2
0
    private void ShowFoundItemInProfiler(HierarchyFrameDataView frameData, int matchingItemId, int frameIndex)
    {
        var goInstanceId = frameData.GetItemInstanceID(matchingItemId);
        var foundObject  = EditorUtility.InstanceIDToObject(goInstanceId);

        //Selection.activeObject = foundObject;
        EditorGUIUtility.PingObject(foundObject);

        var profilerWindowInterface = new ProfilerWindowInterface();

        profilerWindowInterface.OpenProfilerOrUseExisting();
        profilerWindowInterface.JumpToFrame(frameIndex + 1);

        var markerName = frameData.GetItemName(matchingItemId);

        profilerWindowInterface.SetProfilerWindowMarkerName(markerName, new List <string>()
        {
            LookInThread
        });

        ProfilerDriver.enabled     = false;
        EditorApplication.isPaused = true;
    }