I want my menu to be displayed after death, but I can’t figure out how to destroy the statistics and resraun menu that happens after death.
I would be very grateful if someone tells me how to implement this!
My code:
I would be very grateful if someone tells me how to implement this!
My code:
private void OnEntityDeath(BasePlayer player)
{
var filledtemplate = template;
timer.Once(1f, () =>
{
CuiHelper.DestroyUi(player, "Hello");
CuiHelper.AddUi(player, filledtemplate);
});
}public static string template = @"
[
{
""name"": ""Hello"",
""parent"": ""Hud"",
""components"": [
{
""type"": ""UnityEngine.UI.RawImage"",
""color"": ""0 1 1 1"",
""url"": ""http://www.rigormortis.be/wp-content/uploads/rust-icon-512.png""
},
{
""type"": ""RectTransform"",
""anchormin"": ""0.398 0.411"",
""anchormax"": ""0.554 0.689""
},
{
""type"": ""NeedsCursor"",
}
]
},
{
""name"": ""4593-8194-0a6b"",
""parent"": ""Hello"",
""components"": [
{
""type"": ""UnityEngine.UI.Button"",
""command"": ""guitest.close"",
""close"": """",
""color"": ""0.78 0 0 1""
},
{
""type"": ""RectTransform"",
""anchormin"": ""0.85 0.85"",
""anchormax"": ""1 1""
}
]
},
{
""name"": ""c8fd-cb3d-1350"",
""parent"": ""4593-8194-0a6b"",
""components"": [
{
""type"": ""UnityEngine.UI.Text"",
""color"": ""0 0 0.78 0.78"",
""fontSize"": 14,
""align"": ""MiddleCenter"",
""text"": ""Close""
},
{
""type"": ""RectTransform"",
""anchormin"": ""0 0"",
""anchormax"": ""1 1""
}
]
},
{
""name"": ""ddd5-0e72-feb8"",
""parent"": ""Hello"",
""components"": [
{
""type"": ""UnityEngine.UI.Button"",
""command"": ""guitest.play"",
""close"": """",
""color"": ""0.59 0.78 0 1""
},
{
""type"": ""RectTransform"",
""anchormin"": ""0.27 0.355"",
""anchormax"": ""0.77 0.605""
}
]
},
{
""name"": ""53e8-17ff-ce34"",
""parent"": ""ddd5-0e72-feb8"",
""components"": [
{
""type"": ""UnityEngine.UI.Text"",
""color"": ""1 1 1 1"",
""fontSize"": 14,
""align"": ""MiddleCenter"",
""text"": ""Play""
},
{
""type"": ""RectTransform"",
""anchormin"": ""0 0"",
""anchormax"": ""1 1""
}
]
}
]
";