forked from UnityTech/exampleunity
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_script.cs
More file actions
34 lines (27 loc) · 724 Bytes
/
example_script.cs
File metadata and controls
34 lines (27 loc) · 724 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// single_script.cs
// Example code for small Unity project using C#
using UnityEngine;
using System.Collections;
public class example_script : MonoBehaviour {
public Texture aTexture;
void OnGUI() {
#if UNITY_EDITOR
if (!aTexture) {
Debug.LogError("Assign a Texture in the inspector.");
return;
}
#endif
// Draws a single image in a square the size of the screen
int width = Screen.width;
int height = Screen.height;
int left = 0;
int top = 0;
if (width > height)
width = height;
else
height = width;
left = Screen.width/2 - width/2;
top = Screen.height/2 - height/2;
GUI.DrawTexture(new Rect(left, top, width, height), aTexture);
}
}