Mehr FlexibilitÀt, weniger Code - produktivere Entwicklung.

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, .
, â , , . , , .
.
![KĂŒste, brauner Sand. Albert Edelfelt (1935) [USEUM] KĂŒste, brauner Sand. Albert Edelfelt (1935) [USEUM]](https://habrastorage.org/getpro/habr/upload_files/242/d66/470/242d664703dd898ef9c3156c4a58ae7a.png)
Alconost.
Alconost , 70 . - , , API, , 24/7, .
â , , , , , , , Google Play App Store.