-
Notifications
You must be signed in to change notification settings - Fork 418
Node Editor in Android #55
Comments
The next two fields are the To summarize, you can just call: NodeEditorMenuCallback cb = new NodeEditorMenuCallback("allaroundNode", NodeEditor.curNodeCanvas, NodeEditor.curEditorState);
cb.contextClickPos = new Vector2(200, 200);
NodeEditor.ContextCallback(cb); |
Sorry I missed this issue for some reason. |
I tested on my phone and the context menu only shows when touching with two fingers, but you can't select an option. |
Hm, I thought the touch behaves the same on every device. Maybe it's a difference because my tablet has windows 8 not android. I'd first try to emit a right click event on android when the click lasts for more than 0.5 secs or so if that is possible, it wouldn'T require you to rewrite the wholecode much. This would be done in the Update function I guess... |
Hello pmhpereira and Seneral ! Thank you for the advise! I have used "#If UNITY_ANDROID" inside the InputEvents() with touch phase function, the menu will pop after pressing for over 1 second, please see below. However, I am thinking if in mobile application, the contextMenu should still exist after moving out your finger unless further touching by the user `#if UNITY_ANDROID
#endif |
I'm not sure if @Seneral ever thought of supporting this plugin in mobile devices (he said it works for Windows tablet, but possibly because it automatically emulates finger touches as mouse clicks, like a native Windows computer). If he/we were to support this, I think the best approach would be to have a separate class managing the input state (one implementation for computers and one for mobile devices) and have the remaining code querying it. @Seneral, your thoughts? |
I did not actively wanted to support this but if @zardchim needs this, we can resolve this together. So, it seems only context clicks are not supported so far. I can take a look at how I can emulate it. |
@Seneral Thank you very much for the help! Currently I am looking at a simpler way to connect node together on smartphone (e.g. by simply touching on the connection knobs consequently, a line will be automatically formed in between). I really appreciate if you can help me, but please also advise direction / functions to me so I can work on together :) ! |
@zardchim, you should start by checking #37. It's currently being implemented and it is a functionality that will allow Node_Editor to call methods from any gameobject in the scene. Building logical nodes is somewhat easier and you can start doing it yourself. It's just a matter of creating a new BoolType (currently there is a FloatType only) and implement the nodes you need (just check the default ones), which compare two inputs and output the result of the logical operation. |
I've no experience with an Arduino board or similar, but there's some things to consider regarding the conditional operations. Before going any further though, do you have the Arduino API accessable from withing Unity? Then it'll be a first step to expose it to the user through nodes, atleast for the most common ones. It's not adviseable to always rely on the action node as it has alot of overhead compared to a normal node (when it's even implemented). |
@Seneral Thank you very much for the advise! For the Arduino API, I used a simple serial interface to communicate and control. The computer will receive information from the arduino regularly, and can control the Arduino by sending serial message in the form of text "A", "B", "C". I will wrap the communication as a function, so the logical programming flow should be like: I have a input node, that can get value by calling a function. I believe most of the features are being implemented, however in Android, I find the popup menu like "UnityEditor.EditorGUILayout.EnumPopup" in CalcNode cannot be displayed, do you have suggestion on this? I also tried to popup a menu when pressing a button in the sideGUI() of RuntimeNodeEditor, but it shares the same problem .... >.< |
@zardchim, you can see which custom UI elements are available in RTEditorGUI.cs. As of now, all the The problem with displaying the native ones at runtime is that you need to |
Ok, so this could be done connections which will be blocked, that will be the most convenient and cleanest solution. I'll try to get to that feature tomorrow, if you can't wait it should be hard to implement (add a variable/function fo the blocking state to NodeOutput and let the calculation system (in NodeEditor.cs) handle that) :) |
@pmhpereira @Seneral Thank you very much for the advise :) I see, so UnityEditor.EditorGUILayout cannot be used in android while GUILayout can. |
Any news on this? Did you implemented an alternative solution? ;) |
@Seneral However, the interface is not user-friendly on Android ... I need to press stationary on screen to popup the AddMenu and select which node to add. Besides I am thinking alternative way to replace PopUp element. I am struggling on the scale of gui on different screen, for now different nodes are generated like node.rect = new Rect(pos.x, pos.y, 100, 50), I have replaced some of them to node.rect = new Rect(pos.x, pos.y, (Screen.width*4/5)/5, Screen.height/7) in order to perform adaptive sizing, however is there a clever way to do so? |
Than you'll be delightful to hear that I'm reworking the Input system. This will primarily seperates every control from each other and removes the mess the input function is atm, but this will also help to reassign, change and add new hotkeys and controls:) Regarding screen dpi, it might work to use the zooming system. It works in a way that allows to manually modify the zoom and it persists (zooming only adds/substracts from the zoom factor). So you could set the zoom value apropriately on small screens depending on the Screen.dpi (or similar). Tell me if that works! :) |
Sometimes when I connected blocks, an error "GUI Error: You are pushing more GUIClips than you are popping. Make sure they are balanced)" appeared. I discovered the problem arise when I try to connect 2 knobs, after I clicked one knob and pull to somewhere else, if the MouseUp position is inside a Node, the bug appear. It may be possible related to the code below, and the error is "NullReferenceException: Object reference not set to an instance of an object ` case EventType.MouseUp:
|
I also experienced this sometimes but never was able to reproduce it. I restructured this section a bit though and since did not experierenced that problem again, so I think that fixed it:) |
I have git cloned a clear copy from the github and test again, and am able to reproduce the problem. The procedure is : left click a knob and pull a wire from it, if the cursor position is inside a node when you mouseUp, the error appear. |
Ah ok, reproduced that too. I already fixed that though (because I though what the heck did I do there lol), and due to some other changes I cannot directly map that fix to the current version. The following should do it though: if (curEditorState.focusedNode != null && curEditorState.connectOutput != null)
{ // Apply Drawn connections on node if theres a clicked input
NodeInput clickedInput = curEditorState.focusedNode.GetInputAtPos(e.mousePosition);
if (clickedInput != null && clickedInput.CanApplyConnection(curEditorState.connectOutput))
{ // It can connect (type is equals, it does not cause recursion, ...)
clickedInput.ApplyConnection(curEditorState.connectOutput);
}
e.Use ();
} Won't be able to respond for the next hours though:( Hope that does it for you;) |
It looks really awesome !!!!!!!!!! |
Here it is 8baf1fd! Enjoy! ;) |
@zardchim Hey, any news? I'm very interested if you managed to adapt the controls to touch:) |
Hi everyone :)
I am trying to build a Android application with Node Editor features to perform basic logical application (e.g. if / else)
However since Smartphone only allows pressing operation, I am trying to figure out how to add node (e.g. AllRoundNode) by pressing a button on SideGui() as demonstrated in RunTimeNodeEditor.
Could anyone please guide me a way to achieve such operation? I am a bit lost after reading the "ContextCallback" function ....
The text was updated successfully, but these errors were encountered: