{"action":"created","issue":{"url":"https://api.github.com/repos/SiliconStudio/paradox/issues/315","labels_url":"https://api.github.com/repos/SiliconStudio/paradox/issues/315/labels{/name}","comments_url":"https://api.github.com/repos/SiliconStudio/paradox/issues/315/comments","events_url":"https://api.github.com/repos/SiliconStudio/paradox/issues/315/events","html_url":"https://github.com/SiliconStudio/paradox/issues/315","id":108408258,"number":315,"title":"Loading asset in Component Renderer breaks Paradox Studio Scene View","user":{"login":"wanderwurst","id":14100936,"avatar_url":"https://avatars.githubusercontent.com/u/14100936?v=3","gravatar_id":"","url":"https://api.github.com/users/wanderwurst","html_url":"https://github.com/wanderwurst","followers_url":"https://api.github.com/users/wanderwurst/followers","following_url":"https://api.github.com/users/wanderwurst/following{/other_user}","gists_url":"https://api.github.com/users/wanderwurst/gists{/gist_id}","starred_url":"https://api.github.com/users/wanderwurst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wanderwurst/subscriptions","organizations_url":"https://api.github.com/users/wanderwurst/orgs","repos_url":"https://api.github.com/users/wanderwurst/repos","events_url":"https://api.github.com/users/wanderwurst/events{/privacy}","received_events_url":"https://api.github.com/users/wanderwurst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-09-25T21:07:30Z","updated_at":"2015-10-08T04:53:24Z","closed_at":null,"body":"I am trying to create a component similar to the Sprite component, but dumbed down. All it should do is to draw pseudo light effects using the same texture all over (a circular gradient) in additive blend mode.\r\nI try to load the texture in InitializeCore() which works fine when I run the game from VisualStudio. But opening it in Paradox Studio stops the main scene from rendering there. When I remove the Assets.Load() call and instead create a square texture in memory, everything works fine.\r\n\r\nI guess this is either some bug or I am just not supposed to use the Assets.Load() call in the Renderer. But then, when and where would I load a texture that I want to use here?\r\n\r\nAlso, I guess PStudio catches an exception on rendering and then stops. Is there some kind of logging for these exceptions that would make finding my bad code somewhat easier?\r\n\r\nHere is my component code, just in case:\r\nRenderer\r\n```C#\r\nusing MyGame1.CustomComponents;\r\nusing MyGame1.CustomProcessors;\r\nusing SiliconStudio.Core.Mathematics;\r\nusing SiliconStudio.Paradox.Engine;\r\nusing SiliconStudio.Paradox.Graphics;\r\nusing SiliconStudio.Paradox.Rendering;\r\nusing System;\r\nusing System.Collections.Generic;\r\nusing System.Linq;\r\n\r\nnamespace MyGame1.CustomRenderers\r\n{\r\n    public class SpriteLightRenderer : EntityComponentRendererBase\r\n    {\r\n        private Sprite3DBatch _sprite3DBatch;\r\n        private Quaternion _toScreenRotation = Quaternion.RotationX(-MathUtil.PiOverTwo);\r\n        private Texture _pointLightTexture = null;\r\n        private RectangleF _pointLightRegion;\r\n\r\n        protected override void InitializeCore()\r\n        {\r\n            base.InitializeCore();\r\n\r\n            _sprite3DBatch = new Sprite3DBatch(GraphicsDevice);\r\n\r\n            // --- commenting out from here...\r\n            _pointLightTexture = Assets.IsLoaded(\"PointLight\") ? Assets.Get<Texture>(\"PointLight\") : Assets.Load<Texture>(\"PointLight\");\r\n\r\n            if (_pointLightTexture != null)\r\n            {\r\n                _pointLightRegion = new RectangleF(0, 0, _pointLightTexture.Width, _pointLightTexture.Height);\r\n            }\r\n            else\r\n            // --- to here makes it run fine with Paradox Studio\r\n            {\r\n                // Create a square texture from scratch\r\n                const int C_SQUARE_SIZE = 16;\r\n                uint[] particleData = Enumerable.Repeat<uint>(uint.MaxValue, C_SQUARE_SIZE * C_SQUARE_SIZE).ToArray();\r\n                _pointLightTexture = Texture.New2D<UInt32>(GraphicsDevice, C_SQUARE_SIZE, C_SQUARE_SIZE, PixelFormat.B8G8R8A8_UNorm_SRgb, particleData);\r\n                _pointLightRegion = new RectangleF(0, 0, C_SQUARE_SIZE, C_SQUARE_SIZE);\r\n            }\r\n        }\r\n\r\n        protected override void PrepareCore(RenderContext context, RenderItemCollection opaqueList, RenderItemCollection transparentList)\r\n        {\r\n            var spriteLightProcessor = SceneInstance.GetProcessor<SpriteLightProcessor>();\r\n            if ((spriteLightProcessor == null) || (spriteLightProcessor.RenderList == null))\r\n                return;\r\n\r\n            foreach (var spriteLight in spriteLightProcessor.RenderList)\r\n            {\r\n                // Perform culling on group and accept\r\n                if (!CurrentCullingMask.Contains(spriteLight.Key.Group))\r\n                    continue;\r\n\r\n                opaqueList.Add(new RenderItem(this, spriteLight, int.MaxValue));\r\n                return;\r\n            }\r\n        }\r\n\r\n        protected override void DrawCore(RenderContext context, RenderItemCollection renderItems, int fromIndex, int toIndex)\r\n        {\r\n            if ((fromIndex < 0) || (toIndex < fromIndex))\r\n                return;\r\n\r\n            var graphicsDevice = context.GraphicsDevice;\r\n\r\n            CameraComponent cam = context.GetCurrentCamera();\r\n            if (cam == null)\r\n                return;\r\n            Matrix projection = cam.ViewProjectionMatrix;\r\n\r\n            _sprite3DBatch.Begin(projection, SpriteSortMode.Deferred, blendState: graphicsDevice.BlendStates.Additive);\r\n\r\n            for (int i = fromIndex; i <= toIndex; i++)\r\n            {\r\n                var renderItem = renderItems[i];\r\n                KeyValuePair<Entity, SpriteLightComponent> entityComponent = (KeyValuePair<Entity, SpriteLightComponent>)renderItem.DrawContext;\r\n\r\n                Matrix worldPos = Matrix.AffineTransformation(1, _toScreenRotation, entityComponent.Key.Transform.WorldMatrix.TranslationVector);\r\n\r\n                _sprite3DBatch.Draw(texture: _pointLightTexture,\r\n                    worldMatrix: ref worldPos,\r\n                    sourceRectangle: ref _pointLightRegion,\r\n                    elementSize: ref entityComponent.Value.Size,\r\n                    color: ref entityComponent.Value.Color\r\n                    );\r\n            }\r\n\r\n            _sprite3DBatch.End();\r\n        }\r\n    }\r\n}\r\n```\r\nProcessor\r\n```C#\r\nusing MyGame1.CustomComponents;\r\nusing SiliconStudio.Core;\r\nusing SiliconStudio.Paradox.Engine;\r\nusing System.Collections.Generic;\r\n\r\nnamespace MyGame1.CustomProcessors\r\n{\r\n    public class SpriteLightProcessor : EntityProcessor<SpriteLightComponent>\r\n    {\r\n        public Dictionary<Entity, SpriteLightComponent> RenderList\r\n        {\r\n            get\r\n            {\r\n                if (this.Enabled)\r\n                    return enabledEntities;\r\n                return null;\r\n            }\r\n        }\r\n\r\n        public SpriteLightProcessor()\r\n            : base(new PropertyKey[] { SpriteLightComponent.Key })\r\n        {\r\n            Order = ProcessorOrders.SpriteLight;\r\n        }\r\n\r\n        protected override SpriteLightComponent GenerateAssociatedData(Entity entity)\r\n        {\r\n            SpriteLightComponent spriteLight = entity.Get<SpriteLightComponent>();\r\n            return spriteLight;\r\n        }\r\n    }\r\n}\r\n```\r\nComponent\r\n```C#\r\nusing MyGame1.CustomProcessors;\r\nusing MyGame1.CustomRenderers;\r\nusing SiliconStudio.Core;\r\nusing SiliconStudio.Core.Mathematics;\r\nusing SiliconStudio.Paradox.Engine;\r\nusing SiliconStudio.Paradox.Engine.Design;\r\n\r\nnamespace MyGame1.CustomComponents\r\n{\r\n    [Display(ProcessorOrders.SpriteLightSort, \"SpriteLight\", \"A simple 2D pseudo light\", Expand = ExpandRule.Once)]\r\n    [DataContract(\"SpriteLightComponent\")]\r\n    [DefaultEntityComponentRenderer(typeof(SpriteLightRenderer))]\r\n    [DefaultEntityComponentProcessor(typeof(SpriteLightProcessor))]\r\n    public class SpriteLightComponent : EntityComponent\r\n    {\r\n        public static PropertyKey<SpriteLightComponent> Key = new PropertyKey<SpriteLightComponent>(\"Key\", typeof(SpriteLightComponent));\r\n\r\n        public override PropertyKey GetDefaultKey()\r\n        {\r\n            return Key;\r\n        }\r\n\r\n        [DataMember(1)]\r\n        public Vector2 Size = Vector2.One;\r\n\r\n        [DataMember(2)]\r\n        public Color Color = Color.White;\r\n\r\n        public SpriteLightComponent()\r\n        {\r\n        }\r\n    }\r\n}\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/SiliconStudio/paradox/issues/comments/146419385","html_url":"https://github.com/SiliconStudio/paradox/issues/315#issuecomment-146419385","issue_url":"https://api.github.com/repos/SiliconStudio/paradox/issues/315","id":146419385,"user":{"login":"xenux","id":8893272,"avatar_url":"https://avatars.githubusercontent.com/u/8893272?v=3","gravatar_id":"","url":"https://api.github.com/users/xenux","html_url":"https://github.com/xenux","followers_url":"https://api.github.com/users/xenux/followers","following_url":"https://api.github.com/users/xenux/following{/other_user}","gists_url":"https://api.github.com/users/xenux/gists{/gist_id}","starred_url":"https://api.github.com/users/xenux/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xenux/subscriptions","organizations_url":"https://api.github.com/users/xenux/orgs","repos_url":"https://api.github.com/users/xenux/repos","events_url":"https://api.github.com/users/xenux/events{/privacy}","received_events_url":"https://api.github.com/users/xenux/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T04:53:24Z","updated_at":"2015-10-08T04:53:24Z","body":"Great thanks :)\r\n\r\nYou can keep the issue like this for the moment. We will close it when we fix it."}}