Error Static Member cannot be accessed - qualify it with type name instead??????

hey,
im getting an error on my script, not really sure how to go about fixing it, im using C#

the error says

Assets/Virtual Gallery/ImageGallery/SetTextures.cs(90,22): error CS0176: Static member `SetTextures.imagePath' cannot be accessed with an instance reference, qualify it with a type name instead

and this is the script:

using UnityEngine;
using System.Collections;

public class LoadGalleryTexture : MonoBehaviour {
	
 	//public string PicTexture;

public Transform TextObject;

public string url;

IEnumerator Start() {
WWW www = new WWW(url);
yield return www;
renderer.material.mainTexture = www.texture;
}



void Update()
{
	TextObject.guiText.text = "filepath:  "+ url;	
	if(SetTextures.PicHit.transform.position == transform.position)
	{
	url = SetTextures.imagePath;	
	}
}
}

any input?

the error comes from SetTextures, not this code actually

this is how i have my variable set up in SetTextures

	public static string imagePath;

according to this link it should be set up differently. how do i go about changing it?

http://msdn.microsoft.com/en-us/library/zhcxt2bd%28v=vs.80%29.aspx

If you need to access the static variable, do it like so:

SetTextures.imagePath

(there are other ways to access it, but that one is foolproof)

thats how i have it set up in my 1st script, returning the posted error… ive accessed many scripts like that before, not sure why this one is coming back like this

perhaps i shouldve read that it the error is in SetTextures! lol

heres set textures, the problem is happening at the part where it is this.imagePath = imagePath

using UnityEngine;
using System.Collections;


public class SetTextures : MonoBehaviour
{
	public GameObject testPlane;
	public static string imagePath;
	public Transform ApplyPicSwitch;
		public Transform TextObject;
public static RaycastHit PicHit;


public LoadGalleryTexture script;
	void Start()
	{
	
	script = GetComponent("LoadGalleryTexture") as LoadGalleryTexture;
	
		
		// Listen to image picker event so we can load the image into a texture later
		EtceteraManager.imagePickerChoseImage += imagePickerChoseImage;

	}
	
	
	void OnDisable()
	{
		// Stop listening to the image picker event
		EtceteraManager.imagePickerChoseImage -= imagePickerChoseImage;
	}
	
//			float yPos = 5.0f;
//		float xPos = 5.0f;
//		float width = 130.0f;
//		float height = 18.0f;
//		float heightPlus = height + 10.0f;
	//void OnGUI()
	
		


		
			
			
	void Update(){
		
		//TextObject.guiText.text = "filepath:  "+ CurrentTexture; //EtceteraBinding.CurrentTexture;
	
				 Ray Picray = camera.ScreenPointToRay(Input.GetTouch(0).position);

				 		//	StartCoroutine( EtceteraManager.textureFromFileAtPath( "file://" + imagePath, GUItextureLoaded, null ) );
		
			//if( GUI.Button( new Rect( 20, 165, width, height ), "Load Photo Texture" ) )
		//{
			
	if(ApplyPicSwitch.position.x>0)
	{		
	if (Physics.Raycast (Picray, out PicHit))
	{	
		if(/*Input.GetTouch(0).phase == TouchPhase.Began */ PicHit.transform.tag == "PictureFrame")
		{
			//PicHit.transform.renderer.material.color = Color.red;
		}
		if(Input.GetTouch(0).phase == TouchPhase.Ended  PicHit.transform.tag == "PictureFrame")
		{
			if( imagePath == null )
			{
				EtceteraBinding.showAlertWithTitleMessageAndButton( "Load Photo Texture Error", "You have to choose a photo before loading", "OK" );
				return;
			}
			
			// No need to resize because we asked for an image scaled from the picker
			// Resize the image so that we dont end up trying to load a gigantic image
			//EtceteraBinding.resizeImageAtPath( imagePath, 256, 256 );
			
			// Add 'file://' to the imagePath so that it is accessible via the WWW class
			//PicHit.transform.renderer.material.color = Color.grey;
			StartCoroutine( EtceteraManager.textureFromFileAtPath( "file://" + imagePath, textureLoaded, textureLoadFailed ) );
			
			
		}
		
	}
		}
		}
	public static string CurrentTexture;
	void imagePickerChoseImage( string imagePath )
	{
		this.imagePath = imagePath;
		//CurrentTexture = imagePath;
	}
	
	
	public IEnumerator hideActivityView()
	{
		yield return new WaitForSeconds( 2.0f );
		EtceteraBinding.hideActivityView();
	}
	
	
	// Texture loading delegates
	public void textureLoaded( Texture2D texture )
	{
		PicHit.transform.renderer.material.mainTexture = texture;
		//script.url = "file://"+imagePath;
		//testPlane.guiTexture.texture = texture;

	}
	
		// Texture loading delegates
	//public void GUItextureLoaded( Texture2D texture )
	//{
	//	testPlane.guiTexture.texture = texture;
		//PicHit.transform.renderer.material.mainTexture = texture;
	//}
	
	
	public void textureLoadFailed( string error )
	{
		EtceteraBinding.showAlertWithTitleMessageAndButton( "Error Loading Texture.  Did you choose a photo first?", error, "OK" );
		Debug.Log( "textureLoadFailed: " + error );
	}




}
this.imagePath = imagePath;

That’s almost certainly your problem right there. The compiler isn’t really sure whether this.imagePath refers to public SetTextures.imagePath or the local variable within that function.

When you say this.imagePath you are literally saying “the “imagePath” variable on this particular instance of SetTexture” - however, SetTextures.imagePath is not a member of that particular instance of SetTexture, it is static to the entire class.

Instead, say something like this:

SetTextures.imagePath = imagePath;

However, even that is really - really not suggested. You really shouldn’t use the same variable name at all - and I honestly suggest using an entirely different naming convention for the different variable scopes (local to the script vs local to the function).

Maybe use pascal-case starting with a capital for your script-local variable (SetTextures.ImagePath) and starting with a lower case for your function-local (imagePath).

Since you are using C# though, I really suggest just encapsulating the static variable like this…

static string _imagePath;
public static string ImagePath { get { return _imagePath; } set {_imagePath = value; }}

Then, whenever you access it from within the class call the _imagePath, and externally you'll have SetTextures.ImagePath available to you. 

I do wonder why you are using a static variable there anyway though. Perhaps you'd be better served by a properly encapsulated singleton setup (since SetTextures is a MonoBehaviour).

well, i have kinda a crazy setup going on lol

Im using a plugin from prime31 that lets me assign textures from the ipad gallery, thats where this script is actually used, then i altered it to make it so when i touch the object it changes to the selected texture from the ipad photo gallery.

My REAL problem is that when i save the scene, the new texture is not saving, it reverts back to the original.

So what im trying to accomplish is when i tap the object i want to change, it assigns the texture, THEN in another script copies down the image path as a string as a WWW so the next time i load the scene it assigns the WWW texture from the start.

I also usually write in UnityScript, so thats why im pretty confused while trying to alter this. Ill try to make the changes, not sure how it will go! lol

BINGO! Kyle i love you! haha it worked and now i can save everything! woo! problem solved!