I am using the new unity networking using unity 5.3.1 , my player prefab is a UI canvas , so when another client joins the canvas's overlap and I cannot press any button on host or client .
What i want is to disable other canvase's on each players game and just leave the local players canvase active , I have tried islocalplayer , isclient ,isserver but nothing works .
Is there a way around this please do tell.
Here are some options I can think of:
1) Instead of making canvas a player object, make panel a player object, so that all your players are different panels under same canvas. Now, when object are under same canvas, they ray casting order is determined by the order in hierarchy.
The objects that are lower in the hierarchy occlude those that are higher. So, what you can do is moving your player object to the lowest position in objects hierarchy, so that it will occlude all other players. This can be done using Transform methods SetSiblingIndex and GetSiblingIndex, like
transform.SetSiblingIndex(100000/*some big number*/);
2) Disable raycasting on all other players - what if you can click some component on canvas or not is whether it is a raycast target. Images and Text components can be raycast targets, or more generally any component that inherits from Graphics. You can iterate over all components of type Graphics in all players except the local player and mark raycastTarget = false.
I figured it out and as #NikaKasradze said use only one canvas and put all gui listeners in the islocalplayer bool check .
Related
Is it possible to receive a mouse click even in a Qt application, evaluate it, and if necessary, let it fall through to whatever might happen to be below the Qt application window?
Note that Qt::WA_TransparentForMouseEvents doesn't facilitate evaluating the click before passing it through.
And since the click evaluation incorporates some dynamic logic, it is not applicable to set a static mask either, on top of this having a visual impact as well.
Ideally, I would like a way to selectively allow the mouse click to pass through the application window in a platform portable way, ideally from QML and without bringing in the widgets module, or at the very least, without involving digging into private C++ internal APIs.
Qt::WA_TransparentForMouseEvents is used to filter mouse events out. The name is a bit of a misnomer: it allows widgets that would otherwise consume mouse events, not to consume them. E.g. you could make a button not notice any mouse events. If you're writing a custom widget, there's never any need for this attribute, since it's up to you to inspect the mouse events and simply not handle them: they are automatically passed to the parent widget.
But all of this doesn't matter much, since the WA_ attributes are for widgets, and do nothing for windows. You want something else entirely: to make the window itself transparent for input. Thus, in QML:
window.flags = window.flags | Qt.WindowTransparentForInput
use QWidget.setMask to set the repsonsible area of window:
def resizeEvent(self, event):
geo = self.frameGeometry()
path = QtGui.QPainterPath()
path.addEllipse(0, 0, 300, 200)
poly = path.toFillPolygon().toPolygon()
reg = QtGui.QRegion(poly)
print('resize event', geo, poly)
self.setMask(reg)
I am developing a JavaFX application where a class I have developed (extended from javafx.scene.Parent) is created on-the-fly based on what entry the user has clicked in a ListView control.
Just to be clear about this node, it is not created using a layout tool like SceneBuilder, it is created at runtime based on the user's actions.
The constructor for my custom node class creates a VBox and a Label and uses passed coordinates (X,Y) in the constructor method to set its own Layout coords. I then use a custom utility class to make the node draggable. This new node is then added to the main application Pane.
However, I have failed to find out how I can make these nodes resizable by the user. That is, allow the user to mouse over the corner of the node, hold and drag to resize. An operation that all users are used to, no matter what the OS.
Has anyone done anything like this in JavaFX? (My searches on the subject only seem to pull up subjects on the automatic resizing that a parent node does with its child nodes.)
Many thanks,
Ian.
As you can see on the documentation of VBox you can only define minimum, prefered and maximum range, there's not really a way to make it manually resizable.
The only proper solution to solve your problem is to develop your own class to do it, because what you want seems very specific, with your problem description, I don't think use some layouts or panels will do what you exactly want.
I found something that you can use : Dragging to resize a JavaFX Region
This allows you to resize a region, all you have to do after is to put you VBox in this region, but notice in this article that :
Only height resizing is currently implemented.
This code won't work in JavaFX8, you'll have to check the comment to see how it worls in JavaFX8
Hope this helps.
I've read about using a JDialog to wrap a JFXPanel in order to use JDialog's alwaysOnTop method. It works, but I'm having a small issue with this hack.
Since I'm using this technique to make secondary windows to my main application (popups etc), I need to set them on top of the main window. If I use the wrapper hack to do this, the top panel is "always on top" of everything (including other applications).
Is there a way to put the secondary screen only on top of my application? I don't like the fact that another application can be dragged in between the main window and secondary window of my application.
I suggest not using JDialog and JFXPanel, but only using JavaFX Stages.
Make your secondary screen a Stage and invoke secondaryStage.initOwner(primaryStage) before you show the secondary stage.
From the Stage documentation:
A stage can optionally have an owner Window. When a window is a stage's owner, it is said to be the parent of that stage . . . A stage will always be on top of its parent window.
I believe setting the owner of the secondary stage, correctly fulfills your requirement of "secondary screen only on top of my application".
Update: answers to additional questions from comments
I don't want there to be any interaction with the main stage once the secondary is open (the secondary window must be closed to allow interaction again).
To block input to the primary stage, Before showing the secondary stage, call: secondaryStage.initModality(Modality.WINDOW_MODAL).
You could use APPLICATION_MODAL instead of WINDOW_MODAL if you preferred to block all input to any other of your application windows - which one to use depends on the user experience you want.
There's nothing obvious in the api that would center the secondary screen on the main screen. It just always centers on the monitor, no matter where the main screen is.
This part of the question is a duplicate of Center location of stage. The answer to the duplicate has sample code for performing the centering of the child window.
That's right, there is nothing in the public api around positioning child windows relative to parent windows. I've filed a feature request for this functionality Add helper methods for positioning popups relative to nodes, but the feature request has not yet been implemented as of JavaFX 2.2.
There is a sample project I created to do relative positioning of child dialogs, which might be useful.
Just for centering within the parent, you are probably best off querying the stage location and width before displaying the child and then setting the x and y co-ordinates of the child appropriately when you display it. All of this can be done based on x, y and width properties of windows.
There is also a dialog project in the JavaFX UI controls sandbox which might provides some of the functionality you require so that you don't need to code it yourself.
In time all of the functionality you are requesting will probably end up in the JavaFX core platform, but I don't think it's all quite there yet for JavaFX 2.2.
I agree with jewelsea, but if you need to use JDialog and JavaFX stages (like it was my case), then you can't set your primaryStage's parent or modality.
The only solution i found is to use a little "hack":
I use JNA, Java Native Access API to do my own setAlwaysOnTop() method using User32.INSTANCE.setWindowPos(...) with HWND_TOPMOST parameter.
edit: see microsoft doc
and jna doc
I have a DAE model that is parsed into several parts. I am able to deal with them separately, such as changing their material or colour but I am having problems adding click or hover listeners over the children.
For example, lets say I have a model of a kitty where each facial feature is a child. I want to be able to hover or click the features and have a window pop up explaining the feature.
I've tried parsing the model and adding listeners but it doesn't seem to work.
Thanks in advance!
L
Hard to pin point the problem from your description, but you could check the following:
Make sure your viewport is interactive
Make sure the material your material is interactive
Make sure the DisplayObject3D you assign the listener to is not null.
Point 3, with collada objects, you can have nested objects, make sure you add a listener to an object that has geometry, not an empty(no geometry) container. With points 1,2, both viewport and material have a Boolean property called interactive which must be set to true for mouse events.
HTH
Hy!
I'm building a top view 2D map, that it's objects are stored on the server.
The kind of objects are 10 and might be a photo, label, button, lists, mix of them or labels with tooltips.
The component must request the "areas" that are missing on screen.
An area is 1000x1000 px and is cached in flex.
To move in the map, will be like in google maps (drag-and-drop)
I should be able to have another list and move objects from one to another using drag-an-drop on objects. Ex.: I grab an objects from a list and I move it on this map, I release the mouse button and the item is placed there.
Now the problem is: I build a custom component for this trying to emulate the item renderer for performance and recyclage, implement drag-and-drop on objects and request the areas that are missing?
or
I extend the List component from spark and I add some features as multiple kind of itemrenderers and use recycle on them. Of course it must be able to request the missing areas on the screen and cache it's data.
Maybe create a custom layout is needed too.
What I need is something that must be really fluid, so the lighter this component is, the better!
Thanks for your help! (:
UPDATE:
*There will be not any object over another.
*I will not use hitTest on bitmaps because all bitmaps are wrapped in another component,as they,for now are itemrenderers.
Anyway I already begin to do this using a class that extends the SkinnableDataContainer and a custom layout. As the layout is not like a grid, is sparse, random items at diferent points(x, y).
Now I have this problem: https://stackoverflow.com/questions/4192934/how-to-get-the-localx-and-localy-relative-to-item-renderer-and-not-to-the-spark
Maybe you could use a combination of some of the following:
A canvas background (for layered components), looks fluid if using hitTest. Split up the canvas using constraintColumn/constraintRow for a grid layout.
Use hitTest (on items bitmapdata) for collision detection, and move the items to a new position (if items are dropped on top of one another).
Use a combo of mouseDown, mouseMove, mouseUP (example here) for drag n drop.
Use a 2D/3D indexed array to track the position of items (example here)