Jump to content
  • 0
raj441977

Any Idea how to create or add UI controls in Second Life ?

Question

I searched a lot, was trying to create HUD with drag-able UI controls to adjust color, glossiness, environment etc (other creators are already using).

is there any clue ?

0.JPG

Share this post


Link to post
Share on other sites

6 answers to this question

Recommended Posts

  • 1
1 hour ago, Wulfie Reanimator said:

This is done with scripts.

Generally speaking, the script would use the touch_start event to figure out which part of the user is trying to interact with and the touch event to figure out where the user is dragging.

In addition to this, look into llDetectedTouchUV(), which is what I have used in the past to create color pickers, sliders, and other draggable controls (like a dimmer for a light source).
The example scripts on that wiki page are pretty good as a starting point, especially the second one looks like it could make a nice basis for you, although you should change the touch_start event to a simple touch event, and whilst you're at it, use llSetText instead of llSay so as to cut down on chat spam. ūüôā¬†

  • Like 3

Share this post


Link to post
Share on other sites
  • 1

Okay, I'm back for a moment with a little more info, now that I have re-read the original post, which I now understand is not about the scripting, but about HOW TO BUILD it...

You will need two layers. I call them the touch layer, and the background layer.

  • The background layer will have -¬†for example -¬†the texture of the color gradient.
  • The touch layer has the draggable UI controls, which¬†are drawn on a transparent background. This texture is then placed on a prim which I¬†call the touch layer.
  • The touch layer is then placed on top of the background layer so that it matches up with the background layer.
  • Using llDetectedTouchUV() you detect where the prim was touched, this returns a vector between <0,0,0> and <1,1,0>.
  • Use this vector to adjust the offset of the texture on the touch layer. This effectively makes it look like the UI item follows the mouse.

I hope this helps. I can't go in world at the moment, so I can't whip you up some example code, so I hope this will get you on your way. Note that it may be a good idea to have your script retrieve the link number of the touch layer, so you can do if(llDetectedLinkNumber(0) != touch_layer) return; so as to prevent other links to respond to that touch.

  • Like 1
  • Confused 1

Share this post


Link to post
Share on other sites
  • 0

This is done with scripts.

Generally speaking, the script would use the touch_start event to figure out which part of the user is trying to interact with and the touch event to figure out where the user is dragging.

The specific details about the code are very dependent on how the HUD was built. If you don't know how to write LSL scripts, you should post in the Wanted or Inworld Employment sections.

  • Like 2

Share this post


Link to post
Share on other sites
  • 0

adding to what Fritigern says about using textured layers. When we add a 3rd layer then we can make 3D control buttons. Popped up when the button is not pressed, Popped down when it is

on touch_start.  Bring the 3rd layer (our popped down layer) to the front

on touch_end.  Bring the 2nd layer (our popped up layer) to the front

  • Like 1

Share this post


Link to post
Share on other sites
  • 0

Sorry, I was not able to focus on my needs, actually I am not asking for LSL scripting or the touch detection matters or color generating, My need is the UI "Drag-able Slider", not the the code of it's interactions..... I tried lots, searched lots, but not able to build the drag-able content in SL (Just like Range Slider in HTML)

Share this post


Link to post
Share on other sites
  • 0
On 1/13/2020 at 3:09 AM, Fritigern Gothly said:

Okay, I'm back for a moment with a little more info, now that I have re-read the original post, which I now understand is not about the scripting, but about HOW TO BUILD it...

You will need two layers. I call them the touch layer, and the background layer.

  • The background layer will have -¬†for example -¬†the texture of the color gradient.
  • The touch layer has the draggable UI controls, which¬†are drawn on a transparent background. This texture is then placed on a prim which I¬†call the touch layer.
  • The touch layer is then placed on top of the background layer so that it matches up with the background layer.
  • Using llDetectedTouchUV() you detect where the prim was touched, this returns a vector between <0,0,0> and <1,1,0>.
  • Use this vector to adjust the offset of the texture on the touch layer. This effectively makes it look like the UI item follows the mouse.

I hope this helps. I can't go in world at the moment, so I can't whip you up some example code, so I hope this will get you on your way. Note that it may be a good idea to have your script retrieve the link number of the touch layer, so you can do if(llDetectedLinkNumber(0) != touch_layer) return; so as to prevent other links to respond to that touch.

ah, I got that, thanks...... I think I got the answer, probably this is what I wanted for... thank you very much

  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...