public override void Start() { var cache = GetSubsystem<ResourceCache>(); var graphics = GetSubsystem<Graphics>(); var ui = GetSubsystem<UI>(); graphics.SetWindowIcon(cache.Get<Image>("Textures/UrhoIcon.png")); graphics.WindowTitle = "Atomic Game Engine Feature Example"; // Subscribe to Esc key: SubscribeToEvent<KeyDownEvent>(e => { if (e.Key == Constants.KEY_ESCAPE) BackToSelector(); }); // Say Hello var layout = new UILayout(); layout.Rect = UIView.Rect; layout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_CENTER; layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_CENTER; var fontDesc = new UIFontDescription(); fontDesc.Id = "Vera"; fontDesc.Size = 24; var label = new UITextField(); label.FontDescription = fontDesc; label.Text = "Hello World, from the Atomic Game Engine"; layout.AddChild(label); UIView.AddChild(layout); }
public UIItem(Layer owner, UILayout layout, int depth, bool multiclick = false) { Layer = owner; this.multiClick = multiclick; this._Depth = depth; this.Layout = layout; UIRenderer.Add(owner, this); Layout.Init(this); }
void InitWindow() { var layout = new UILayout(); layout.Axis = UI_AXIS.UI_AXIS_Y; var checkBox = new UICheckBox(); checkBox.Id = "Checkbox"; layout.AddChild(checkBox); var button = new UIButton(); button.Text = "Button"; button.Id = "Button"; layout.AddChild(button); var edit = new UIEditField(); layout.AddChild(edit); edit.Id = "EditField"; window = new UIWindow(); window.Settings = UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_TITLEBAR | UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_CLOSE_BUTTON; window.Text = "Hello Atomic GUI!"; window.AddChild(layout); window.ResizeToFitContent(); UIView.AddChild(window); window.Center(); SubscribeToEvent <WidgetEvent>(window, e => { if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { var target = e.Target; if (target != null) { window.Text = $"Hello: {target.Id}"; } } }); SubscribeToEvent <WidgetDeletedEvent>(window, e => { BackToSelector(); }); }
public virtual bool Push(object o = null, UILayout l = null, Vector2 size = default(Vector2)) { UIRect uiRect = new UIRect(); uiRect.prefab = l; uiRect.data = o; uiRect.rect = new Rect(end, size); uiRects.Add(uiRect); PlaceNextRect(uiRect); SetDirty(); return(true); }
void InitWindow() { var layout = new UILayout(); layout.Axis = UI_AXIS.UI_AXIS_Y; var checkBox = new UICheckBox(); checkBox.Id = "Checkbox"; layout.AddChild(checkBox); var button = new UIButton(); button.Text = "Button"; button.Id = "Button"; layout.AddChild(button); var edit = new UIEditField(); layout.AddChild(edit); edit.Id = "EditField"; window = new UIWindow(); window.Settings = UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_TITLEBAR | UI_WINDOW_SETTINGS.UI_WINDOW_SETTINGS_CLOSE_BUTTON; window.Text = "Hello Atomic GUI!"; window.AddChild(layout); window.ResizeToFitContent(); UIView.AddChild(window); window.Center(); SubscribeToEvent<WidgetEvent>(window, e => { if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { var target = e.Target; if (target != null) { window.Text = $"Hello: {target.Id}"; } } }); SubscribeToEvent<WidgetDeletedEvent>(window, e => { BackToSelector(); }); }
void frameReposition() { for (int i = 0; i < layouts.Count; ++i) { UILayout c = layouts[i]; c.mHeight = mHeight; c.mWidth = mWidth; Vector3 p = c.transform.localPosition; p.x = 0; p.y = 0; p.z = 0; c.transform.localPosition = p; } }
public IConvertView GetConvertView(int position, IConvertView convertView) { TypeListCell cell = convertView as TypeListCell; if (cell == null) { cell = new TypeListCell(); cell.FontSize = 25; cell.TextComponent.alignment = TextAnchor.MiddleCenter; UILayout.AddUnderLine(cell.GetRectTransform(), Screen.height / 720f, Color.white); } cell.Text = "Part" + (position + 1) + "." + Types[position]; return(cell); }
void LoadCell(int index) { GameObject obj = PoolManager.AddChild(scrollRect.content, uiRects[index].prefab.gameObject); UILayout instance = obj.GetComponent <UILayout>(); instance.RectTransform.pivot = new Vector2(0, 1); UIRect uiRect = uiRects[index]; uiRect.instance = instance; instance.RectTransform.anchoredPosition = uiRect.rect.position.Invert(1); instance.RectTransform.sizeDelta = uiRect.rect.size; instance.Parent = this; instance.SetData(uiRect.data); }
public SampleSelector() { sampleRef = null; var rootLayout = new UILayout(); rootLayout.Axis = UI_AXIS.UI_AXIS_Y; rootLayout.Rect = UIView.Rect; UIView.AddChild(rootLayout); SubscribeToEvent <KeyDownEvent>(e => { if (e.Key == Constants.KEY_ESCAPE) { GetSubsystem <Engine>().Exit(); } }); #if ATOMIC_DESKTOP || ATOMIC_MOBILE var sampleTypes = typeof(Sample).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Sample)) && t != typeof(Sample)).ToArray(); foreach (var sample in sampleTypes) { var button = new UIButton(); button.Text = sample.Name; button.SubscribeToEvent <WidgetEvent>(button, e => { // We're only interested in clicks if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { return; } // set the event as handled, as the UI is about to go away e.Handled = true; // Goodbye UI UIView.RemoveChild(rootLayout); sampleRef = (Sample)Activator.CreateInstance(sample); sampleRef.Start(); UnsubscribeFromEvent <KeyDownEvent>(); }); rootLayout.AddChild(button); } #endif }
/// <summary> /// Tween the value. /// </summary> protected override void OnUpdate (float factor, bool isFinished) { value = Mathf.RoundToInt(from * (1f - factor) + to * factor); if (updateTable) { if (mLayout == null) { mLayout = NGUITools.FindInParents<UILayout>(gameObject); if (mLayout == null) { updateTable = false; return; } } mLayout.repositionNow = true; } }
void Start() { mScroll = GetComponent <ScrollRect>(); mLayout = Util.Get <UILayout>(transform, "Viewport/Content"); mLayout.onCreate = OnCreateRender; mLayout.onUpdate = OnUpdateRender; mLayout.ItemRenderer = Util.Child(transform, "Viewport/Content/Render"); mRenders = new Dictionary <GameObject, Text>(); mList = new List <string>(); mList.Add("-"); mLayout.DataCount = mList.Count; mLayout.InvalidateData(); }
private void ReLayoutUIComponent(UILayout ui_layout, Button[] UIbuttons, int faceDir) { if (ShopObject != null) { switch (ui_layout) { case UILayout.EqualSpace: ToEqualSpaceLayout(ShopObject.transform, UIbuttons, item_radius); break; case UILayout.SpecificSpace: ToSpecificLayout(ShopObject.transform, UIbuttons, faceDir, item_radius, item_space); break; } } }
/// <summary> /// Tween the value. /// </summary> protected override void OnUpdate(float factor, bool isFinished) { value = from * (1f - factor) + to * factor; if (updateTable) { if (mLayout == null) { mLayout = NGUITools.FindInParents <UILayout>(gameObject); if (mLayout == null) { updateTable = false; return; } } mLayout.repositionNow = true; } }
public override void Start() { Scene scene = AtomicNET.GetSubsystem <Player>().LoadScene("Scenes/Scene.scene"); Vector <Camera> cameras = new Vector <Camera>(); scene.GetComponents(cameras, true); Graphics graphics = GetSubsystem <Graphics>(); Renderer renderer = GetSubsystem <Renderer>(); int numCameras = cameras.Count; views = new UIView[numCameras]; renderer.SetNumViewports((uint)numCameras); int viewportWidth = graphics.Width / numCameras; for (int i = 0; i < numCameras; ++i) { Viewport viewport = new Viewport(scene, cameras[i]); viewport.Rect = new IntRect( i * viewportWidth, 0, (i + 1) * viewportWidth, graphics.Height); renderer.SetViewport((uint)i, viewport); UIView view = new UIView(); UILayout layout = new UILayout() { // See for a layout cheatsheet: https://github.com/AtomicGameEngine/AtomicGameEngine/wiki/Turbobadger-Layout-Cheat-Sheet // Specifies which y position widgets in a AXIS_X layout should have, or which x position widgets in a AXIS_Y layout should have. LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_RIGHT_BOTTOM, // Specifies how widgets should be moved horizontally in a AXIS_X layout(or vertically in a AXIS_Y layout) if there is extra space available. LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM, Rect = viewport.Rect }; layout.AddChild(new UITextField() { FontDescription = fontDescription, Text = cameras[i].Node.Name }); view.AddChild(layout); views[i] = view; } }
public SampleSelector() { sampleRef = null; var rootLayout = new UILayout(); rootLayout.Axis = UI_AXIS.UI_AXIS_Y; rootLayout.Rect = UIView.Rect; UIView.AddChild(rootLayout); SubscribeToEvent<KeyDownEvent>(e => { if (e.Key == Constants.KEY_ESCAPE) GetSubsystem<Engine>().Exit(); }); #if ATOMIC_DESKTOP || ATOMIC_MOBILE var sampleTypes = typeof(Sample).Assembly.GetTypes().Where(t => t.IsSubclassOf(typeof(Sample)) && t != typeof(Sample) ).ToArray(); foreach (var sample in sampleTypes) { var button = new UIButton(); button.Text = sample.Name; button.SubscribeToEvent<WidgetEvent>( button, e => { // We're only interested in clicks if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) return; // set the event as handled, as the UI is about to go away e.Handled = true; // Goodbye UI UIView.RemoveChild(rootLayout); sampleRef = (Sample) Activator.CreateInstance(sample); sampleRef.Start(); UnsubscribeFromEvent<KeyDownEvent>(); }); rootLayout.AddChild(button); } #endif }
private void SetLayout(Transform t, UILayout layoutType) { var layoutGroup = t.GetComponent <HorizontalOrVerticalLayoutGroup>(); LayoutData newLayoutData = new LayoutData(layoutGroup); switch (layoutType) { case UILayout.Vertical: newLayoutData.LayoutType = UILayout.Vertical; break; case UILayout.Horizontal: newLayoutData.LayoutType = UILayout.Horizontal; break; } CreateLayout(t, newLayoutData); }
/// <summary> /// /// </summary> protected virtual void Awake() { m_Go = gameObject; // /*#if UNITY_EDITOR_WIN * m_Scanner=new BluetoothScanner(this); * m_BtnStart.onClick.AddListener(()=>{ * m_Scanner.deviceList.Add(new BluetoothScanner.DeviceInfo{name="Virtual Device",address="00:00:00:00:00"}); * OnDeviceListChanged(); * } * ); #else*/ m_Scanner = new BluetoothScanner(this); //m_BtnCnnt.onClick.AddListener(OnClick_m_BtnCnnt); m_BtnStart.onClick.AddListener(m_Scanner.StartScan); m_BtnStop.onClick.AddListener(m_Scanner.StopScan); //#endif // if (m_LayoutCnns != null) { m_UILayout = m_LayoutCnns.GetComponent <UILayout>(); } if (asMain) { if (main == null) { main = this; } else if (main != this) { Log.e("BluetoothScannerGUI", "The main instance exists."); } } if (!showOnAwake) { m_Go.SetActive(m_IsVisible = false); } if (debugMode) { AddRequest(OpenDevice); } }
public override void Start() { var cache = GetSubsystem <ResourceCache>(); var graphics = GetSubsystem <Graphics>(); var ui = GetSubsystem <UI>(); graphics.SetWindowIcon(cache.Get <Image>("Textures/UrhoIcon.png")); graphics.WindowTitle = "Atomic Game Engine Feature Example"; // Subscribe to Esc key: SubscribeToEvent <KeyDownEvent>(e => { if (e.Key == Constants.KEY_ESCAPE) { BackToSelector(); } }); // Say Hello var layout = new UILayout(); layout.Rect = UIView.Rect; layout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_CENTER; layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_CENTER; var fontDesc = new UIFontDescription(); fontDesc.Id = "Vera"; fontDesc.Size = 24; var label = new UITextField(); label.FontDescription = fontDesc; label.Text = "Hello World, from the Atomic Game Engine"; layout.AddChild(label); UIView.AddChild(layout); }
protected void SimpleCreateInstructions(string text = "") { var layout = new UILayout(); layout.Rect = UIView.Rect; layout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_RIGHT_BOTTOM; layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM; var fontDesc = new UIFontDescription(); fontDesc.Id = "Vera"; fontDesc.Size = 18; label = new UIEditField(); label.FontDescription = fontDesc; label.ReadOnly = true; label.Multiline = true; label.AdaptToContentSize = true; label.Text = text; layout.AddChild(label); UIView.AddChild(layout); }
public virtual void AddView(IUIView view, UILayout layout) { if (view == null) { return; } Transform t = view.Transform; if (t == null) { return; } if (t.parent == transform) { layout?.Invoke(view.RectTransform); return; } view.Owner.layer = gameObject.layer; t.SetParent(transform, false); layout?.Invoke(view.RectTransform); }
void CreateUI() { var cache = GetSubsystem <ResourceCache>(); var layout = new UILayout() { Axis = UI_AXIS.UI_AXIS_Y }; layout.Rect = UIView.Rect; UIView.AddChild(layout); // Create a scene which will not be actually rendered, but is used to hold SoundSource components while they play sounds scene = new Scene(); // Create buttons for playing back sounds foreach (var item in sounds) { var button = new UIButton(); layout.AddChild(button); button.Text = item.Key; button.SubscribeToEvent <WidgetEvent>(button, e => { if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { // Get the sound resource Sound sound = cache.Get <Sound>(item.Value); if (sound != null) { // Create a scene node with a SoundSource component for playing the sound. The SoundSource component plays // non-positional audio, so its 3D position in the scene does not matter. For positional sounds the // SoundSource3D component would be used instead Node soundNode = scene.CreateChild("Sound"); SoundSource soundSource = soundNode.CreateComponent <SoundSource>(); soundSource.Play(sound); // In case we also play music, set the sound volume below maximum so that we don't clip the output soundSource.Gain = 0.75f; // Set the sound component to automatically remove its scene node from the scene when the sound is done playing } } }); } // Create buttons for playing/stopping music var playMusicButton = new UIButton(); layout.AddChild(playMusicButton); playMusicButton.Text = "Play Music"; playMusicButton.SubscribeToEvent <WidgetEvent> (playMusicButton, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { return; } if (scene.GetChild("Music", false) != null) { return; } var music = cache.Get <Sound>("Music/StoryTime.ogg"); music.Looped = true; Node musicNode = scene.CreateChild("Music"); SoundSource musicSource = musicNode.CreateComponent <SoundSource> (); // Set the sound type to music so that master volume control works correctly musicSource.SetSoundType("Music"); musicSource.Play(music); }); var audio = GetSubsystem <Audio>(); // FIXME: Removing the music node is not stopping music var stopMusicButton = new UIButton(); layout.AddChild(stopMusicButton); stopMusicButton.Text = "Stop Music"; stopMusicButton.SubscribeToEvent <WidgetEvent>(stopMusicButton, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { return; } scene.RemoveChild(scene.GetChild("Music", false)); }); // Effect Volume Slider var slider = new UISlider(); layout.AddChild(slider); slider.SetLimits(0, 1); slider.Text = "Sound Volume"; slider.SubscribeToEvent <WidgetEvent>(slider, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED) { return; } Log.Info($"Setting Effects to {slider.Value}"); audio.SetMasterGain("Effect", slider.Value); }); // Music Volume Slider var slider2 = new UISlider(); layout.AddChild(slider2); slider2.SetLimits(0, 1); slider2.Text = "Music Volume"; slider2.SubscribeToEvent <WidgetEvent>(slider2, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED) { return; } Log.Info($"Setting Music to {slider2.Value}"); audio.SetMasterGain("Music", slider2.Value); }); }
protected override void OnLoad(EventArgs e) { ICMSMasterPage master = Page.Master as ICMSMasterPage; if ((master != null) && (master.FooterContainer != null)) { master.FooterContainer.Visible = false; } ScriptHelper.RegisterScriptFile(Page, "Controls/CodePreview.js"); imgProgress.ImageUrl = GetImageUrl("/Design/Preloaders/preload16.gif"); paneToolbar = new UILayoutPane(); if (!DialogMode) { paneFooter.Visible = false; } previewValue = GetPreviewStateFromCookies(CookiesPreviewStateName); if (CMSContext.EditedObject == null) { previewValue = 0; } // Change preview state handling string args = Request["__EVENTARGUMENT"]; string target = Request["__EVENTTARGET"]; if (target == btnHidden.UniqueID) { switch (args) { case "vertical": previewValue = 1; break; case "horizontal": previewValue = 2; break; case "split": previewValue = (previewValue == 0) ? 1 : 0; if (previewValue != 0) { RegisterFullScreen(); PreviewInitialized = true; paneToolbar.Values.Add(new UILayoutValue("PreviewInitialized", true)); } break; } SetPreviewStateToCookies(CookiesPreviewStateName, previewValue); paneToolbar.Values.Add(new UILayoutValue("SetControls", true)); } UILayout subLayout = paneContentMain.FindControl("layoutElem") as UILayout; panePreview = subLayout.FindControl("panePreview") as UILayoutPane; // Pane toolbar paneToolbar.ID = "paneToolbar"; paneToolbar.Direction = PaneDirectionEnum.North; paneToolbar.ControlPath = "~/CMSModules/AdminControls/Controls/Preview/PreviewNavigationButtons.ascx"; paneToolbar.Resizable = false; paneToolbar.Slidable = false; paneToolbar.RenderAs = HtmlTextWriterTag.Div; paneToolbar.SpacingOpen = 0; if (AddTitleToToolbar && (previewValue != 0)) { // Add toolbar padding to show title paneToolbar.PaneClass = "PreviewTitlePadding"; } paneToolbar.Values.Add(new UILayoutValue("PreviewURLSuffix", PreviewURLSuffix)); paneToolbar.Values.Add(new UILayoutValue("CookiesPreviewStateName", CookiesPreviewStateName)); paneToolbar.Values.Add(new UILayoutValue("PreviewObjectName", PreviewObjectName)); paneToolbar.Values.Add(new UILayoutValue("DefaultAliasPath", DefaultAliasPath)); paneToolbar.Values.Add(new UILayoutValue("DialogMode", DialogMode)); paneToolbar.Values.Add(new UILayoutValue("IgnoreSessionValues", IgnoreSessionValues)); paneToolbar.Values.Add(new UILayoutValue("DefaultPreviewPath", DefaultPreviewPath)); paneContentMain.Visible = true; subLayout.StopProcessing = false; paneFooter.SpacingOpen = 0; paneFooter.Values.Add(new UILayoutValue("ShowSaveButtons", ShowSaveButtons)); // Check if inner control denied displaying preview CMSPreviewControl pw = paneContent.UserControl as CMSPreviewControl; if (pw != null) { if (!pw.ShowPreview) { previewValue = 0; } } switch (previewValue) { // No split case 0: subLayout.StopProcessing = true; paneContentMain.Visible = false; paneContent.Direction = PaneDirectionEnum.Center; break; // Vertical case 1: int additionalSize = AddTitleToToolbar ? 38 : 0; paneContent.SpacingOpen = 14; paneContent.SpacingClosed = 14; paneContent.ResizerClass = "TransformationVerticalResizer"; paneToolbar.Values.Add(new UILayoutValue("ShowPanelSeparator", ShowPanelSeparator)); paneToolbar.SpacingOpen = 0; paneToolbar.Size = ShowPanelSeparator ? (41 + additionalSize).ToString() : (35 + additionalSize).ToString(); layoutElem.Controls.Add(paneToolbar); layoutElem.Panes.Add(paneToolbar); paneContent.Direction = PaneDirectionEnum.West; break; // Horizontal case 2: paneToolbar.PaneClass = "HorizontalToolbar"; paneContent.ResizerClass = "GrayResizer"; paneToolbar.Size = "30"; subLayout.Controls.Add(paneToolbar); subLayout.Panes.Add(paneToolbar); break; } if ((previewValue != 0) && !RequestHelper.IsPostBack()) { RegisterFullScreen(); } base.OnLoad(e); }
protected Toast(ToastView view, IUIViewGroup viewGroup, string text, float duration, UILayout layout) : this(view, viewGroup, text, duration, layout, null) { }
public static Toast Show(IUIViewGroup viewGroup, string text, float duration, UILayout layout, Action callback) { return(Show(ViewName, viewGroup, text, duration, layout, callback)); }
/// <summary> /// Drop the item onto the specified object. /// </summary> protected virtual void OnDragDropRelease (GameObject surface) { if (!cloneOnDrag) { mTouchID = int.MinValue; // Re-enable the collider if (mButton != null) mButton.isEnabled = true; else if (mCollider != null) mCollider.enabled = true; // Is there a droppable container? UIDragDropContainer container = surface ? NGUITools.FindInParents<UIDragDropContainer>(surface) : null; if (container != null) { // Container found -- parent this object to the container mTrans.parent = (container.reparentTarget != null) ? container.reparentTarget : container.transform; Vector3 pos = mTrans.localPosition; pos.z = 0f; mTrans.localPosition = pos; } else { // No valid container under the mouse -- revert the item's parent mTrans.parent = mParent; } // Update the grid and table references mParent = mTrans.parent; mGrid = NGUITools.FindInParents<UIGrid>(mParent); mLayout = NGUITools.FindInParents<UILayout>(mParent); // Re-enable the drag scroll view script if (mDragScrollView != null) mDragScrollView.enabled = true; // Notify the widgets that the parent has changed NGUITools.MarkParentAsChanged(gameObject); if (mLayout != null) mLayout.repositionNow = true; if (mGrid != null) mGrid.repositionNow = true; } else NGUITools.Destroy(gameObject); }
/// <summary> /// Perform any logic related to starting the drag & drop operation. /// </summary> protected virtual void OnDragDropStart () { // Automatically disable the scroll view if (mDragScrollView != null) mDragScrollView.enabled = false; // Disable the collider so that it doesn't intercept events if (mButton != null) mButton.isEnabled = false; else if (mCollider != null) mCollider.enabled = false; mTouchID = UICamera.currentTouchID; mParent = mTrans.parent; mRoot = NGUITools.FindInParents<UIRoot>(mParent); mGrid = NGUITools.FindInParents<UIGrid>(mParent); mLayout = NGUITools.FindInParents<UILayout>(mParent); // Re-parent the item if (UIDragDropRoot.root != null) mTrans.parent = UIDragDropRoot.root; Vector3 pos = mTrans.localPosition; pos.z = 0f; mTrans.localPosition = pos; TweenPosition tp = GetComponent<TweenPosition>(); if (tp != null) tp.enabled = false; SpringPosition sp = GetComponent<SpringPosition>(); if (sp != null) sp.enabled = false; // Notify the widgets that the parent has changed NGUITools.MarkParentAsChanged(gameObject); if (mLayout != null) mLayout.repositionNow = true; if (mGrid != null) mGrid.repositionNow = true; }
//重新布局/ void reposition() { if (!mReposition) { return; } mParent = transform.parent.GetComponent <UILayout>(); if (mParent == null) { //根节点取屏幕大小/ if (disableScale) { mWidth = baseWidth; mHeight = baseHeight; } else { Vector2 sz = getViewSize(); mWidth = (int)sz.x; mHeight = (int)sz.y; } } if (null != backGround) { //拉伸layout背景/ backGround.width = mWidth; backGround.height = mHeight; } //添加子layout到layout管理列表,并设置重布局标志/ layouts.Clear(); Transform t = transform; for (int i = 0, max = t.childCount; i < max; ++i) { UILayout ly = t.GetChild(i).GetComponent <UILayout>(); if (ly == null) { continue; } ly.repositionNow = true; layouts.Add(ly); } //设置子layout大小位置/ switch (mOrientation) { case OrientationType.Horizontal: horizontalReposition(); break; case OrientationType.Vertical: verticalReposition(); break; case OrientationType.Frame: frameReposition(); break; case OrientationType.Table: tableReposition(); break; } //设置控件大小/ resizeWidget(); //设置控件位置/ repositionWidget(); #if !UNITY_EDITOR mReposition = false; #endif }
public static GameObject[] GenerateUI(GameObject prefab, Transform parent, int amount, UILayout layout) { var GOS = new GameObject[amount].InitEXT(() => GameObject.Instantiate(prefab, parent)); var rectTFs = GOS.Map((x) => x.GetComponent <RectTransform>()); if (layout == UILayout.Vertical) { UIPositioner.PositionVertically(parent, rectTFs); } else if (layout == UILayout.Horizontal) { UIPositioner.PositionHorizontally(parent, rectTFs); } return(GOS); }
public static T[] GenerateUIFixedSize <T>(T prefab, Transform parent, int amount, UILayout layout, float sizePerElement) where T : Component { var GOS = new T[amount].InitEXT(() => GameObject.Instantiate(prefab, parent)); var rectTFs = GOS.Map((x) => x.GetComponent <RectTransform>()); if (layout == UILayout.Vertical) { UIPositioner.PositionPixelwiseVertically(parent, rectTFs, sizePerElement); } else if (layout == UILayout.Horizontal) { UIPositioner.PositionHorizontally(parent, rectTFs); } return(GOS); }
public UILabel(Layer owner, UILayout layout, int depth, float size, string text, TextAlignment alignment = TextAlignment.Left) : this(owner, layout, depth, size, Color.White, text, alignment) { }
public static Toast Show(IUIViewGroup viewGroup, string text, float duration, UILayout layout) { return(Show(ViewName, viewGroup, text, duration, layout, null)); }
void CreateUI() { var cache = GetSubsystem<ResourceCache>(); var layout = new UILayout() { Axis = UI_AXIS.UI_AXIS_Y }; layout.Rect = UIView.Rect; UIView.AddChild(layout); // Create a scene which will not be actually rendered, but is used to hold SoundSource components while they play sounds scene = new Scene(); // Create buttons for playing back sounds foreach (var item in sounds) { var button = new UIButton(); layout.AddChild(button); button.Text = item.Key; button.SubscribeToEvent<WidgetEvent>(button, e => { if (e.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { // Get the sound resource Sound sound = cache.Get<Sound>(item.Value); if (sound != null) { // Create a scene node with a SoundSource component for playing the sound. The SoundSource component plays // non-positional audio, so its 3D position in the scene does not matter. For positional sounds the // SoundSource3D component would be used instead Node soundNode = scene.CreateChild("Sound"); SoundSource soundSource = soundNode.CreateComponent<SoundSource>(); soundSource.Play(sound); // In case we also play music, set the sound volume below maximum so that we don't clip the output soundSource.Gain = 0.75f; // Set the sound component to automatically remove its scene node from the scene when the sound is done playing } } }); } // Create buttons for playing/stopping music var playMusicButton = new UIButton(); layout.AddChild(playMusicButton); playMusicButton.Text = "Play Music"; playMusicButton.SubscribeToEvent<WidgetEvent> (playMusicButton, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) return; if (scene.GetChild ("Music", false) != null) return; var music = cache.Get<Sound>("Music/StoryTime.ogg"); music.Looped = true; Node musicNode = scene.CreateChild ("Music"); SoundSource musicSource = musicNode.CreateComponent<SoundSource> (); // Set the sound type to music so that master volume control works correctly musicSource.SetSoundType ("Music"); musicSource.Play (music); }); var audio = GetSubsystem<Audio>(); // FIXME: Removing the music node is not stopping music var stopMusicButton = new UIButton(); layout.AddChild(stopMusicButton); stopMusicButton.Text = "Stop Music"; stopMusicButton.SubscribeToEvent<WidgetEvent>(stopMusicButton, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) return; scene.RemoveChild(scene.GetChild("Music", false)); }); // Effect Volume Slider var slider = new UISlider(); layout.AddChild(slider); slider.SetLimits(0, 1); slider.Text = "Sound Volume"; slider.SubscribeToEvent<WidgetEvent>(slider, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED) return; Log.Info($"Setting Effects to {slider.Value}"); audio.SetMasterGain("Effect", slider.Value); }); // Music Volume Slider var slider2 = new UISlider(); layout.AddChild(slider2); slider2.SetLimits(0, 1); slider2.Text = "Music Volume"; slider2.SubscribeToEvent<WidgetEvent>(slider2, e => { if (e.Type != UI_EVENT_TYPE.UI_EVENT_TYPE_CHANGED) return; Log.Info($"Setting Music to {slider2.Value}"); audio.SetMasterGain("Music", slider2.Value); }); }
public static Toast Show(string viewName, IUIViewGroup viewGroup, string text, float duration, UILayout layout, Action callback) { if (string.IsNullOrEmpty(viewName)) { viewName = ViewName; } ApplicationContext context = Context.GetApplicationContext(); IUIViewLocator locator = context.GetService <IUIViewLocator>(); ToastView view = locator.LoadView <ToastView>(viewName); if (view == null) { throw new NotFoundException("Not found the \"ToastView\"."); } Toast toast = new Toast(view, viewGroup, text, duration, layout); toast.Show(); return(toast); }
//CreateTextBlock private StackPanel CreateStackPanel(int month, int day, Color color) { UILayout uiLayout = new UILayout(); uiLayout.SolidColorBrush = color; StackPanel stackPanel = uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, BLOCK_THICKNESS, month, day); stackPanel.PointerPressed += OnPointerPressed; return stackPanel; }
protected Toast(ToastView view, IUIViewGroup viewGroup, string text, float duration, UILayout layout, Action callback) { this.view = view; this.viewGroup = viewGroup; this.text = text; this.duration = duration; this.layout = layout; this.callback = callback; }
//CreateTextBlock private StackPanel CreateStackPanel(string showText, Color color) { UILayout uiLayout = new UILayout(); uiLayout.SolidColorBrush = color; return uiLayout.GetMode_A_StackPanel(BLOCK_WIDTH, BLOCK_HEIGHT, BLOCK_THICKNESS, 0, 0, showText); }
public override void Start() { AtomicNET.GetSubsystem <Player> ().LoadScene("Scenes/Scene.scene"); var ui = GetSubsystem <UI> (); ui.AddFont("Textures/BrokenGlass.ttf", "BrokenGlass"); // add a gooder font ui.LoadSkin("Textures/desktop.tb.txt"); // load in the app skin ResourceCache cache = GetSubsystem <ResourceCache> (); Graphics graphics = GetSubsystem <Graphics> (); graphics.SetWindowTitle("PeriodicApp"); Image icon = cache.GetResource <Image> ("Textures/AtomicLogo32.png"); graphics.SetWindowIcon(icon); myuivew = new UIView(); mylayout = new UILayout(); // make the host widget for all visible ui mylayout.SetId("UIPeriodicTable"); // tag it, like a big game scientist mylayout.SetRect(myuivew.GetRect()); //size it to fill the screen area mylayout.SetLayoutConfig("YAGAC"); //all-in-one setting mylayout.SetSkinBg("background_solid"); // make it look gooder mylayout.Load("Scenes/main_layout.ui.txt"); // load the main layout myuivew.AddChild(mylayout); // And make it show up. UITabContainer maintb = (UITabContainer)mylayout.GetWidget("maintabs"); UITabContainer acttb = (UITabContainer)mylayout.GetWidget("primarytabs"); UITabContainer semitb = (UITabContainer)mylayout.GetWidget("moretabs"); UITabContainer viewtb = (UITabContainer)mylayout.GetWidget("supporttabs"); UITabContainer supporttb = (UITabContainer)mylayout.GetWidget("atomictabs"); supporttb.SetCurrentPage(0); viewtb.SetCurrentPage(0); semitb.SetCurrentPage(0); acttb.SetCurrentPage(0); maintb.SetCurrentPage(0); // do this or else the tab contents look like crap! mylog = (UITextField)mylayout.GetWidget("LogText"); UIWidget ea = mylayout.GetWidget("exitapp"); var cota = new code_table(); cota.Setup(mylayout); var cobg = new code_uibargraph(); cobg.Setup(mylayout.GetWidget("pageuibargraph")); var cobu = new code_uibutton(); cobu.Setup(mylayout.GetWidget("pageuibutton")); var cocb = new code_uicheckbox(); cocb.Setup(mylayout.GetWidget("pageuicheckbox")); var cocl = new code_uiclicklabel(); cocl.Setup(mylayout.GetWidget("pageuiclicklabel")); var coch = new code_uicolorwheel(); coch.Setup(mylayout.GetWidget("pageuicolorwheel")); var cocw = new code_uicolorwidget(); cocw.Setup(mylayout.GetWidget("pageuicolorwidget")); var coco = new code_uicontainer(); coco.Setup(mylayout.GetWidget("pageuicontainer")); var coef = new code_uieditfield(); coef.Setup(mylayout.GetWidget("pageuieditfield")); var cofw = new code_uifinderwindow(); cofw.Setup(mylayout.GetWidget("pageuifinderwindow")); var cofd = new code_uifontdescription(); cofd.Setup(mylayout.GetWidget("pageuifontdescription")); var coiw = new code_uiimagewidget(); coiw.Setup(mylayout.GetWidget("pageuiimagewidget")); var cois = new code_uiinlineselect(); cois.Setup(mylayout.GetWidget("pageuiinlineselect")); var colo = new code_uilayout(); colo.Setup(mylayout.GetWidget("pageuilayout")); var colp = new code_uilayoutparams(); colp.Setup(mylayout.GetWidget("pageuilayoutparams")); var comi = new code_uimenuitem(); comi.Setup(mylayout.GetWidget("pageuimenuitem")); var comw = new code_uimenuwindow(); comw.Setup(mylayout.GetWidget("pageuimenuwindow")); var come = new code_uimessagewindow(); come.Setup(mylayout.GetWidget("pageuimessagewindow")); var copw = new code_uipromptwindow(); copw.Setup(mylayout.GetWidget("pageuipromptwindow")); var copd = new code_uipulldownmenu(); copd.Setup(mylayout.GetWidget("pageuipulldownmenu")); var corb = new code_uiradiobutton(); corb.Setup(mylayout.GetWidget("pageuiradiobutton")); var cosv = new code_uisceneview(); cosv.Setup(mylayout.GetWidget("pageuisceneview")); var cosb = new code_uiscrollbar(); cosb.Setup(mylayout.GetWidget("pageuiscrollbar")); var cosc = new code_uiscrollcontainer(); cosc.Setup(mylayout.GetWidget("pageuiscrollcontainer")); var cose = new code_uisection(); cose.Setup(mylayout.GetWidget("pageuisection")); var cosd = new code_uiselectdropdown(); cosd.Setup(mylayout.GetWidget("pageuiselectdropdown")); var cosi = new code_uiselectitem(); cosi.Setup(mylayout.GetWidget("pageuiselectitem")); var cosl = new code_uiselectlist(); cosl.Setup(mylayout.GetWidget("pageuiselectlist")); var cosp = new code_uiseparator(); cosp.Setup(mylayout.GetWidget("pageuiseparator")); var cosk = new code_uiskinimage(); cosk.Setup(mylayout.GetWidget("pageuiskinimage")); var cosa = new code_uislider(); cosa.Setup(mylayout.GetWidget("pageuislider")); var cotc = new code_uitabcontainer(); cotc.Setup(mylayout.GetWidget("pageuitabcontainer")); var cotf = new code_uitextfield(); cotf.Setup(mylayout.GetWidget("pageuitextfield")); var cotw = new code_uitexturewidget(); cotw.Setup(mylayout.GetWidget("pageuitexturewidget")); var cowd = new code_uiwidget(); cowd.Setup(mylayout.GetWidget("pageuiwidget")); var cowi = new code_uiwindow(); cowi.Setup(mylayout.GetWidget("pageuiwindow")); SubscribeToEvent <WidgetEvent> (ea, ev => { if (ev.Type == UI_EVENT_TYPE.UI_EVENT_TYPE_CLICK) { GetSubsystem <Engine> ().Exit(); } }); SubscribeToEvent <KeyDownEvent> (e => { if (e.Key == Constants.KEY_ESCAPE) { GetSubsystem <Engine> ().Exit(); } }); }
protected void SimpleCreateInstructions(string text = "") { var layout = new UILayout(); layout.Rect = UIView.Rect; layout.LayoutPosition = UI_LAYOUT_POSITION.UI_LAYOUT_POSITION_RIGHT_BOTTOM; layout.LayoutDistributionPosition = UI_LAYOUT_DISTRIBUTION_POSITION.UI_LAYOUT_DISTRIBUTION_POSITION_RIGHT_BOTTOM; var fontDesc = new UIFontDescription(); fontDesc.Id = "Vera"; fontDesc.Size = 18; var label = new UIEditField(); label.FontDescription = fontDesc; label.ReadOnly = true; label.Multiline = true; label.AdaptToContentSize = true; label.Text = text; layout.AddChild(label); UIView.AddChild(layout); }
public UILabel(Layer owner, UILayout layout, float size, string text, TextAlignment alignment = TextAlignment.Left) : this(owner, layout, UIDepths.MIDDLE, size, text, alignment) { }
protected override void OnLoad(EventArgs e) { // This loads the user control itself. User control then sets the UIContext.EditedObject value. var previewControl = PaneContent.UserControl as CMSPreviewControl; ICMSMasterPage master = Page.Master as ICMSMasterPage; if ((master != null) && (master.FooterContainer != null)) { master.FooterContainer.Visible = false; } ScriptHelper.RegisterScriptFile(Page, "Controls/CodePreview.js"); paneToolbar = new UILayoutPane(); PaneFooter.Visible = DisplayFooter; previewValue = GetPreviewStateFromCookies(CookiesPreviewStateName); if ((UIContext.EditedObject == null) && !AllowEmptyObject) { previewValue = 0; } // Change preview state handling string args = Request[Page.postEventArgumentID]; string target = Request[Page.postEventSourceID]; if (target == btnHidden.UniqueID) { switch (args) { case "vertical": previewValue = 1; break; case "horizontal": previewValue = 2; break; case "split": previewValue = (previewValue == 0) ? 1 : 0; if (previewValue != 0) { RegisterFullScreen(); PreviewInitialized = true; paneToolbar.Values.Add(new UILayoutValue("PreviewInitialized", true)); } break; } SetPreviewStateToCookies(CookiesPreviewStateName, previewValue); paneToolbar.Values.Add(new UILayoutValue("SetControls", true)); } if (!EnablePreview) { previewValue = 0; } UILayout subLayout = PaneContentMain.FindControl("layoutElem") as UILayout; panePreview = subLayout.FindControl("panePreview") as UILayoutPane; PaneContentMain.Visible = true; subLayout.StopProcessing = false; PaneFooter.SpacingOpen = 0; // Check if inner control denied displaying preview if ((previewControl != null) && !previewControl.ShowPreview) { previewValue = 0; } switch (previewValue) { // No split case 0: { subLayout.StopProcessing = true; PaneContentMain.Visible = false; PaneContent.Direction = PaneDirectionEnum.Center; } break; // Vertical case 1: { PaneContent.SpacingOpen = 8; PaneContent.SpacingClosed = 8; PaneContent.ResizerClass = "TransformationVerticalResizer"; paneToolbar.PaneClass = "VerticalToolbar"; paneToolbar.Values.Add(new UILayoutValue("ShowPanelSeparator", ShowPanelSeparator)); paneToolbar.SpacingOpen = 0; PaneLayout.Controls.Add(paneToolbar); PaneLayout.Panes.Add(paneToolbar); PaneContent.Direction = PaneDirectionEnum.West; } break; // Horizontal case 2: { paneToolbar.PaneClass = "HorizontalToolbar"; subLayout.Controls.Add(paneToolbar); subLayout.Panes.Add(paneToolbar); } break; } // Pane toolbar paneToolbar.ID = "paneToolbar"; paneToolbar.Direction = PaneDirectionEnum.North; paneToolbar.ControlPath = "~/CMSModules/AdminControls/Controls/Preview/PreviewNavigationButtons.ascx"; paneToolbar.Resizable = false; paneToolbar.Slidable = false; paneToolbar.RenderAs = HtmlTextWriterTag.Div; paneToolbar.SpacingOpen = 0; paneTitle.Visible = DisplayTitlePane; paneToolbar.Values.Add(new UILayoutValue("PreviewURLSuffix", PreviewURLSuffix)); paneToolbar.Values.Add(new UILayoutValue("CookiesPreviewStateName", CookiesPreviewStateName)); paneToolbar.Values.Add(new UILayoutValue("PreviewObjectName", PreviewObjectName)); paneToolbar.Values.Add(new UILayoutValue("DefaultAliasPath", DefaultAliasPath)); paneToolbar.Values.Add(new UILayoutValue("DialogMode", DialogMode)); paneToolbar.Values.Add(new UILayoutValue("IgnoreSessionValues", IgnoreSessionValues)); paneToolbar.Values.Add(new UILayoutValue("DefaultPreviewPath", DefaultPreviewPath)); if (PaneContent.UserControl != null) { PaneContent.UserControl.SetValue("DialogMode", DialogMode); } if (previewValue != 0) { ScriptHelper.HideVerticalTabs(Page); if (!RequestHelper.IsPostBack()) { RegisterFullScreen(); } } base.OnLoad(e); }