Difficulty with Unity UI button movements - c#

I've recently added more buttons to my UI by making them children to an invisible image. They seem to respond and move properly, until multiple buttons are clicked on while they and the Billboard are out. This is a huge problem, since players are going to commonly use them to switch between tabs in the menu. I'm not getting any error codes, so I'm not sure which part of the program is glitching.
The code for these objects are simple bools that turn false after each execution, so I'm not sure why they keep getting stuck in a seemingly true position. I've tried adding "TTabOut = false" after some lines, but deleted them after they failed to make a difference.
Ui in Ui out Glitch

Related

Is there a way to avoid animations being skipping on if the time changes too fast in timeline

I am working on master timeline which can be interact via slider. If the time value changes too fast then animation in nestedtimelines aren't able to finish their animation or return to their initial state. Like, text or images remain on the screen instead of they should disapper if ı rewind the timeline. Is there a way to avoid this.
I have two solution like when the go is disabled putting the inital state values, or make limitation for slider value changing. Second one is not user friendly. First one is not best practice I guess. So, I would like to avoid those options.

Screen has flickering

I have a problem with screen flickering. I read some other topics on this case, but there are solutions that didn't work for me, I think that's because I don't know what exactly causes the problem.
My screen is has a large number of controls, maybe this is what causes the problem. I'll try to describe it as best, as I can.
First of all, I am using WinForms.
I am making a video game, so the screen should be maximized all the time.
To allow stretching all the controls I am using TablePanels, one large that is docked to fill the whole form and a few smaller that also dock fill the large Table cells. In smaller cells of those tables, Buttons are docked fill.
To show the background drawn buttons, I made control buttons completely transparent. It needs to stay that way.
The screen flickers white at positions of TableLayoutPanels borders.
The screen flickers when a mouse enters the position of a Button, any Button, no matter where it is located.
For now, only one element changes actively during gameplay - a Label. When mouse enters the field of button, this label shows what this button does. For example if I enter the area of "Use" button, the label displays the word "USE".
I haven't tried that yet, but I must implement, that some images of button will change or become transparent, or lose transparency during game-play. Like there could be one image for closed cupboard, but when player opens it, another image of open cupboard appears. I think I know how to do it, all I want is to prevent flickering.
If you suggest using some code (and I expect it will be needed), please specify where I should put it.
It seems problem was solved.
I'll answer my question myself, in case someone else needs it.
The problem was caused by one of labels, although I can't guess why.
I am using a number of TableLayoutPanels, one of them fills the whole form. It has a number of rows, each of them is also a TableLayoutPanel, or just a Panel.
Flickering appeared when I tried to put a label inside main TableLayoutPanel by its own, and not in a sub panel. When I put a Panel inside main Table, and label inside it, the majority of flickering was gone.
To remove it completely, I used both recommendations just in case:
1) DoubleBuffering: Here (answer from Fabjan)
2) Article also recommended by Fabian
After that, only a few minor glitches remained. I did a few tests and it seems that the last glitches happened when mouse left the screen, then returned back inside. My game screen is maximized, so it took some time to check. To fix it, I used an easy command:
"Cursor.Clip = this.Bounds;" on FormLoad
I learned it from another question from this site: Here
Unfortunately, I didn't understand, why misplaced label was behind flickering, but since the problem was solved, I decided to write it here, in case someone else needs it.

Buttons randomly shift after minimise/restore on form

I am completely stumped, when I minimise and then restore my main form window some of my form buttons move behind other buttons.
I have not overridden any of the functions that govern this so I am totally confused as to why this would happen.
My components are all anchored and set to "bottom right" yet they magically teleport to the right after a minimise/restore. This is what mean:
I dont end know where to start looking for ways to fix this because a google search didn't turn up anything. Has anyone experienced anything like this? What could it be due to?

SurfaceListBox not responding to touch gestures for several seconds

I have a WPF-program that has a grid with two columns. First one has buttons and second one has WindowsFormsHost-element that embeds an ActiveX component. One button hides the WindowsFormsHost-element and shows a SurfaceListBox on the same location on screen in the second column. If I have touched the WindowsFormsHost element just before pressing this button, it takes approximately 8 seconds from the last touch until the SurfaceListBox becomes responsible for touch gestures.
The thread is probably not blocked, because I can use the buttons in another column, and use use the ListBox with mouse.
The ListBox remains unresponsive for touch events forever, if I touch it within the 8 second waiting time. So it seems that somehow the ListBox does not get the touch events.
If I programmatically create another ListBox, it does not work either, for 8 seconds, if it is placed in same are on screen than the WindowsFormsHost was.
I noticed there is a method CaptureTouch() for UIElement, but I cannot get hold of to the TouchDevice that I could pass it as parameter. I have set ManipulationEnabled="true" for every UIElement and no TouchEvent will be fired.
I have also desperately used UpdateLayout() etc with no luck.
So I think the touch gestures are somehow routed wrong and after the waiting time it implicitly fixes the routing, but is there a way I could make the touch gestures work in the ListBox immediately?
The problem disappeared when I removed "focus tracking for launching on-screen keyboard" from my program.
So in case of somebody else struggles with the same problem,
http://www.infragistics.com/community/blogs/blagunas/archive/2013/12/17/showing-the-windows-8-touch-keyboard-in-wpf.aspx and SurfaceListBoxes aren't meant for each other.

User controls do not properly fit on the screen

My application has several controls. Like in one screen has TreeView on left side, GridView with paging in the middle and 4 buttons at right side. The controls properly appear when the form is in a maximized state, but if I minimize it the controls do not properly fit on the screen.
I tried with different different tricks like table layout.. in dat I added a panel, etc...
But I could not solve the problem.
How can I create such type of screens which fits independently of size of my window?
Thanks
I had the same problem a while ago. In my case i had a Button and a ListView within a GroupBox that was inside a SplitContainer, which was within a UserControl on a TabControl. I wanted the button on the top right located and anchored and the ListView took the space leftover, so i couldn't dock it. Instead it was anchored in all four places.
In my case my button and the listview are worked and behaved correctly in the designer, but in my running app the button was positioned to far on the right and the ListView size had also a too much width.
For a first bugfix i did some iterations about positioning the button in the designer a little more to the left, check it running mode, re-align the button in designer from the impression i had in the last run.
So i got it to work and started over with some other thing i had to do in my app. After a while i got a new feature request and needed another button within this messy thing. This time i did a complete rebuild of the gui elements on a new usercontrol, just to see if the problem reappears. To my amazement this gui mock just behaved as expected.
Within my code i didn't anything about changing the location, size, anchors, docks, etc. So the problem had to be within the InitializeComponents() code created by the designer.
I started with a diff of both versions and couldn't see any big differences (there were a lot of them, but only minors like size, location or name). So i started to put code from my crazy usercontrol into the mock and running the mock in my app. After several copies the problem also appears in my mock, so i got the root cause of the problem.
What do you think, which property leaded to the crazy behaviour?
It was the MinimumSize of my SplitContainer!
So to get really the root cause of your problem you should start over with an empty UserControl (or Form) and just place all the elements on it with the desired behaviour (size, location, anchor, dock).
Nothing more!
Then test if this mock behaves the way you want and if not, post this code here and tell us what you expected to see.

Categories

Resources