private void OnDestroy()
 {
     if (object.ReferenceEquals(sInstance, this))
     {
         sInstance = null;
         SingletonMgr.RemoveSingleton(this);
     }
 }
 static public void DestroySingleton()
 {
     if (sInstance != null)
     {
         SingletonMgr.RemoveSingleton(sInstance);
         Destroy(sInstance.gameObject);
         sInstance = null;
     }
 }
Exemple #3
0
    public static Packet HanldeProtoBuf(Packet data)
    {
        Packet ret = new Packet();

        ret.m_bytes = new byte[data.m_bytes.Length];
        Buffer.BlockCopy(data.m_bytes, 0, ret.m_bytes, 0, data.m_bytes.Length);

        LuaFunction luaFunc = SingletonMgr.GetLuaState().GetFunction("TestCharpCallLua");

        luaFunc.Call(ret);
        return(ret);
    }
 static public void CreateSingleton()
 {
     if (sInstance == null)
     {
         SingletonMgr.Initialize();
         sInstance = GameObject.FindObjectOfType <T>();
         if (sInstance == null && SingletonMgr.LazyInstantiationAllowed)
         {
             sInstance = new GameObject(typeof(T).Name + "::Singleton").AddComponent <T>();
         }
         DontDestroyOnLoad(sInstance);
     }
 }
 protected virtual void Awake()
 {
     if (sInstance == null)
     {
         sInstance = (T)this;
         DontDestroyOnLoad(this);
         SingletonMgr.AddSingleton(this);
     }
     else if (!object.ReferenceEquals(this, sInstance))
     {
         Destroy(this.gameObject);
     }
 }
Exemple #6
0
    public static LuaTable TestLuaCallByLuaArrayTable(LuaTable param)
    {
        LuaArrayTable arrayTable = param.ToArrayTable();

        foreach (var iter in arrayTable)
        {
            Debug.Log("array " + iter);
        }

        int      reference = SingletonMgr.GetLuaState().ToLuaRef();
        LuaTable ret       = new LuaTable(reference, SingletonMgr.GetLuaState());

        ret[1] = "array1";
        ret[2] = "array2";
        return(ret);
    }
Exemple #7
0
    public static LuaTable TestLuaCallByLuaDicTable(LuaTable param)
    {
        LuaDictTable dicTable = param.ToDictTable();

        foreach (var iter in dicTable)
        {
            Debug.Log("key " + iter.Key + " value " + iter.Value);
        }

        int      reference = SingletonMgr.GetLuaState().ToLuaRef();
        LuaTable ret       = new LuaTable(reference, SingletonMgr.GetLuaState());

        //ret();
        //Dictionary<string, string> ret = new Dictionary<string, string>();
        //ret.Add("csharpKey", "csharpValue");
        ret["csharpKey"] = "csharpValue";
        return(ret);
    }