public async override Task GenerateVisual(object typeInstance, Type neosType, bool force = false)
        {
            Component targetInstance = typeInstance as Component;
            Category  typeCategory   = GetCategory(neosType);
            string    typeSafeName   = GetSafeName(neosType);

            if (!(force || NeedsVisual(typeSafeName, typeCategory)))
            {
                return;
            }

            Rect bounds = await BuildComponentUI(targetInstance);

            double aspectRatio = (bounds.height + 5.0) / bounds.width;

            VisualSlot.LocalPosition = new float3(0, ((((bounds.height / 2.0f) - bounds.Center.y) / 2.0f) + 5.0f) * 0.1f, 0.5f);
            VisualCaptureCamera.OrthographicSize.Value = (bounds.height + 5) / 20.0f;
            await new ToWorld();
            Bitmap2D componentImage = await VisualCaptureCamera.RenderToBitmap(new int2(400, (int)(400 * aspectRatio)));

            foreach (string path in typeCategory.Paths)
            {
                Directory.CreateDirectory($"{WikiAssetGenerator.BasePath}\\Components\\{path}\\");
                componentImage.Save($"{WikiAssetGenerator.BasePath}\\Components\\{path}\\{typeSafeName}Component.png", 100, true);
            }
            VisualSlot.DestroyChildren();
        }
Exemple #2
0
        public async override Task GenerateVisual(object typeInstance, Type neosType, bool force = false)
        {
            LogixNode targetInstance = typeInstance as LogixNode;
            Category  typeCategory   = GetCategory(neosType);
            string    typeSafeName   = GetSafeName(neosType);

            if (!(force || NeedsVisual(typeSafeName, typeCategory)))
            {
                return;
            }

            await BuildLogiXUI(targetInstance);

            Canvas logixVisual = VisualSlot.GetComponentInChildren <Canvas>();
            float  aspectRatio = logixVisual.Size.Value.y / logixVisual.Size.Value.x;

            VisualCaptureCamera.OrthographicSize.Value = logixVisual.Size.Value.y / 20.0f;
            Bitmap2D logixImage = await VisualCaptureCamera.RenderToBitmap(new int2(128, (int)(128.0 * aspectRatio)));

            foreach (string path in typeCategory.Paths)
            {
                Directory.CreateDirectory($"{WikiAssetGenerator.BasePath}\\Logix\\{path}\\");
                logixImage.Save($"{WikiAssetGenerator.BasePath}\\Logix\\{path}\\{typeSafeName}Node.png", 100, true);
            }
        }
Exemple #3
0
        private async void CaptureImage()
        {
            Camera componentCamera = Slot.GetComponent <Camera>();

            if (componentCamera != null)
            {
                double aspectRatio     = ((double)lastContent.RectTransform.BoundingRect.height + 5.0) / (double)lastContent.RectTransform.BoundingRect.width;
                Slot   componentVisual = Slot.FindChild(S => S.Name == "Visual");
                componentVisual.LocalPosition          = new float3(0, ((((lastContent.RectTransform.BoundingRect.height / 2.0f) - lastContent.RectTransform.BoundingRect.Center.y) / 2.0f) + 5.0f) * 0.001f, 0.5f);
                componentCamera.OrthographicSize.Value = (lastContent.RectTransform.BoundingRect.height + 5) / 2000.0f;
                Bitmap2D logixTex = await componentCamera.RenderToBitmap(new int2(512, (int)(512.0f * aspectRatio)));

                logixTex.Save($"{BasePath}Data\\CustomCapture{CaptureIndex}.png", 100, true);
            }
        }
        public override async Task GenerateVisual(object typeInstance, Type neosType, bool force = false)
        {
            SyncObject targetInstance = typeInstance as SyncObject;
            string     typeSafeName   = GetSafeName(neosType);

            if (!(force || NeedsVisual(typeSafeName)))
            {
                return;
            }

            Rect bounds = await BuildSyncMemberUI(targetInstance);

            double aspectRatio = (bounds.height + 5.0) / bounds.width;

            VisualSlot.LocalPosition = new float3(0, ((((bounds.height / 2.0f) - bounds.Center.y) / 2.0f) + 5.0f) * 0.1f, 0.5f);
            VisualCaptureCamera.OrthographicSize.Value = (bounds.height + 5) / 20.0f;
            await new ToWorld();
            Bitmap2D componentImage = await VisualCaptureCamera.RenderToBitmap(new int2(400, (int)(400 * aspectRatio)));

            componentImage.Save($"{WikiAssetGenerator.BasePath}\\SyncTypes\\{typeSafeName}SyncType.png", 100, true);
            VisualSlot.DestroyChildren();
        }