SuperPower Unity!
Rinity2 performs IL(C# bytecode) modification to accomplish syntax magics which cannot be done in vanilla C#/Unity.
This may sensative to Unity version changes and not work with latest Unity.
- Unity 2017.3 or higher
- 2-Way Binding
- String Interpolation
- PubSub Messaging
- Threading Utilities
- Object Pooling
Recycle
[Recycle]
public class Player {
/* ... */
}
/* auto pooling */
var player = new Player();
Automatically recycles the objects instead of creating new one.
based on this small research
String Interpolation
int a = 1234;
Debug.Log("a is {{a}}.")
- This feature is no longer useful since Unity fully supports latest .Net and C#.
Dispatch
[Dispatch(ThreadType.ThreadPool)]
public void DownloadJson(string uri) {
// This will be executed in background thread.
var json = SomeDownloadMethod(uri);
OnDownloadJson(json);
}
[Dispatch(ThreadType.MainThread)]
public void OnDownloadJson(string json) {
// Will be executed in main thread.
/* do UI tasks */
}
Just call methods without threading concerns, it automatically dispatches to right thread for you.
SharedVar
[SharedVariable("shared_level")]
public int level {get;set;}
[SharedVariable("shared_level")]
public int level2 {get;set;}
Trace
[Trace]
public void WorkWork() {
/* .... */
}
NotifyChange
class Player : INotifyPropertyChanged {
public event PropertyChangedEventHandler PropertyChanged;
public int level { get; set; }
void Start () {
PropertyChanged += OnPropertyChanged;
}
// Automatically called when property is changed.
private void OnPropertyChanged(object sender, PropertyChangedEventArgs e) {
Debug.Log("PROPERTY CHANGED : " + e.PropertyName);
}
}
DbgHelper
// Same as __LINE__ in C++
Debug.Log( DbgHelper.CurrentLine );