Question by
ayadader · Dec 11, 2015 at 01:53 PM ·
controller
Why give me an error on namespace mset{ public enum Corner {
link textusing UnityEngine; using System.Collections;
namespace mset{ public enum Corner { TopLeft, TopRight, BottomLeft, BottomRight }
public class logo : MonoBehaviour {
public Texture2D logoTexture = null;
public Color color = Color.white;
public Vector2 logoPixelOffset = new Vector2(0,0);
public Vector2 logoPercentOffset = new Vector2(0,0);
public Corner placement = Corner.BottomLeft;
private Rect texRect = new Rect(0,0,0,0);
void Reset() {
logoTexture = Resources.Load("renderedLogo") as Texture2D;
}
void Start() {
}
void updateTexRect() {
if( logoTexture ) {
float tw = logoTexture.width;
float th = logoTexture.height;
float cw = 0f;
float ch = 0f;
if( this.GetComponent<Camera>() ) {
//check attached camera first
cw = GetComponent<Camera>().pixelWidth;
ch = GetComponent<Camera>().pixelHeight;
} else if( Camera.main ) {
//use first camera tagged as MainCamera
cw = Camera.main.pixelWidth;
ch = Camera.main.pixelHeight;
} else if( Camera.current ) {
//use currently active camera (mostly harmless)
//cw = Camera.current.pixelWidth;
//ch = Camera.current.pixelHeight;
}
float ox = logoPixelOffset.x + logoPercentOffset.x*cw*0.01f;
float oy = logoPixelOffset.y + logoPercentOffset.y*ch*0.01f;
switch(placement) {
case Corner.TopLeft:
texRect.x = ox;
texRect.y = oy;
break;
case Corner.TopRight:
texRect.x = cw - ox - tw;
texRect.y = oy;
break;
case Corner.BottomLeft:
texRect.x = ox;
texRect.y = ch - oy - th;
break;
case Corner.BottomRight:
texRect.x = cw - ox - tw;
texRect.y = ch - oy - th;
break;
};
texRect.width = tw;
texRect.height = th;
}
}
void OnGUI() {
updateTexRect();
if( logoTexture ) {
GUI.color = color;
GUI.DrawTexture(texRect, logoTexture);
}
}
}
}
logo.zip
(794 B)
Comment
Error publication , but in the attached file with the question .... This is the first time used the site ..
Your answer
![](https://koobas.hobune.stream/wayback/20220612052206im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
FPS Walker bunny hops if stop walking while on slopes 2 Answers
Spaceship Script not working? 0 Answers
optimising player controller 1 Answer
How to add a sprint button on a 3D platformer? In C# 1 Answer