Skip to content

Commit 5b1f30b

Browse files
authored
Update README.md
1 parent bfbeeae commit 5b1f30b

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,32 @@
11
# Configs
2-
Scriptable Object Configs
2+
Scriptable Object Configs for data storage
3+
4+
## Usage
5+
6+
Writing config:
7+
8+
```csharp
9+
[CreateAssetMenu(menuName = "Game/Configs/Player")]
10+
public class PlayerConfig : Config
11+
{
12+
[SerializeField] private float _startPlayerHealth = 100f;
13+
14+
public float StartPlayerHealth => _startPlayerHealth;
15+
}
16+
```
17+
18+
Now you need to create an asset and put it in Resources folder
19+
20+
Receive data:
21+
22+
```csharp
23+
public class Player : MonoBehaviour
24+
{
25+
private float _health = 0f;
26+
27+
private void Awake()
28+
{
29+
_health = Config.Get<PlayerConfig>().StartPlayerHealth;
30+
}
31+
}
32+
```

0 commit comments

Comments
 (0)