- Home /
Ui Canvas/Error CS0117
For a unity game group project my task at the moment is to find out the following: In the game the player will sooner or later find a picture (in this case a map) lying on a desk, and when clicking on the map it will become screen sized so you can look at it properly, and when clicking again the map should go back to it's place on the table. I wanna realize this by using a UI Canvas and the function OnMouseDown. I've been trying to figure it out but right now I have the error CS0117 saying sth does not contain a definition for renderMode.
using UnityEngine;
using System.Collections;
public class MapDummy : MonoBehaviour {
private Canvas canvas;
void Start(){
canvas = GetComponent<Canvas>();
}
void OnMouseDown()
{
if(MapDummy.renderMode == RenderMode.WorldSpace)
{
MapDummy.renderMode = RenderMode.ScreenSpaceOverlay;
}
}
void Update()
{
if(MapDummy.renderMode != RenderMode.WorldSpace
&& Input.GetMouseButtonDown(0))
{
MapDummy.renderMode = RenderMode.WorldSpace;
}
}
}
This is my code so far. Can anyone tell me what my mistake is? And maybe how I have to put the settings for the Canvas? Thanks!
Answer by applemaniac · May 20, 2015 at 09:26 AM
Hello, why don't you replace MapDummy.renderMode by canvas.renderMode ?
Changed it but it doesn't work :/ I have no error but nothing happens. Did I put the components in the correct way? First I created a GameObject UI Canvas, added the Component Image to it and added my picture called "$$anonymous$$apDummy" as SourceImage to the Image. I imported $$anonymous$$apDummy as Asset with the setting "Texture Type:Sprite". Then I created the script and put it to the canvas. Is that the correct way?
Your answer