relatively new to unity and began with java script but now want to change to C#. I previously had a health bar 2d texture set up which would change size with the following javascript code which worked;
var maximumHitPoints = 100.0;
var playerHealth = 100.0;
var damage : int = 50;
var healthGUI : GUITexture;
using UnityEngine;
using System.Collections;
public class PlayerHealthGuiScript : MonoBehaviour {
public float maxHealth;
public float currentHealth;
public int damageAmount;
public GUITexture healthBar;
private float healthGuiWidth;
Setting xMax in this case doesn’t make much sense since it’s much more complicated that way. xMin, yMin, xMax and yMax are just wrapper properties and they work internally (kind of) with x, y, width and height.
Like already been mentioned in JS when you access the member of a value type property it automatically creates a local variable, change the member and assign it back. It might be easier but break the rule of value types since it behaves like a reference type.
Thanks all of you I tried all your solutions and they seem to work fine.
Not only that but I now have a better understanding of what was going wrong as well which will help in the future.
I have another 7 scripts to convert so you may hear from me again