上次总结到泛型
脚本UISceneMgr中涉及到了获取挂点的脚本UISceneCtrBase这是个场景基类,以后还有有一个窗口基类,
using UnityEngine;
using System.Collections;
/// <summary>
/// 场景UI控制器基类
/// </summary>
public class UISceneCtrBase : MonoBehaviour {
//获取居中挂点
public Transform center_container;
//左上挂点
public Transform left_top_container;
// Use this for initialization
void Start () {
OnStart ();
}
void OnDestroy(){
BeforeOnDestroy ();
}
protected virtual void OnStart(){
}
protected virtual void BeforeOnDestroy(){
}
// Update is called once per frame
void Update () {
}
}
一个 专门容纳各个enum的文件
using UnityEngine;
using System.Collections;
/// <summary>
/// 场景UI类型
/// </summary>
public enum SceneUIType{
NONE = 0,
/// <summary>
/// 登陆场景UI类型
/// </summary>
Login,
Battle
}
public enum ResourceType{
NONE = 0,
/// <summary>
/// 登陆场景UI类型
/// </summary>
UIScene,
/// <summary>
/// 登陆窗体UI类型
/// </summary>
UIWindow
}
public enum WindowUIType{
NONE = 0,
/// <summary>
/// 登陆场景UI类型
/// </summary>
Login,
Register
}
public enum WindowUIContainerType{
NONE = 0,
Center,
//左上挂点
LeftTop,
//左下挂点
LeftButton,
//右上挂点
RightTop,
//右下挂点
RightButton,
}
/// <summary>
/// 窗口UI显示的动画类型
/// </summary>
public enum WindowShowAnimationType{
Nomal = 0,
//从中间向四周放大显示
CenterToBig,
//从左到右
LeftToRight,
RightToLeft,
TopToBottom,
BottomToTop//从下到上
}
这里我只是罗列了我当前用到的,以后随时加
到现在,三个最基本的脚本写了两个
剩下这个
using UnityEngine;
using System.Collections;
//游戏工具类,扩展特点,静态类,方法是静态的
public static class GameTools {
public static void ResetPositionAndScale(this GameObject go){
go.transform.localPosition = Vector3.zero;
go.transform.localScale = Vector3.one;
}
public static void SetParent(this GameObject go,Transform parent){
go.transform.parent = parent;
}
/// <summary>
/// 获取或添加组件
/// </summary>
/// <returns>组件泛型</returns>
/// <param name="go">游戏对象</param>
/// <typeparam name="T">组件实例</typeparam>
public static T GetOrAddCoponent<T>(this GameObject go) where T:MonoBehaviour{
T t = go.GetComponent<T> ();
if(null == t)
t = go.AddComponent<T>();
return t;
}
}
到此我们就可以成功的加载出来背景了,最后一个阶段也是最乱的阶段,显示窗口,同时设置按钮,写入,读取,功能最后再说,先把显示显示全