playMaker

Author Topic: NGUI Integration (WIP) [NGUI 3.5.9 supported]  (Read 148258 times)

LiveWire

  • Playmaker Newbie
  • *
  • Posts: 7
Re: NGUI Integration (WIP)
« Reply #120 on: June 11, 2013, 09:54:45 PM »
Thanks jeanfabre, I got it working in the example scene following those steps, however I still can't make it work in my custom scene.

The scene is very simple. Basically I have a player inventory, and I want to be able to drag icons from the inventory over objects in the world, the have that trigger some event on the object.

I assume I need the following:
UI Button:
> a drag/drop script of some description, that stores a reference to the icon image that will be dragged (currently a child of the button).

world object:
> an FSM with a NGUI / ON DROP event set to trigger
> an NGuiEventsToPlaymakerFsmEvents component
> a script of some description that identifies the object as a valid drop target

I had tried various combinations of scripts that ship with NGUI but I've been unable to get further than dragging an icon around using UIDragObject.

I have tried attaching a simple script to the world object (based on DragDropSurface) to test if it was receiving OnDrop messages:
Code: [Select]
public class DropSurface : MonoBehaviour
{
    void OnDrop(GameObject dragObject)
    {
        Debug.Log("OnDrop worked!");
    }
}
But nothing happens.

Does the UIDragObject script need to send an OnDrop message somewhere?

I have very little programming knowledge (I'm trying to teach myself while working on this project), so pre-built solutions like NGUI and Playmaker have been great. I just have trouble when I need to delve into the scripts themselves :)

LiveWire

  • Playmaker Newbie
  • *
  • Posts: 7
Re: NGUI Integration (WIP)
« Reply #121 on: June 11, 2013, 11:33:30 PM »
What difference a lunch-break makes. After browsing through some documentation I noticed this line: "You can add the following functions to your scripts placed on widgets or in-game objects with a collider, provided they are drawn with a camera that has the UICamera script attached"

I attached the UICamera script to my main camera (since the gui camera is set to draw only the UI) and now it all works.

However, not I have UICamera on both the gui camera and the main camera. Is this likely to cause issues?

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI Integration (WIP)
« Reply #122 on: June 14, 2013, 02:18:20 AM »
Hi,

 not sure, hopefully someone can step in to comment on this.

bye,

 Jean

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI Integration (WIP)
« Reply #123 on: June 17, 2013, 01:18:54 AM »
can we get MOUSE EXIT function?

Hi,

Just to  comment on this: MOUSE EXIT is actually dealt with ON HOVER, it has a boolean flag which tells if hover enters or exit, that's how you do it in NGUI.

http://www.tasharen.com/?page_id=160

bye,

 Jean

Loganou974

  • Playmaker Newbie
  • *
  • Posts: 18
Re: NGUI Integration (WIP)
« Reply #124 on: June 25, 2013, 05:19:49 AM »
Hi !

I'm new in Playmaker and nGUI and i've got a simple problem that i cannot get rid of...

How do i make my nGUI elements appear and disappear with a Playmaker action ? (like when a main menu disappear, to make appear a level menu)

I've tried to Set the "Enable" Property of the GUI Component, it hides it, but the player can click on it as it was shown...

I've tried to Set the "Active" Property of the GameObject, but once it was unactived, no way to turn it back to "active", even with another GO setting the property...

I know it may be a stupid question but i really can't find a way :/
« Last Edit: June 25, 2013, 05:27:11 AM by Loganou974 »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: NGUI Integration (WIP)
« Reply #125 on: June 25, 2013, 06:11:26 AM »
Hi,

 I think you need to hide the panel, you will get better results, as the button component is only the visual thing, the collider remains active. So either deactivate the whole gameObject, or it's parent panel.

bye,

 Jean

Loganou974

  • Playmaker Newbie
  • *
  • Posts: 18
Re: NGUI Integration (WIP)
« Reply #126 on: June 25, 2013, 09:14:12 AM »
Okay Thanks for the quick reply ;)

oOoANDOSoOo

  • Playmaker Newbie
  • *
  • Posts: 13
Re: NGUI Integration (WIP)
« Reply #127 on: June 28, 2013, 05:13:00 PM »
Hi, great Addon but I have a few problems.

On a new project using the latest version of Unity, I get three warnings;
---
Assets/PlayMaker NGUI/Editor/NGuiEventsToPlaymakerFsmEventsInspector.cs(31,92): warning CS0618: `UnityEditor.EditorGUILayout.ObjectField(string, UnityEngine.Object, System.Type, params UnityEngine.GUILayoutOption[])' is obsolete: `Check the docs for the usage of the new parameter 'allowSceneObjects'.'

---
Assets/PlayMaker NGUI/Editor/NGuiEventsToPlaymakerFsmEventsInspector.cs(40,75): warning CS0618: `UnityEditor.EditorGUILayout.ObjectField(string, UnityEngine.Object, System.Type, params UnityEngine.GUILayoutOption[])' is obsolete: `Check the docs for the usage of the new parameter 'allowSceneObjects'.'
---
Assets/PlayMaker NGUI/Editor/NGuiEventsToPlaymakerFsmEventsInspector.cs(50,75): warning CS0618: `UnityEditor.EditorGUILayout.ObjectField(string, UnityEngine.Object, System.Type, params UnityEngine.GUILayoutOption[])' is obsolete: `Check the docs for the usage of the new parameter 'allowSceneObjects'.'
---

Also, because I am not using Photon, if I remove the PUN folder after importing Playmaker I get the following error:

Assets/PlayMaker NGUI/Editor/NGuiEventsToPlaymakerFsmEventsInspector.cs(103,50): error CS0103: The name `PlayMakerPhotonEditorUtility' does not exist in the current context

---

Obviously I can just comment this line out but I am just making sure that doing so will not break anything within the scripts and gameObject that is in this new version of the Playmaker-NGUI addon.

 :)

Many thanks,
-Andos.


-----
EDIT:
How strange.. after I closed Unity and came back to it the warnings have gone.

EDIT:
Nope, scrap that - it still shows the warnings. Will this be updated soon so that these warnings will vanish?
« Last Edit: July 06, 2013, 10:28:23 AM by oOoANDOSoOo »

oOoANDOSoOo

  • Playmaker Newbie
  • *
  • Posts: 13
Re: NGUI Integration (WIP)
« Reply #128 on: July 09, 2013, 04:58:19 PM »
Hey all,
Ok i asked this in the Help section but I guess it is more tailored to NGUI so I'll try here.

Is their anyway, other then using get/set properties, to change the 'Color Tint' of a sprite/texture in a button (say you wanted it to be gray if not allowed to click but if for some reason you are allowed to click it, it is white)?

I have tried using SendMessage but not sure what to send, i have tried set_color but what ever I put in 'Texture' (which of course I am trying to put a color) just gets reset to none or default color of white when I return back if i've run the project to test it.

Any ideas ;-)

UPDATE:
I decided to go down a different route, I just added another sprite/texture to the button and deactivated it. Then in my FSM, when I needed to, I (de)activated the relevent sprites.

Cheers all,
-Andos
« Last Edit: July 09, 2013, 07:01:20 PM by oOoANDOSoOo »

Satrio

  • Junior Playmaker
  • **
  • Posts: 67
Re: NGUI Integration (WIP)
« Reply #129 on: July 10, 2013, 06:48:45 AM »
I use a "set property" action to do this. But remember you have to "drag" the NGUI item to the object slot, not the whole gameobject. Then you select "color" in the dropdown menu.

Hope this makes sense to you, as I am not able to reference the correct Unity terms for this, as I am on a mobile device.

vidi

  • Playmaker Newbie
  • *
  • Posts: 21
Re: NGUI Integration (WIP)
« Reply #130 on: July 10, 2013, 07:11:46 AM »
I get a error message if I start the NGUI Playmaker Example

I don't know what is my mistake

Edit:

Ok my fault. I have re download Playmaker and now it works  :)
« Last Edit: July 10, 2013, 08:03:12 AM by vidi »

Red

  • Hero Member
  • *****
  • Posts: 563
Re: NGUI Integration (WIP)
« Reply #131 on: July 16, 2013, 10:00:49 PM »
Hmm, late night brain bubbling here on the whole on hover to boolean thing... I was wondering... if this system is able to affect the events system, would it be possible that it can also read via actions?

it kinda hit me as i was mulling over this in that if there was an action that had a "get NGUI state" where you can either manually enter the name of the state in NGUI that you're looking for and you feed it a boolean to feed it to (with a toggle for every frame or only once) that could open up the flexibiltiy really fast.

Dunno... since i'm not a programmer i have no idea if this is possible and if so how hard it'd be (or maybe it'd be easy? dunno.) so, just a thought is all.

NotoriousGIB

  • Playmaker Newbie
  • *
  • Posts: 4
    • Mann Made Games, LLC
Re: NGUI Integration (WIP)
« Reply #132 on: July 27, 2013, 01:17:48 PM »
On a new project using the latest version of Unity, I get three warnings;
---
Assets/PlayMaker NGUI/Editor/NGuiEventsToPlaymakerFsmEventsInspector.cs(31,92): warning CS0618: `UnityEditor.EditorGUILayout.ObjectField(string, UnityEngine.Object, System.Type, params UnityEngine.GUILayoutOption[])' is obsolete: `Check the docs for the usage of the new parameter 'allowSceneObjects'.'

Right before the last parenthesis on each line add the following:
"false,null".

Line 31 should look like this:
PlayMakerFSM _newTargetFSM = (PlayMakerFSM)EditorGUILayout.ObjectField("The Target defaults to",_targetFsm,typeof(PlayMakerFSM),false,null);

oOoANDOSoOo

  • Playmaker Newbie
  • *
  • Posts: 13
Re: NGUI Integration (WIP)
« Reply #133 on: July 28, 2013, 09:24:36 PM »
On a new project using the latest version of Unity, I get three warnings;
---
Assets/PlayMaker NGUI/Editor/NGuiEventsToPlaymakerFsmEventsInspector.cs(31,92): warning CS0618: `UnityEditor.EditorGUILayout.ObjectField(string, UnityEngine.Object, System.Type, params UnityEngine.GUILayoutOption[])' is obsolete: `Check the docs for the usage of the new parameter 'allowSceneObjects'.'

Right before the last parenthesis on each line add the following:
"false,null".

Line 31 should look like this:
PlayMakerFSM _newTargetFSM = (PlayMakerFSM)EditorGUILayout.ObjectField("The Target defaults to",_targetFsm,typeof(PlayMakerFSM),false,null);

Many thanks, this worked.

-Andos

oOoANDOSoOo

  • Playmaker Newbie
  • *
  • Posts: 13
Re: NGUI Integration (WIP)
« Reply #134 on: July 28, 2013, 09:33:29 PM »
Humm... so now I am getting error:

Code: [Select]
Assets/PlayMaker NGUI/Widgets/UIJoystick.cs(133,45): error CS1061: Type `UnityEngine.Vector3' does not contain a definition for `AlmostEquals' and no extension method `AlmostEquals' of type `UnityEngine.Vector3' could be found (are you missing a using directive or an assembly reference?)
after just reimporting PlayMaker NGUI (i just re downloaded it too)

cheers,
-andos