Skip to content

Commit

Permalink
Upgrade to Unity 5
Browse files Browse the repository at this point in the history
  • Loading branch information
TarasOsiris committed May 7, 2015
1 parent e34a19b commit 1786e50
Show file tree
Hide file tree
Showing 70 changed files with 577 additions and 228 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
Temp/
obj/
Library/
UnityVS/

# ===================================== #
# Visual Studio / MonoDevelop generated #
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ void Update ()
mTrans.position = uiCamera.ViewportToWorldPoint(pos);

// For pixel-perfect results
if (uiCamera.isOrthoGraphic)
if (uiCamera.orthographic)
{
mTrans.localPosition = NGUIMath.ApplyHalfPixelOffset(mTrans.localPosition, mTrans.localScale);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public InvGameItem Replace (InvBaseItem.Slot slot, InvGameItem item)

if (baseItem != null && go != null)
{
Renderer ren = go.renderer;
Renderer ren = go.GetComponent<Renderer>();
if (ren != null) ren.material.color = baseItem.color;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void OnPress (bool isPressed)
}

mIsDragging = false;
Collider col = collider;
Collider col = GetComponent<Collider>();
if (col != null) col.enabled = !isPressed;
if (!isPressed) Drop();
}
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Examples/Scripts/Other/Spin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public class Spin : MonoBehaviour
void Start ()
{
mTrans = transform;
mRb = rigidbody;
mRb = GetComponent<Rigidbody>();
}

void Update ()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
// Copyright 2011-2013 Tasharen Entertainment
//----------------------------------------------

using UnityEngine;
Expand Down Expand Up @@ -64,7 +64,7 @@ void OnNormal (string spriteName)
mButton.normalSprite = spriteName;
mSprite.spriteName = spriteName;
mSprite.MakePixelPerfect();
if (mButton.collider == null || (mButton.collider is BoxCollider)) NGUITools.AddWidgetCollider(mButton.gameObject);
if (mButton.GetComponent<Collider>() == null || (mButton.GetComponent<Collider>() is BoxCollider)) NGUITools.AddWidgetCollider(mButton.gameObject);
Repaint();
}

Expand Down
4 changes: 2 additions & 2 deletions patterns_proj/Assets/NGUI/Scripts/Interaction/UIButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ public bool isEnabled
{
get
{
Collider col = collider;
Collider col = GetComponent<Collider>();
return col && col.enabled;
}
set
{
Collider col = collider;
Collider col = GetComponent<Collider>();
if (!col) return;

if (col.enabled != value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ protected void Init ()
}
else
{
Renderer ren = tweenTarget.renderer;
Renderer ren = tweenTarget.GetComponent<Renderer>();

if (ren != null)
{
mColor = ren.material.color;
}
else
{
Light lt = tweenTarget.light;
Light lt = tweenTarget.GetComponent<Light>();

if (lt != null)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public class UIDraggableCamera : IgnoreTimeScale

void Awake ()
{
mCam = camera;
mCam = GetComponent<Camera>();
mTrans = transform;

if (rootForBounds == null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ public bool isEnabled
{
get
{
Collider col = collider;
Collider col = GetComponent<Collider>();
return col && col.enabled;
}
set
{
Collider col = collider;
Collider col = GetComponent<Collider>();
if (!col) return;

if (col.enabled != value)
Expand Down
10 changes: 5 additions & 5 deletions patterns_proj/Assets/NGUI/Scripts/Interaction/UIScrollBar.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//----------------------------------------------
// NGUI: Next-Gen UI kit
// Copyright © 2011-2013 Tasharen Entertainment
// Copyright 2011-2013 Tasharen Entertainment
//----------------------------------------------

using UnityEngine;
Expand Down Expand Up @@ -104,8 +104,8 @@ public Direction direction
ForceUpdate();

// Update the colliders as well
if (mBG.collider != null) NGUITools.AddWidgetCollider(mBG.gameObject);
if (mFG.collider != null) NGUITools.AddWidgetCollider(mFG.gameObject);
if (mBG.GetComponent<Collider>() != null) NGUITools.AddWidgetCollider(mBG.gameObject);
if (mFG.GetComponent<Collider>() != null) NGUITools.AddWidgetCollider(mFG.gameObject);
}
}
}
Expand Down Expand Up @@ -293,14 +293,14 @@ void OnDragForeground (GameObject go, Vector2 delta)

void Start ()
{
if (background != null && background.collider != null)
if (background != null && background.GetComponent<Collider>() != null)
{
UIEventListener listener = UIEventListener.Get(background.gameObject);
listener.onPress += OnPressBackground;
listener.onDrag += OnDragBackground;
}

if (foreground != null && foreground.collider != null)
if (foreground != null && foreground.GetComponent<Collider>() != null)
{
UIEventListener listener = UIEventListener.Get(foreground.gameObject);
listener.onPress += OnPressForeground;
Expand Down
4 changes: 2 additions & 2 deletions patterns_proj/Assets/NGUI/Scripts/Interaction/UISlider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ void Init ()
void Awake ()
{
mTrans = transform;
mCol = collider as BoxCollider;
mCol = GetComponent<Collider>() as BoxCollider;
}

/// <summary>
Expand All @@ -149,7 +149,7 @@ void Start ()
{
Init();

if (Application.isPlaying && thumb != null && thumb.collider != null)
if (Application.isPlaying && thumb != null && thumb.GetComponent<Collider>() != null)
{
UIEventListener listener = UIEventListener.Get(thumb.gameObject);
listener.onPress += OnPressThumb;
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/Internal/NGUITools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ static public AudioSource PlaySound (AudioClip clip, float volume, float pitch)

if (mListener != null && mListener.enabled && NGUITools.GetActive(mListener.gameObject))
{
AudioSource source = mListener.audio;
AudioSource source = mListener.GetComponent<AudioSource>();
if (source == null) source = mListener.gameObject.AddComponent<AudioSource>();
source.pitch = pitch;
source.PlayOneShot(clip, volume);
Expand Down
4 changes: 2 additions & 2 deletions patterns_proj/Assets/NGUI/Scripts/Tweening/TweenColor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public Color color
void Awake ()
{
mWidget = GetComponentInChildren<UIWidget>();
Renderer ren = renderer;
Renderer ren = GetComponent<Renderer>();
if (ren != null) mMat = ren.material;
mLight = light;
mLight = GetComponent<Light>();
}

/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/Tweening/TweenFOV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TweenFOV : UITweener
/// Camera that's being tweened.
/// </summary>

public Camera cachedCamera { get { if (mCam == null) mCam = camera; return mCam; } }
public Camera cachedCamera { get { if (mCam == null) mCam = GetComponent<Camera>(); return mCam; } }

/// <summary>
/// Current field of view value.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class TweenOrthoSize : UITweener
/// Camera that's being tweened.
/// </summary>

public Camera cachedCamera { get { if (mCam == null) mCam = camera; return mCam; } }
public Camera cachedCamera { get { if (mCam == null) mCam = GetComponent<Camera>(); return mCam; } }

/// <summary>
/// Current field of view value.
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/Tweening/TweenVolume.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public AudioSource audioSource
{
if (mSource == null)
{
mSource = audio;
mSource = GetComponent<AudioSource>();

if (mSource == null)
{
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/UI/UIAnchor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public enum Side
void Awake ()
{
mTrans = transform;
mAnim = animation;
mAnim = GetComponent<Animation>();
}

/// <summary>
Expand Down
4 changes: 2 additions & 2 deletions patterns_proj/Assets/NGUI/Scripts/UI/UICamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ class Highlighted
/// Caching is always preferable for performance.
/// </summary>

public Camera cachedCamera { get { if (mCam == null) mCam = camera; return mCam; } }
public Camera cachedCamera { get { if (mCam == null) mCam = GetComponent<Camera>(); return mCam; } }

/// <summary>
/// Set to 'true' just before OnDrag-related events are sent (this includes OnPress events that resulted from dragging).
Expand Down Expand Up @@ -726,7 +726,7 @@ void Awake ()
Application.platform == RuntimePlatform.IPhonePlayer
#if !UNITY_3_5 && !UNITY_4_0 && !UNITY_4_1
|| Application.platform == RuntimePlatform.WP8Player
|| Application.platform == RuntimePlatform.BB10Player
|| Application.platform == RuntimePlatform.BlackBerryPlayer
#endif
)
{
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/UI/UIOrthoCamera.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class UIOrthoCamera : MonoBehaviour

void Start ()
{
mCam = camera;
mCam = GetComponent<Camera>();
mTrans = transform;
mCam.orthographic = true;
}
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/UI/UIPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,7 @@ void OnDrawGizmos ()
GameObject go = UnityEditor.Selection.activeGameObject;
bool selected = (go != null) && (NGUITools.FindInParents<UIPanel>(go) == this);

if (selected || clip || (mCam != null && mCam.isOrthoGraphic))
if (selected || clip || (mCam != null && mCam.orthographic))
{
if (size.x == 0f) size.x = mScreenSize.x;
if (size.y == 0f) size.y = mScreenSize.y;
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/UI/UIStretch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public enum Style

void Awake ()
{
mAnim = animation;
mAnim = GetComponent<Animation>();
mRect = new Rect();
mTrans = transform;
}
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/UI/UITextList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void Awake ()
if (textLabel == null) textLabel = GetComponentInChildren<UILabel>();
if (textLabel != null) textLabel.lineWidth = 0;

Collider col = collider;
Collider col = GetComponent<Collider>();

if (col != null)
{
Expand Down
2 changes: 1 addition & 1 deletion patterns_proj/Assets/NGUI/Scripts/UI/UIViewport.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class UIViewport : MonoBehaviour

void Start ()
{
mCam = camera;
mCam = GetComponent<Camera>();
if (sourceCamera == null) sourceCamera = Camera.main;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ private void InitCapsulePrototype()
var capsule = GameObject.CreatePrimitive(PrimitiveType.Capsule);

capsule.AddComponent<Rigidbody>();
capsule.renderer.material = greenMaterial;
capsule.GetComponent<Renderer>().material = greenMaterial;

var capsuleBehaviour = capsule.AddComponent<GreenCapsule>();
capsuleBehaviour.health = 100;
Expand All @@ -37,14 +37,14 @@ private void InitCapsulePrototype()
public void SpawnBlueSphere()
{
var blueSphere = Object.Instantiate(blueSpherePrototype, Vector3.zero, Quaternion.identity) as GameObject;
blueSphere.rigidbody.velocity = new Vector3(5, 5, 5);
blueSphere.GetComponent<Rigidbody>().velocity = new Vector3(5, 5, 5);
}

// Prefab can clone itself
public void SpawnRedCube()
{
var redCube = redCubePrototype.Clone();
redCube.rigidbody.velocity = new Vector3(5, 5, 5);
redCube.GetComponent<Rigidbody>().velocity = new Vector3(5, 5, 5);
}

// Construct Object from scratch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ void UpdateRobotProperties()
{
_isGrounded = Physics2D.OverlapCircle(_groundCheck.position, GROUNDED_RADIUS, whatIsGround);
_anim.SetBool("Ground", _isGrounded);
_anim.SetFloat("vSpeed", rigidbody2D.velocity.y);
_anim.SetFloat("vSpeed", GetComponent<Rigidbody2D>().velocity.y);
}

void UpdateInput()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public override RobotState HandleInput(State2DRobotInput.RobotInput input)
_robotAnimator.SetBool("Crouch", input.crouch);

_robotAnimator.SetFloat("Speed", Mathf.Abs(input.move));
_robot.rigidbody2D.velocity = new Vector2(input.move * MAX_SPEED, _robot.rigidbody2D.velocity.y);
_robot.GetComponent<Rigidbody2D>().velocity = new Vector2(input.move * MAX_SPEED, _robot.GetComponent<Rigidbody2D>().velocity.y);

if (input.move > 0 && !_facingRight) { Flip(); }
else if(input.move < 0 && _facingRight) { Flip(); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public MyCubePool(MyCube objectToCopy, GameObject parent, int initialSize, int g
protected override void OnHandleAllocatePrefab(MyCube prefabInstance)
{
prefabInstance.gameObject.SetActive(true);
prefabInstance.renderer.material.color = Color.yellow;
prefabInstance.GetComponent<Renderer>().material.color = Color.yellow;
prefabInstance.transform.position = new Vector3(-3, -3, -3);
}

Expand All @@ -35,7 +35,7 @@ protected override void OnHandleAllocatePrefab(MyCube prefabInstance)
protected override void OnHandleObtainPrefab(MyCube prefabInstance)
{
prefabInstance.gameObject.SetActive(true);
prefabInstance.renderer.material.color = Color.green;
prefabInstance.GetComponent<Renderer>().material.color = Color.green;
}

/*
Expand All @@ -46,6 +46,6 @@ protected override void OnHandleObtainPrefab(MyCube prefabInstance)
protected override void OnHandleRecyclePrefab(MyCube prefabInstance)
{
prefabInstance.gameObject.SetActive(true);
prefabInstance.renderer.material.color = Color.red;
prefabInstance.GetComponent<Renderer>().material.color = Color.red;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ void FixedUpdate()
anim.SetBool("Ground", grounded);

// Set the vertical animation
anim.SetFloat("vSpeed", rigidbody2D.velocity.y);
anim.SetFloat("vSpeed", GetComponent<Rigidbody2D>().velocity.y);
}


Expand Down Expand Up @@ -65,7 +65,7 @@ public void Move(float move, bool crouch, bool jump)
anim.SetFloat("Speed", Mathf.Abs(move));

// Move the character
rigidbody2D.velocity = new Vector2(move * maxSpeed, rigidbody2D.velocity.y);
GetComponent<Rigidbody2D>().velocity = new Vector2(move * maxSpeed, GetComponent<Rigidbody2D>().velocity.y);

// If the input is moving the player right and the player is facing left...
if(move > 0 && !facingRight)
Expand All @@ -81,7 +81,7 @@ public void Move(float move, bool crouch, bool jump)
if (grounded && jump) {
// Add a vertical force to the player.
anim.SetBool("Ground", false);
rigidbody2D.AddForce(new Vector2(0f, jumpForce));
GetComponent<Rigidbody2D>().AddForce(new Vector2(0f, jumpForce));
}
}

Expand Down
Loading

0 comments on commit 1786e50

Please sign in to comment.