private void CreateShaderPropInfos(FrameDebuggerEventData frameInfo) { var originProps = frameInfo.shaderProperties; var originPropType = this.reflectionCache.GetTypeObject(originProps.GetType()); var originPropReflection = new ReflectionClassWithObject(originPropType, originProps); frameInfo.convertedProperties = new ShaderProperties(); originPropReflection.CopyFieldsToObjectByVarName <ShaderProperties>(ref frameInfo.convertedProperties); var props = frameInfo.convertedProperties; props.convertedFloats = ReflectionClassWithObject.CopyToListFromArray <ShaderPropertyInfo>(this.reflectionCache, props.floats); props.convertedVectors = ReflectionClassWithObject.CopyToListFromArray <ShaderPropertyInfo>(this.reflectionCache, props.vectors); props.convertedMatricies = ReflectionClassWithObject.CopyToListFromArray <ShaderPropertyInfo>(this.reflectionCache, props.matrices); props.convertedTextures = ReflectionClassWithObject.CopyToListFromArray <ShaderPropertyInfo>(this.reflectionCache, props.textures); props.convertedBuffers = ReflectionClassWithObject.CopyToListFromArray <ShaderPropertyInfo>(this.reflectionCache, props.buffers); }
public FrameInfoCrawler(ReflectionCache rcache) { this.reflectionCache = rcache; this.frameDebuggeUtil = reflectionCache.GetTypeObject("UnityEditorInternal.FrameDebuggerUtility"); this.frameEventData = reflectionCache.GetTypeObject("UnityEditorInternal.FrameDebuggerEventData"); var frameDebuggerWindowType = this.reflectionCache.GetTypeObject("UnityEditor.FrameDebuggerWindow"); var window = frameDebuggerWindowType.CallMethod <object>("ShowFrameDebuggerWindow", null, null); this.frameDebuggerWindowObj = new ReflectionClassWithObject(frameDebuggerWindowType, window); this.IsRunning = false; this.alreadyWriteTextureDict = new Dictionary <int, TextureUtility.SaveTextureInfo>(); this.savedRenderTexture = new Dictionary <SavedRenderTextureInfo, TextureUtility.SaveTextureInfo>(); this.renderTextureLastChanged = new Dictionary <int, int>(); }
private bool GetFrameEventData(int frameIdx, out ReflectionClassWithObject ret) { object[] args = null; #if UNITY_2019_3_OR_NEWER args = new object[] { frameIdx, this.frameEventData.CreateInstance() }; #else args = new object[] { frameIdx, null }; #endif bool result = this.frameDebuggeUtil.CallMethod <bool>("GetFrameEventData", null, args); if (result) { ret = new ReflectionClassWithObject(frameEventData, args[1]); } else { ret = null; } return(result); }
private IEnumerator TryGetFrameEvnetData(int frameIdx, double deltaTime = 2) { double startTime = EditorApplication.timeSinceStartup; int limit = frameDebuggeUtil.GetPropertyValue <int>("limit", null); while ((EditorApplication.timeSinceStartup - startTime) < deltaTime) { bool res = GetFrameEventData(frameIdx, out this.currentFrameEventData); if (res) { break; } else { currentFrameEventData = null; yield return(null); } } }
public static List <T> CopyToListFromArray <T>(ReflectionCache cache, System.Array arr) { if (arr == null) { return(null); } List <T> list = new List <T>(arr.Length); if (arr.Length <= 0) { return(list); } foreach (var obj in arr) { T dest = (T)System.Activator.CreateInstance(typeof(T)); var reflectionType = cache.GetTypeObject(obj.GetType()); var reflectionClassWithObject = new ReflectionClassWithObject(reflectionType, obj); reflectionClassWithObject.CopyFieldsToObjectByVarName(ref dest); list.Add(dest); } return(list); }
private void CreateFrameDebuggerEventList(System.Array arr) { this.frameDebuggerEventList = ReflectionClassWithObject.CopyToListFromArray <FrameDebuggerEvent>(this.reflectionCache, arr); }