Is this possible? (503189)

I’m currently working on a simple slide show where the user clicks on one of two arrows and the texture offset increases. This is possible if I separate the below into two separate script files and attach them to the arrows. What I want to do to is combine both of these into one file attached to the player object. I’ve tried to do this below but I’m not sure if it possible…

using UnityEngine;
using System.Collections;

public class Arrows : MonoBehaviour {
	
	public int time = 2;

	public GameObject screen;
	public float moveTex = 0.25f;
	
	public GameObject[] arrows;
	
	
	// Use this for initialization
	void Start () {
	
	}
	
	IEnumerator OnMouseUp( GameObject[] arrows){
				
		float tex_offset_x = screen.renderer.material.GetTextureOffset("_MainTex").x;
		
		if (tex_offset_x <= 0f)
		{
			moveTex = 0f;	
		}
		else
		{
			moveTex = 0.25f;
		}
		
		if(arrows[0])
		{
			screen.renderer.material.SetTextureOffset("_MainTex", new Vector2( tex_offset_x-moveTex, 0f));
		}
		
		if(arrows[1])
		{
			screen.renderer.material.SetTextureOffset("_MainTex", new Vector2( tex_offset_x+moveTex, 0f));	
		}


		yield return new WaitForSeconds(time);
		yield return null;
		
	}
	
}

What this should do in my mind, is detect which of the game objects the mouse has just clicked and then move the texture accordingly. This doesn’t happen. No errors returned. Just nothing happens.

From the OnMouseUp reference you can see that it doenst provide a overload that has parameters.
OnMouse… events only work for the gameobject the script is applied to.

Another way would be to cast rays yourself and go from there.

Ref:

You could also put the script with the texture swapping onto the image that is getting switched. Then make another script to put on the left and right arrows to increase/decrease the index.