mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
little bit more progress, creating main menu page structure
This commit is contained in:
27
src/UI/Main/Pages/BaseMenuPage.cs
Normal file
27
src/UI/Main/Pages/BaseMenuPage.cs
Normal file
@ -0,0 +1,27 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Explorer.UI.Main.Pages
|
||||
{
|
||||
public abstract class BaseMenuPage
|
||||
{
|
||||
public abstract string Name { get; }
|
||||
|
||||
public GameObject Content;
|
||||
public Button RefNavbarButton { get; set; }
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get => Content?.activeSelf ?? false;
|
||||
set => Content?.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
public abstract void Init();
|
||||
public abstract void Update();
|
||||
}
|
||||
}
|
22
src/UI/Main/Pages/ConsolePage.cs
Normal file
22
src/UI/Main/Pages/ConsolePage.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Explorer.UI.Main.Pages
|
||||
{
|
||||
public class ConsolePage : BaseMenuPage
|
||||
{
|
||||
public override string Name => "C# Console";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
75
src/UI/Main/Pages/HomePage.cs
Normal file
75
src/UI/Main/Pages/HomePage.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ExplorerBeta.UI;
|
||||
using ExplorerBeta.UI.Main;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Explorer.UI.Main.Pages
|
||||
{
|
||||
public class HomePage : BaseMenuPage
|
||||
{
|
||||
public override string Name => "Home";
|
||||
|
||||
private GameObject m_mainViewport;
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
ConstructMenu();
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region UI Construction
|
||||
|
||||
private void ConstructMenu()
|
||||
{
|
||||
var parent = MainMenu.Instance.PageViewport;
|
||||
|
||||
m_mainViewport = UIFactory.CreateHorizontalGroup(parent);
|
||||
var mainGroup = m_mainViewport.GetComponent<HorizontalLayoutGroup>();
|
||||
mainGroup.padding.left = 3;
|
||||
mainGroup.padding.right = 3;
|
||||
mainGroup.padding.top = 3;
|
||||
mainGroup.padding.bottom = 3;
|
||||
mainGroup.spacing = 5;
|
||||
mainGroup.childForceExpandHeight = true;
|
||||
mainGroup.childForceExpandWidth = true;
|
||||
mainGroup.childControlHeight = true;
|
||||
mainGroup.childControlWidth = true;
|
||||
|
||||
var leftPaneObj = UIFactory.CreateVerticalGroup(m_mainViewport, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
||||
var leftLayout = leftPaneObj.AddComponent<LayoutElement>();
|
||||
leftLayout.minWidth = 350;
|
||||
leftLayout.flexibleWidth = 0;
|
||||
|
||||
var leftGroup = leftPaneObj.GetComponent<VerticalLayoutGroup>();
|
||||
leftGroup.padding.left = 8;
|
||||
leftGroup.padding.right = 8;
|
||||
leftGroup.padding.top = 8;
|
||||
leftGroup.padding.bottom = 8;
|
||||
leftGroup.spacing = 5;
|
||||
leftGroup.childControlWidth = true;
|
||||
leftGroup.childControlHeight = true;
|
||||
leftGroup.childForceExpandWidth = false;
|
||||
leftGroup.childForceExpandHeight = true;
|
||||
|
||||
var rightPaneObj = UIFactory.CreateVerticalGroup(m_mainViewport, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
||||
var rightLayout = rightPaneObj.AddComponent<LayoutElement>();
|
||||
rightLayout.flexibleWidth = 999999;
|
||||
|
||||
var rightGroup = rightPaneObj.GetComponent<VerticalLayoutGroup>();
|
||||
rightGroup.childForceExpandHeight = true;
|
||||
rightGroup.childForceExpandWidth = true;
|
||||
rightGroup.childControlHeight = true;
|
||||
rightGroup.childControlWidth = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
22
src/UI/Main/Pages/OptionsPage.cs
Normal file
22
src/UI/Main/Pages/OptionsPage.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Explorer.UI.Main.Pages
|
||||
{
|
||||
public class OptionsPage : BaseMenuPage
|
||||
{
|
||||
public override string Name => "Options / Misc";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
22
src/UI/Main/Pages/SearchPage.cs
Normal file
22
src/UI/Main/Pages/SearchPage.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Explorer.UI.Main.Pages
|
||||
{
|
||||
public class SearchPage : BaseMenuPage
|
||||
{
|
||||
public override string Name => "Search";
|
||||
|
||||
public override void Init()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user