Skip to content

Commit

Permalink
添加UI代码生成工具,添加一些组件
Browse files Browse the repository at this point in the history
  • Loading branch information
526077247 committed Sep 18, 2022
1 parent 36a54f3 commit 08af398
Show file tree
Hide file tree
Showing 39 changed files with 1,397 additions and 6 deletions.
Binary file modified Assets/AssetsPackage/Code/Hotfix/Code1.dll.bytes
Binary file not shown.
Binary file modified Assets/AssetsPackage/Code/Hotfix/Code1.pdb.bytes
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/AssetsPackage/UI/UIMain.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/AssetsPackage/UI/UIMain/Prefabs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

196 changes: 196 additions & 0 deletions Assets/AssetsPackage/UI/UIMain/Prefabs/UIMainView.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1386170326414932
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 224438795553994780}
m_Layer: 5
m_Name: UIMainView
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &224438795553994780
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1386170326414932}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8387124566555402871}
- {fileID: 2166509226398129077}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &4514847008310789613
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2166509226398129077}
- component: {fileID: 3106506399834163583}
- component: {fileID: 1151684211184624713}
m_Layer: 5
m_Name: Text
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2166509226398129077
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4514847008310789613}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 224438795553994780}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 160, y: 30}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &3106506399834163583
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4514847008310789613}
m_CullTransparentMesh: 1
--- !u!114 &1151684211184624713
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4514847008310789613}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_FontData:
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
m_FontSize: 14
m_FontStyle: 0
m_BestFit: 0
m_MinSize: 10
m_MaxSize: 40
m_Alignment: 4
m_AlignByGeometry: 0
m_RichText: 1
m_HorizontalOverflow: 0
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: welcome
--- !u!1 &5643723715351900894
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 8387124566555402871}
- component: {fileID: 7400171927947396771}
- component: {fileID: 9136845342904087258}
m_Layer: 5
m_Name: Image
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &8387124566555402871
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5643723715351900894}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 224438795553994780}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &7400171927947396771
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5643723715351900894}
m_CullTransparentMesh: 1
--- !u!114 &9136845342904087258
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5643723715351900894}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 0}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
9 changes: 9 additions & 0 deletions Assets/AssetsPackage/UI/UIMain/Prefabs/UIMainView.prefab.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Scripts/Code/Game/Scene.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Scripts/Code/Game/Scene/Login.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ public string GetScenePath()

public async ETTask OnSwitchSceneEnd()
{
await UIManager.Instance.OpenWindow<UIMainView>(UIMainView.PrefabPath);
await UIManager.Instance.DestroyWindow<UILoadingView>();
win = null;
}
Expand Down
8 changes: 8 additions & 0 deletions Assets/Scripts/Code/Game/UI/UIMain.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 30 additions & 0 deletions Assets/Scripts/Code/Game/UI/UIMain/UIMainView.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.UI;

namespace TaoTie
{
public class UIMainView : UIBaseView, IOnCreate, IOnEnable
{
public static string PrefabPath => "UI/UIMain/Prefabs/UIMainView.prefab";
public UIImage Image;
public UIText Text;


#region override
public void OnCreate()
{
this.Image = this.AddComponent<UIImage>("Image");
this.Text = this.AddComponent<UIText>("Text");
}
public void OnEnable()
{
}
#endregion

#region 事件绑定
#endregion
}
}
11 changes: 11 additions & 0 deletions Assets/Scripts/Code/Game/UI/UIMain/UIMainView.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

57 changes: 57 additions & 0 deletions Assets/Scripts/Code/Module/UIComponent/UIDropdown.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
using UnityEngine.Events;
using UnityEngine.UI;

namespace TaoTie
{
public class UIDropdown:UIBaseContainer,IOnDestroy
{
public Dropdown unity_uidropdown;
public UnityAction<int> __onValueChanged;

#region override

public void OnDestroy()
{
RemoveOnValueChanged();
}

#endregion

void ActivatingComponent()
{
if (this.unity_uidropdown == null)
{
this.unity_uidropdown = this.GetGameObject().GetComponent<Dropdown>();
if (this.unity_uidropdown == null)
{
Log.Error($"添加UI侧组件UIDropdown时,物体{this.GetGameObject().name}上没有找到Dropdown组件");
}
}
}
public void SetOnValueChanged( UnityAction<int> callback)
{
this.ActivatingComponent();
this.RemoveOnValueChanged();
this.__onValueChanged = callback;
this.unity_uidropdown.onValueChanged.AddListener(this.__onValueChanged);
}
public void RemoveOnValueChanged()
{
if (this.__onValueChanged != null)
{
this.unity_uidropdown.onValueChanged.RemoveListener(this.__onValueChanged);
this.__onValueChanged = null;
}
}
public int GetValue()
{
this.ActivatingComponent();
return this.unity_uidropdown.value;
}
public void SetValue( int value)
{
this.ActivatingComponent();
this.unity_uidropdown.value = value;
}
}
}
3 changes: 3 additions & 0 deletions Assets/Scripts/Code/Module/UIComponent/UIDropdown.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 08af398

Please sign in to comment.