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 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); }