worked on GUI. Simple health bar is temp.
This commit is contained in:
parent
66a44d1cc4
commit
67b18de11b
Binary file not shown.
BIN
Assets/GUI/Healthbar.png
Normal file
BIN
Assets/GUI/Healthbar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 32 KiB |
57
Assets/GUI/Healthbar.png.meta
Normal file
57
Assets/GUI/Healthbar.png.meta
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 74267eec14d0a3740b66cdaf403f3a88
|
||||||
|
timeCreated: 1454189771
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
linearTexture: 0
|
||||||
|
correctGamma: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 0
|
||||||
|
cubemapConvolution: 0
|
||||||
|
cubemapConvolutionSteps: 7
|
||||||
|
cubemapConvolutionExponent: 1.5
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
rGBM: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
textureType: 8
|
||||||
|
buildTargetSettings: []
|
||||||
|
spriteSheet:
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
BIN
Assets/GUI/HealthbarFilled.png
Normal file
BIN
Assets/GUI/HealthbarFilled.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 31 KiB |
57
Assets/GUI/HealthbarFilled.png.meta
Normal file
57
Assets/GUI/HealthbarFilled.png.meta
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 855e9e69ccc2916489351dda7cbbf398
|
||||||
|
timeCreated: 1454189771
|
||||||
|
licenseType: Free
|
||||||
|
TextureImporter:
|
||||||
|
fileIDToRecycleName: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
mipmaps:
|
||||||
|
mipMapMode: 0
|
||||||
|
enableMipMap: 1
|
||||||
|
linearTexture: 0
|
||||||
|
correctGamma: 0
|
||||||
|
fadeOut: 0
|
||||||
|
borderMipMap: 0
|
||||||
|
mipMapFadeDistanceStart: 1
|
||||||
|
mipMapFadeDistanceEnd: 3
|
||||||
|
bumpmap:
|
||||||
|
convertToNormalMap: 0
|
||||||
|
externalNormalMap: 0
|
||||||
|
heightScale: 0.25
|
||||||
|
normalMapFilter: 0
|
||||||
|
isReadable: 0
|
||||||
|
grayScaleToAlpha: 0
|
||||||
|
generateCubemap: 0
|
||||||
|
cubemapConvolution: 0
|
||||||
|
cubemapConvolutionSteps: 7
|
||||||
|
cubemapConvolutionExponent: 1.5
|
||||||
|
seamlessCubemap: 0
|
||||||
|
textureFormat: -1
|
||||||
|
maxTextureSize: 2048
|
||||||
|
textureSettings:
|
||||||
|
filterMode: -1
|
||||||
|
aniso: -1
|
||||||
|
mipBias: -1
|
||||||
|
wrapMode: 1
|
||||||
|
nPOTScale: 0
|
||||||
|
lightmap: 0
|
||||||
|
rGBM: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
spriteMode: 1
|
||||||
|
spriteExtrude: 1
|
||||||
|
spriteMeshType: 1
|
||||||
|
alignment: 0
|
||||||
|
spritePivot: {x: 0.5, y: 0.5}
|
||||||
|
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
spritePixelsToUnits: 100
|
||||||
|
alphaIsTransparency: 1
|
||||||
|
textureType: 8
|
||||||
|
buildTargetSettings: []
|
||||||
|
spriteSheet:
|
||||||
|
sprites: []
|
||||||
|
outline: []
|
||||||
|
spritePackingTag:
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
58
Assets/GUI/mGUI.cs
Normal file
58
Assets/GUI/mGUI.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using System.Collections;
|
||||||
|
|
||||||
|
public class mGUI : MonoBehaviour
|
||||||
|
{
|
||||||
|
public GUISkin mySkin;
|
||||||
|
public float curHealth = 100;
|
||||||
|
public float maxHealth = 100;
|
||||||
|
public Texture2D bgImage;
|
||||||
|
public Texture2D fgImage;
|
||||||
|
float nativeWidth = 640;
|
||||||
|
float nativeHeight = 400;
|
||||||
|
float percentHealth;
|
||||||
|
int healthBarLength = 400;
|
||||||
|
Matrix4x4 guiMatrix;
|
||||||
|
|
||||||
|
void Start()
|
||||||
|
{
|
||||||
|
Vector3 scale = new Vector3(.5f, .5f, 1.0f);
|
||||||
|
print(scale);
|
||||||
|
guiMatrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Matrix4x4 GetGUIMatrix()
|
||||||
|
{
|
||||||
|
return guiMatrix;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
void OnGUI()
|
||||||
|
{
|
||||||
|
GUI.matrix = GetGUIMatrix();
|
||||||
|
// Create one Group to contain both images
|
||||||
|
// Adjust the first 2 coordinates to place it somewhere else on-screen
|
||||||
|
GUI.BeginGroup(new Rect(0, 0, 640, 400));
|
||||||
|
|
||||||
|
// Draw the background image
|
||||||
|
GUI.backgroundColor = new Color(0, 0, 0, 0.0f);
|
||||||
|
GUI.Box(new Rect(0, 0, 620, 400), bgImage);
|
||||||
|
|
||||||
|
percentHealth = curHealth / maxHealth;
|
||||||
|
// Create a second Group which will be clipped
|
||||||
|
// We want to clip the image and not scale it, which is why we need the second Group
|
||||||
|
GUI.BeginGroup(new Rect(0, 0, percentHealth * 640, 400));
|
||||||
|
|
||||||
|
// Draw the foreground image
|
||||||
|
GUI.backgroundColor = new Color(0, 0, 0, 0.0f);
|
||||||
|
GUI.Box(new Rect(0, 0, 620, 400), fgImage);
|
||||||
|
|
||||||
|
|
||||||
|
// End both Groups
|
||||||
|
GUI.EndGroup();
|
||||||
|
|
||||||
|
GUI.EndGroup();
|
||||||
|
}
|
||||||
|
}
|
13
Assets/GUI/mGUI.cs.meta
Normal file
13
Assets/GUI/mGUI.cs.meta
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 648f4d518e7553e43bfc19b27ce55c9b
|
||||||
|
timeCreated: 1454186720
|
||||||
|
licenseType: Free
|
||||||
|
MonoImporter:
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences:
|
||||||
|
- mySkin: {fileID: 11400000, guid: 35ff26cd2821a324b9bfa066cd48b571, type: 2}
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Reference in New Issue
Block a user