Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Change Movie Texture by click

Discussion in 'Scripting' started by andiknowit, Mar 3, 2016.

  1. andiknowit

    andiknowit

    Joined:
    Mar 3, 2016
    Posts:
    4
    Hi!
    I have two RawImages in my project.
    First Raw Image is fullscreen, second item is centered.
    There is a Panel and toggle group.
    I have three movie textures.
    I want to use my toggle-buttons for changing movie textures in second RawImage.
    Please help me to understand how make this:)
     
  2. andiknowit

    andiknowit

    Joined:
    Mar 3, 2016
    Posts:
    4
    Unity version is 5.2.1
     
  3. Marikosama

    Marikosama

    Joined:
    Jun 26, 2015
    Posts:
    13
    Since toggle is true or false so you could only change two image based on true or false.
    Just create a script with public gameobject that refer to your sprite
    Then write a public function inside that contains a boolean parameter
    then if...else statement
    if(true)
    rawImage2.sprite = spriteA;
    else
    rawImage2.sprite = spriteB;
    Add a OnValueChanged
    then refer to the object that this script attached on
     
    andiknowit likes this.