Name | Status |
---|---|
OpenUPM | |
Unity 2019.4 | |
Unity 2020.3 | |
Unity 2021.3 | |
Development package |
- Add the OpenUPM reigstry.
Click in the menu bar Edit → Project Settings... → Package Manager Add a new scoped registry with the following parameters:
Name:OpenUPM
URL:https://package.openupm.com
Scopes:com.openupm
se.hertzole.cecil-attributes
- Click apply and close the project settings.
- Open up the package manager.
Click in the menu bar Window → Package Manager - Select
Packages: My Registries
in the menu bar of the package manager window. - You should see Cecil Attributes under the
Hertzole
section. Click on it and then press Install in the bottom right corner.
- Open up the Unity package manager
- Click on the plus icon in the top left and "Add package from git url"
- Paste in
https://github.com/Hertzole/cecil-attributes.git
You can also paste inhttps://github.com/Hertzole/cecil-attributes.git#develop
if you want the latest (but unstable!) changes.
Unity should now resolve the packages.
Applies to classes, fields, properties, and events
Reset static will automatically reset your statics to their default value when the game starts. The default value can be either a value you've specified (the default assign value) or just the default value for that type. This is extremely useful for when you have fast enter play mode settings on without domain reload. Putting it on a class will reset all static fields/properties/events in that class.
Usage:
[ResetStatic]
public static int testValue = 10;
Applies to methods and properties
Log called will automatically put a Debug.Log message in your methods/properties to see when they are called.
In methods it will display all the parameters along with the name of the method.
In properties it will display the property name, Get/Set and the value. If it's a get it will show the return value. If it's a set it will show the old value and the new value. You can also turn off logging for both get/set per attribute.
Usage:
[LogCalled(logPropertyGet: true, logPropertySet: true)]
public int MyProperty { get; set; }
[LogCalled]
public void MyMethod(int para1, string para2)
{
// Will log "MyMethod (para1: <value>, para2: <value>)
}
Applies to fields and properties
Find property will automatically find serialized properties for you and make sure they exist. By default it searches with the same name as the field/property in your editor script, but a custom name/path can be specified to make it search with another name or within another serialized property.
Usage:
[FindProperty]
private SerializedProperty myProperty; // Will look for a property called 'myProperty'.
[FindProperty("customName")]
private SerializedProperty notMyName; // Will look for a property called 'customName'.
[FindProperty("firstProperty/secondProperty")]
private SerializedProperty nested; // Will first look for a property called 'firstProperty' and then 'secondProperty' on the first property.
Applies to methods and properties
Timed will automatically put your entire method inside a stopwatch and log at the end of the method how long it took to execute in both milliseconds and ticks.
Usage:
[Timed]
private void MyMethod()
{
// TODO: Code
// Will log 'MyMethod took <ms> milliseconds (<ticks> ticks)'
}
Applies to methods
Mark in profiler will put your method inside a big Profiler.BeginSample() and Profiler.EndSample to make it show up in the Unity profiler.
Usage:
[MarkInProfiler]
private void MyMethod() // This will show up in the Unity profiler.
{
// TODO: Code
}
Applies to serialized fields
Get component will automatically get your components for you in editor time on prefabs and scene objects. It does not fetch them at runtime! A target can be specified to get components in children or the parent.
Usage:
[SerializeField]
[GetComponent]
private MyComponent myComponent; // Will call GetComponent(s)
[SerializeField]
[GetComponent(target = GetComponentTarget.Parent)]
private MyComponent myParentComponent; // Will call GetComponent(s)InParent
[SerializeField]
[GetComponent(target = GetComponentTarget.Children)]
private MyComponent myChildrenComponent; // Will call GetComponent(s)InChildren
MIT - Basically do whatever, I'm just not liable if it causes any damages.