Skip to content

Commit f59aa2e

Browse files
committed
Fix line endings and eol newline
1 parent bb29ba0 commit f59aa2e

12 files changed

+77
-9
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[*]
2+
insert_final_newline = true
3+
end_of_line = lf

Assets/Editor/PropertyDrawers/LabelAsDrawer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2323
EditorGUI.PropertyField(position, property, label);
2424
}
2525
}
26-
}
26+
}

Assets/Editor/PropertyDrawers/PrefabPropertyDrawer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
2323

2424
property.objectReferenceValue = EditorGUI.ObjectField(position, label.text, property.objectReferenceValue, fieldType, false);
2525
}
26-
}
26+
}

Assets/Editor/PropertyDrawers/UneditableDrawer.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ public override void OnGUI(Rect position, SerializedProperty property, GUIConten
1616
EditorGUI.PropertyField(position, property, label, true);
1717
EditorGUI.EndDisabledGroup();
1818
}
19-
}
19+
}

Assets/Scripts/Attributes/LabelAsAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@ public class LabelAsAttribute : PropertyAttribute
66
{
77
public readonly string Text;
88
public LabelAsAttribute(string text) => Text = text;
9-
}
9+
}

Assets/Scripts/Attributes/PrefabOnlyAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
using UnityEngine;
33

44
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
5-
public class PrefabOnlyAttribute : PropertyAttribute{ public PrefabOnlyAttribute(){} }
5+
public class PrefabOnlyAttribute : PropertyAttribute{}

Assets/Scripts/Attributes/UneditableAttribute.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
using UnityEngine;
33

44
[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
5-
public class UneditableAttribute : PropertyAttribute{}
5+
public class UneditableAttribute : PropertyAttribute{}

Assets/Scripts/Attributes/readme.md

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
2+
3+
# Attributes
4+
5+
You may be familiar with the use of [SerializeField] for exposing variables in the unity editor inspector as opposed to making fields public. This is only one of many useful attributes you can attach to a field ("Range" may be another one of interest?)
6+
7+
Unity allows us as developers to greatly extend the editor with custom editor scripts (CustomEditor and PropertyDrawer), With that, they also allow us to define custom attributes, and add specifications for how fields marked with said attributes are drawn in the editor.
8+
9+
Currently, we have the following attributes which modifies how the fields marked with them are drawn:
10+
11+
----
12+
13+
## PrefabOnly
14+
15+
Can be put on any `GameObject` field or component fields (i.e. fields of classes inheriting from the base class `Component` - i.e. all built-in components, as well as custom `MonoBehaviour`)
16+
17+
The attribute disallows references to in-scene gameobjects/components
18+
19+
Example:
20+
21+
```cs
22+
[PrefabOnly, SerializeField]
23+
private GameObject somePrefab;
24+
25+
// Note: usage of this is scary, and should only be used in a "read-only" context or in
26+
// editor-related contexts. Changing it would change the prefab's Rigidbody.
27+
[PrefabOnly]
28+
public Rigidbody someRigidbodyOfAPrefab;
29+
```
30+
31+
## Uneditable
32+
33+
Can be put on any field (though only useful on serialized fields - as others aren't editable through the editor anyways)
34+
35+
The attribute allows insight in the field, but disallows changing the field from editor. Can be useful for displaying debug info, or simply for disallowing edits while keeping the field serialized.
36+
37+
Example:
38+
39+
```cs
40+
[Uneditable, SerializeField]
41+
private GameObject someObjectReferenceThatCannotBeChangedInEditor;
42+
43+
[Uneditable]
44+
public float someFloatSetInternally;
45+
```
46+
47+
## LabelAs
48+
49+
Can be put on any field (though only useful on serialized fields - as others aren't labelled in the editor anyways)
50+
51+
The attribute allows "rebranding" a variable as it is shown in the editor.
52+
53+
Example:
54+
55+
```cs
56+
[LabelAs("Some Name That Makes Sense In Editor Context"), SerializeField]
57+
private string someVariableNameThatMakesSenseInScriptingContext;
58+
```

Assets/Scripts/Attributes/readme.md.meta

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Scripts/Auction/BiddingRound.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ public BiddingRound(Item[] items)
1414
tokens = new int[items.Length];
1515
players = new PlayerInventory[items.Length];
1616
}
17-
}
17+
}

Assets/Scripts/Auction/PlayerInventory.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ public void PerformTransaction(Item item, int cost)
1313
items.Add(item);
1414
tokens -= cost;
1515
}
16-
}
16+
}

Assets/Scripts/Extensions/CollectionExtensions.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,4 @@ public static class ArrayExtensions
5353
public static void Resize<T>(this T[] arr, int n) => System.Array.Resize(ref arr, n);
5454

5555
}
56-
}
56+
}

0 commit comments

Comments
 (0)