Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

UI Script that Communicates with Another Script

Discussion in 'Getting Started' started by Fredcm, Apr 24, 2019.

  1. Fredcm

    Fredcm

    Joined:
    Aug 14, 2018
    Posts:
    5
    I am trying to create a very basic UI for my project. The project consists of an object projecting an image onto another object on the scene. The user can change the images to be projected by dragging and dropping them from the Project tab into the Inspector menu.

    I already have a script for this, which is working just fine, but now I want to display 5 different options of images on the screen, in-game. This way, the user can pick an image by simply clicking on it (instead of having to drag and drop them into the Inspector).

    I already have this basic UI created as a prefab, with 5 icons representing the images, but my question is: how can I create a UI script with these elements, and how to make this script communicate with the projection script that is already applied to a game object on the scene?
     
  2. MD_Reptile

    MD_Reptile

    Joined:
    Jan 19, 2012
    Posts:
    2,664
    "An object projecting an image onto another object on the scene" seems a bit complicated to be honest lol. So, you want a 3D world object, like a projector I guess, to shine your UI onto the screen? You lost me there lol.
     
    Fredcm likes this.
  3. Fredcm

    Fredcm

    Joined:
    Aug 14, 2018
    Posts:
    5
    Actually, I already have this whole projection thing working in my project (I am using UVPaint plugin for this). What I want is simply to create a basic UI (some kind of selection menu) so that the user can pick between images.

    But as I am very new to C# and Unity, I am having trouble figuring out how to create a script for the UI, and how to make this script call actions (such as Project and Erase) from the projection script I already have.
     
  4. https://learn.unity.com/learn/tutorials?k=["t:tutorial","lang:en","tag:581391a30909150018ad9268"]

    You can learn how to create/use UI here.
     
    Fredcm likes this.
  5. Fredcm

    Fredcm

    Joined:
    Aug 14, 2018
    Posts:
    5
  6. Fredcm

    Fredcm

    Joined:
    Aug 14, 2018
    Posts:
    5