0
Answered

GameObject

James 2 years ago updated by Lazlo Bonin (Lead Developer) 2 years ago 5

I have a script running on a prefab and when a certain condition is met (OnMouseUp) I would like to set the text for a TextMesh on another object.  This works fine when I use GameObject Literal node, but fails when I use: GameObject.gameObject(get).  In both cases I am supplying the correct TextMesh object, but in the later case, the GameObject.gameObject(get) returns self and I get the error (not surprisingly) "There is no 'TextMesh' attached to the game object, but a script is trying to access it."

Is this expected behavior?  

Bolt Version:
Unity Version:
Platform(s):
Scripting Backend:
.NET Version (API Compatibility Level):
GOOD, I'M SATISFIED
Satisfaction mark by James 2 years ago
Pending Review

Hi James,

What exactly do you mean by .gameObject(get)? Can you send me a screenshot?

Also, could it be related to this issue? If so, it is fixed for v.1.0.1, which should hit the store early this week.

http://support.ludiq.io/topics/243-trying-to-create-a-simple-camera-follow-script/#comment-376

+1


Here is a screen shot.  I am just running some tests to see if I can incorporate Bolt into my pipeline (mainly to get the artists more engaged).  This is attached to a prefab cube with a rigidbody to test input interactions.  The "textLabel" object is a simple TextMesh with no script logic or graph attached.  It is not attached to "Cube"

You can see in the diagram I am trying a few ways of accessing the "textLabel" object.  The first two work fine, the third does not.  In all three cases, I selected the "textLabel" object through the selection dialog provided when clicking the circle next to the field.  

The second node is the suggestion then pulling backward from the TextMesh node, but I would have expected all three to work.  Let me know if you need any more detail.  Thanks for the quick response.

Forgot to add, it does appear to be related to issue 376.  It seems as though the inline field for GameObject is being overridden by self.  Based on the error message and "watch" value on the green wire.

Answered

Thanks for taking the time to send a screenshot and detail the issue.

It is indeed the same issue as 376. Inline port fields for game objects get overridden by self. I'll be pushing the fix to the asset store early tomorrow morning.

I also take note of the bad dark-on-dark text for colored nodes in the dark skin. I'll try to have that fixed in the same update. I don't have a Unity Pro license at the moment so I haven't been able to see all these issues, but if ever you see more don't hesitate to report them.

Edit: as a side note, I just want to point out that you should never actually have to use the "Get Game Object" unit, because Bolt will automatically convert any component to its parent game object under the hood if need be.