少年修仙传客户端代码仓库
Leonard Wu
2018-08-15 47f2992f5d49689e774cef28cf845764792c4bc2
提供窗口管理的lua接口
4个文件已修改
2个文件已添加
78 ■■■■ 已修改文件
Lua/LuaUtility.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Lua/LuaWindow.cs 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Lua/LuaWindowUtility.cs 44 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Lua/LuaWindowUtility.cs.meta 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
System/WindowBase/WindowCenter.cs 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
Utility/UIUtility.cs 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
Lua/LuaUtility.cs
@@ -17,8 +17,10 @@
    public void Init()
    {
        Do("global.util");
        Do("custom.ButtonUtil");
        Do("global.logex");
        Do("global.functions");
        lastGCTime = 0f;
    }
Lua/LuaWindow.cs
@@ -10,7 +10,6 @@
public class LuaWindow : Window
{
    public string fileName;
    public Injection[] injections;
    Action luaOnDestroy;
@@ -24,7 +23,6 @@
    Action onLateUpdate;
    private LuaTable scriptEnv;
    bool luaInited = false;
    private void Init()
    {
@@ -33,12 +31,6 @@
        meta.Set("__index", LuaUtility.env.Global);
        scriptEnv.SetMetaTable(meta);
        meta.Dispose();
        scriptEnv.Set("self", this);
        foreach (var injection in injections)
        {
            scriptEnv.Set(injection.name, injection.value);
        }
        LuaUtility.Do(fileName, "LuaWindow", scriptEnv);
@@ -72,7 +64,6 @@
        onLateUpdate = null;
        scriptEnv.Dispose();
        injections = null;
    }
    protected override void BindController()
@@ -104,6 +95,7 @@
    protected override void OnAfterOpen()
    {
        scriptEnv.Set("root",this.gameObject);
        if (onAfterOpen != null)
        {
            onAfterOpen();
Lua/LuaWindowUtility.cs
New file
@@ -0,0 +1,44 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Snxxz.UI;
[XLua.LuaCallCSharp]
public class LuaWindowUtility
{
    public static Window Open(string _name, bool _forceSync = false, int _functionalOrder = 0)
    {
        return WindowCenter.Instance.Open(_name, _forceSync, _functionalOrder);
    }
    public static Window OpenWithoutAnimation(string _name)
    {
        return WindowCenter.Instance.OpenWithoutAnimation(_name);
    }
    public static Window Get(string _name)
    {
        return WindowCenter.Instance.Get(_name);
    }
    public static Window Close(string _name)
    {
        return WindowCenter.Instance.Close(_name);
    }
    public static void CloseAll()
    {
        WindowCenter.Instance.CloseAll();
    }
    public static void DestroyWin(string _name)
    {
        WindowCenter.Instance.DestroyWin(_name);
    }
    public static bool CheckOpen(string _name)
    {
        return WindowCenter.Instance.CheckOpen(_name);
    }
}
Lua/LuaWindowUtility.cs.meta
New file
@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: d01a9255dd1b980498b7f0296c9d7a4d
timeCreated: 1534342506
licenseType: Free
MonoImporter:
  serializedVersion: 2
  defaultReferences: []
  executionOrder: 0
  icon: {instanceID: 0}
  userData:
  assetBundleName:
  assetBundleVariant:
System/WindowBase/WindowCenter.cs
@@ -63,7 +63,6 @@
            OpenFromLocal(windowName);
        }
        [XLua.LuaCallCSharp]
        public void OpenFromLocal(string _name)
        {
            Window win = null;
@@ -106,7 +105,6 @@
            }
        }
        [XLua.LuaCallCSharp]
        public Window Open(string _name, bool _forceSync = false, int _functionalOrder = 0)
        {
            if (VersionConfig.Get().isBanShu)
@@ -166,7 +164,6 @@
            }
        }
        [XLua.LuaCallCSharp]
        public Window OpenWithoutAnimation(string _name)
        {
            Window win = null;
@@ -212,7 +209,6 @@
        }
        [XLua.LuaCallCSharp]
        public Window Get(string _window)
        {
            if (windows.ContainsKey(_window))
@@ -248,7 +244,6 @@
            return win;
        }
        [XLua.LuaCallCSharp]
        public Window Close(string _name)
        {
            if (windows.ContainsKey(_name))
@@ -302,7 +297,6 @@
            return new List<string>(windows.Keys);
        }
        [XLua.LuaCallCSharp]
        public void CloseAll(CloseAllIgnoreType _ignoreType = CloseAllIgnoreType.System)
        {
            foreach (var window in windows.Values)
@@ -436,7 +430,6 @@
            DestroyWin(typeof(T).Name);
        }
        [XLua.LuaCallCSharp]
        public void DestroyWin(string _name)
        {
            if (windows.ContainsKey(_name))
@@ -492,7 +485,6 @@
            }
        }
        [XLua.LuaCallCSharp]
        public bool CheckOpen(string _name)
        {
            if (windows.ContainsKey(_name) && windows[_name] != null)
Utility/UIUtility.cs
@@ -7,7 +7,7 @@
public static class UIUtility
{
    [XLua.LuaCallCSharp]
    public static GameObject CreateWidget(string _sourceName, string _name)
    {
        var prefab = UILoader.LoadPrefab(_sourceName);