forked from Facepunch/Rust.Community
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCommunityEntity.UI.Toggle.cs
More file actions
37 lines (29 loc) · 891 Bytes
/
CommunityEntity.UI.Toggle.cs
File metadata and controls
37 lines (29 loc) · 891 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#if CLIENT
using UnityEngine;
// Toggle UI panels based on what the client is showing (instead of parenting them to GUI prefabs that could be destroyed)
public partial class CommunityEntity
{
public void OnGuiChanged( Panel panelType, bool open )
{
// Could occur if calling OnGuiChanged as the client is disconnecting
if (this == null || transform == null) return;
var panel = transform.Find( panelType.ToString() );
// Also check gameObject in case the panel was destroyed
if (panel == null || panel.gameObject == null)
{
Debug.LogWarning( $"CommunityEntity Panel {panelType} not found" );
return;
}
panel.gameObject.SetActive( open );
}
public enum Panel
{
Crafting,
Contacts,
TechTree,
Inventory,
Clans,
Map,
}
}
#endif