I have two scroll rects overlapping in unity I have done this so I can have image and text next to each other that change sides for every time they are made, is there a way I can have them both scroll at the same time and point as currently they only scroll individually
I used two overlapping scroll rects and expected them to both work at the same time
No, I don't believe that's a valid use case for the built-in ScrollView. You'll need to write your own implementation instead that can handle your use case.
Related
I'm using unity 5.3 and I'm trying to change the Rendering Order of two overlayed cross platform controls which each reside in their own canvas.
In previous versions you could bring the window into focus using
GUI.FocusWindow(0);
However this does not work with the new system.
I've also tried modifying the order in the editor window which has done nothing.
Does anyone know how I can move a control to be on top of the other?
After doing some research I found the proper way to change the Canvas Rendering Order. There is a property in the Canvas for the Sort Order, which is really the render order.
.
Just as a note remember the controls you want to be on top should have a larger order than the control on bottom.
Order in the editor window should work here. Are you sure you're changing the order of elements inside one canvas element?
Note that the order of elements in the Canvas game object is the order everything is rendered in - so the last thing you have in canvas will be the last thing drawn, so it will be on top of everything.
Here's how it works:
This is demonstrated with Unity 5.3.4, with much older Unity it can be different (there was a change of the way how children were enumerated somewhere in 5.0 or 5.1 AFAIK).
I want to make a 2D scatter plot with following requirements;
The "dots" should not be dots but instead arrows pointing either upwards or downwards depending on the data it represents.
It should be possible to specify what values to show on the axis.
The user should be able to zoom and pan on the graph.
I want to be able to specify what color each arrow should have.
The arrows should be clickable (i.e. I need some way to register a click event and decide which arrow was clicked).
I have tried to accomplish this using ZedGraph but I find it hard to get how I want, especially with the first requirement.
Is there a free charting library that would allow me to do this relatively easy in WinForms? Or, any general tips on how to accomplish the first requirement using ZedGraph?
In the Zedgraph samples there is an example of adding text labels to the data points using TextObjects. You can find this demo sample here.
Based on this example, you should be able to create the up and down arrows in required positions, using ArrowObjects instead of TextObjects.
I have now learned that all requirements can be accomplished using ZedGraph.
The "dots" should not be dots but instead arrows pointing either upwards or downwards depending on the data it represents.
The cleanest solution is to use LineItem and do custom symbol type just like in this post Customize symbol type of a ZedGraph LineItem .
It should be possible to specify what values to show on the axis.
An easy solution to this is to use TextLabels and manually place them where you want them.
The user should be able to zoom and pan on the graph.
Functionality built into ZedGraph.
I want to be able to specify what color each arrow should have.
One can create multiple LineItems for each color, this requires that the line itself is not visible though.
The arrows should be clickable (i.e. I need some way to register a click event and decide which arrow was clicked).
Easily made using the Click event and FindNearestPoint method.
I have two inkCanvas elements in WPF displayed side by side. I want to be able to draw lines seamlessly from one inkCanvas to the next. Right now the stroke gets clipped at the boundary and you have to release the mouse and press it again on the next canvas to continue the line.
I also read that inkCanvas wasn't really the way to go for drawing. It was more for simple things like signatures. What are you supposed to use instead?
First try with one inkcancas:
add tiles by replacing the current inkcanvas with a bigger one and copying the strokes
it might work
if it doesn't you will know what you need more
Yes inkcanvas is for simple things but before you start coding a lot try to specify what you need.
I am using NPlot charting library to draw several plots illustrating signal fluctuations. The plots are inserted one beneath the other in a flowlayoutpanel1.
The x axis is the time. The y is the value of the signal.
I've added a trackbar at the bottom, along the x axis. When the user moves the trackbar, the value of each signal is displayed somewhere (in relation to the trackbar's position).
All of this is already functional.
I've been asked to add some visual way to illustrate the precise time where the trackbar is. They want some sort of vertical line that would move with the trackbar, over all the Nplots. However they are open to alternatives.
I have tried drawing the line but it's difficult to draw in relation to the trackbar's position. Also it ends up being drawn BEHIND the Nplots.
I've also tried drawing a static grid on the flowpanel but the Nplots are not transparent, and my boss doesn't like each plot having a individual grid for aesthetic purposes.
At this point i'm open to any "out-of-the-box" suggestions, or corrections on my implementation. I'm self taught in C# so i haven't done anything like this before.
Please help!
EDIT: I have gotten something slightly better by using a label with a border, stretching it to be tall and having width of 1. This creates a Line that goes over all other control. Now my biggest challenge is calculating the position of the trackbar pointer to make the line match it...
After a lot of fiddling, i found that the only way to have a line drawn over all other controls was NOT to use the Graphics drawline, as the controls placed on top were not transparent and i could not access their graphics component (was a imported control not a .NET class).
I ended up going with the EDIT solution, took a label with a border and put the width to 1, creating a simple line instead of a box.
The position formula took a lot of fine tuning, the way to go was to calculate (estimate) the width between two trackbar ticks an add a tiny offset for the control itself. Using the traback's pointer Value property, i could calculate the position of the label/line so that it would follow the trackbar pointer. There is a minuscule offset sometimes formed but not well seen to the naked eye.
I've searched around for an alternative way of drawing selection indicators for visual objects (like selected edges, lines etc.) without the use of ControlPaint.DrawReversibleFrame and related XOR methods. The reasons are unwanted XOR-ing "artifacts", reversibility not applying to bitmaps, no control of the actual visual look and slowness.
On the other hand I want to avoid having to repaint the whole scene (map actually) if a user decides he wants to deselect an object or two, because the repaint could be quite expensive.
So the only alternative I can see is implementing some basic drawing logic directly on a Bitmap, but with storing the previous contents of the pixels before they change. Then (in theory) I would be able to reapply old contents of, say, an selected edge rectangle if the user chooses to deselect that edge.
My question is whether you think this is a good idea or do you see some other alternatives to my problem (within the GDI+)?
Thanks in advance
If the selection indicator is just drawn on the top of the unselected object, you can use two bitmaps, draw all the unselected objects on the background one and the selection indicators on the other, and paint them both on screen.
Else, you can do the same, except that you render the selected objects instead of just indicators.
Only store the rectangles "of interest" in an off screen buffer. And repaint when the focus is lost. . . Or if you can redraw just the portion as it appears normally based on in memory data you should be fine. Otherwise it seems that you have the gist of it.