More flexibility, less code - more productive development.
Unity3D β , 8 β , , -. , Unity -, , .
, , , - β , . - 24 72 , β , GitHub Game Off, .
-, C++ ( , ), , : β .
β (, , ) β :
: , .
: , .
Unity : Unity, .
, Unity3D .
: Unity 3D Technologies ( ).
1.
β . Unity .
β [Serializable] . β Unity:
[Serializable]
public struct PlayerStats
{
public int movementSpeed;
public int hitPoints;
public bool hasHealthPotion;
}
, , .
: , , β , .
public enum PlayerType
{
ARCHER, KNIGHT
}
[Serializable]
public struct PlayerStats
{
public int movementSpeed;
public int hitPoints;
public bool hasHealthPotion;
public Sprite face;
public PlayerType type;
}
, Unity β .
2. RequireComponent
β . , , , Rigidbody . β RequireComponent.
:
.
.
, .
RequireComponent :
[RequireComponent(typeof(Rigidbody))]
public class PlayerScript : MonoBehaviour
{
Rigidbody rigidbody;
void Awake()
{
rigidbody = GetComponent<Rigidbody>();
}
}
. Awake Start, .
. , RequireComponent . , β .
, , null, β , .
3.
, , : Unity . Unity , , , , .
, β .
OnClick: , , .
, , onClick Unity, . : β ( setActive(true) ), β ( play() ) Animator β ( setTrigger() ). β .
. . . , . : β , .
4. Unity
Unity UnityEvent, OnClick Unity. UnityEvent, , , OnClick:
, , UnityEvent . , UnityEvent Invoke:
using UnityEngine;
using UnityEngine.Events;
public class CallEventsScript : MonoBehaviour
{
public UnityEvent eventsToBeCalled;
public void CallEvents()
{
eventsToBeCalled.Invoke();
}
}
CallEvents UnityEvent. , , . β .
UnityEvent , , , Awake, Start, OnEnable, OnDisable . . , , Start, β .
β , : , . UnityEvent:
[RequireComponent(typeof(Collider))]
public class TriggerBoxScript : MonoBehaviour
{
public UnityEvent eventsToBeCalledOnCollision;
public List<string> objectsTagToActivate;
private void OnCollisionEnter(Collision other)
{
if (OtherHasWantedTag(other.gameObject))
{
InvokeEvents();
}
}
private void OnTriggerEnter(Collider other)
{
if (OtherHasWantedTag(other.gameObject))
{
InvokeEvents();
}
}
private bool OtherHasWantedTag(GameObject other)
{
var found = objectsTagToActivate.Find(other.CompareTag);
return found != null;
}
private void InvokeEvents()
{
eventsToBeCalledOnCollision.Invoke();
}
}
, ( OnTriggerEnter, OnCollisionEnter). , .
, . , Β«PlayerΒ» β , . : , , , . .
, β Unity. β .
(OnClick UnityEvent) ( ) ( ).
, , : . , , , . Unity, .
, β , , . , , .
.
Alconost.
Alconost , 70 . - , , API, , 24/7, .
β , , , , , , , Google Play App Store.