Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private static Transform UIRoot; // could probably skip caching this...
- private static MonoBehaviour StatusMessage; // The status message script
- private static MethodInfo ShowMessage;
- private static void ShowStatusMessageInDesigner(string Message, float Time = 5.0f)
- { // you know, it'd be nice if Service Provider's ShowStatusMessage worked in the designer ;) <------ message to Nathan... I don't think he saw it
- if (!UIRoot || !StatusMessage)
- { // basically, if we don't have both the UI root and status message object, get them both...
- UIRoot = ServiceProvider.Instance.UserInterface.UIRootObject.transform;// this may also be acheived with GameObject.Find("UI Root");
- GameObject StatusMessageGameObject = UIRoot.FindChild("StatusMessage").gameObject;
- MonoBehaviour[] Scripts = StatusMessageGameObject.GetComponents<MonoBehaviour>();
- for (int i = 0; i < Scripts.Length; i++)
- {
- if (Scripts[i].GetType().Name == "StatusMessageScript")
- {
- StatusMessage = Scripts[i];
- ShowMessage = StatusMessage.GetType().GetMethod("ShowMessage");
- break;
- }
- }
- }
- ShowMessage.Invoke(StatusMessage, new object[] { Message, Time });
- }
Add Comment
Please, Sign In to add comment