public override void OnSceneSet(Scene scene) { if (scene != null) { if (ReceiveFixedUpdates) { var physicsWorld = scene.GetComponent<PhysicsWorld>(); if (physicsWorld == null) throw new InvalidOperationException("Scene must have PhysicsWorld component in order to receive FixedUpdates"); physicsPreStepSubscription = physicsWorld.SubscribeToPhysicsPreStep(OnFixedUpdate); } if (ReceiveFixedPostUpdates) { var physicsWorld = scene.GetComponent<PhysicsWorld>(); if (physicsWorld == null) throw new InvalidOperationException("Scene must have PhysicsWorld component in order to receive FixedUpdates"); physicsPostStepSubscription = physicsWorld.SubscribeToPhysicsPostStep(OnFixedPostUpdate); } if (ReceivePostUpdates) { scenePostUpdateSubscription = scene.SubscribeToScenePostUpdate(OnPostUpdate); } } else { physicsPreStepSubscription?.Unsubscribe(); physicsPostStepSubscription?.Unsubscribe(); scenePostUpdateSubscription?.Unsubscribe(); } }
public void Hide() { if (text == null) return; subscription.Unsubscribe(); application.UI.Root.RemoveChild(text, 0); text = null; subscription = null; }
public void Show(Color color, int fontSize = 18) { if (text != null) return; text = new Text(); text.SetColor(color); text.VerticalAlignment = VerticalAlignment.Top; text.HorizontalAlignment = HorizontalAlignment.Right; text.TextAlignment = HorizontalAlignment.Right; text.SetFont(CoreAssets.Fonts.AnonymousPro, fontSize); application.UI.Root.AddChild(text); subscription = application.Engine.SubscribeToPostUpdate(OnPostUpdate); }
public void Show() { if (text != null) return; var ui = application.UI; var root = ui.Root; var cache = application.ResourceCache; text = new Text(); text.VerticalAlignment = VerticalAlignment.Top; text.HorizontalAlignment = HorizontalAlignment.Right; text.TextAlignment = HorizontalAlignment.Right; text.SetFont(cache.GetFont("Fonts/Anonymous Pro.ttf"), 18); root.AddChild(text); subscription = application.Engine.SubscribeToPostUpdate(OnPostUpdate); }