Example #1
0
 static int InstantiateModelFromPacket(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         string arg0 = ToLua.CheckString(L, 1);
         string arg1 = ToLua.CheckString(L, 2);
         UnityEngine.GameObject arg2 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 3, typeof(UnityEngine.GameObject));
         UnityEngine.GameObject o    = GameObjectExtension.InstantiateModelFromPacket(arg0, arg1, arg2);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #2
0
    /// <summary>
    /// 创建单位, 如果对象池内有引用直接使用
    /// </summary>
    /// <param name="voBase"></param>
    /// <returns></returns>
    public GameObject CreateAvatar(VOBase voBase)
    {
        GameObject result = null;

        if (displayPool.ContainsKey(voBase.Name) && displayPool[voBase.Name].Count > 0)
        {
            result = displayPool[voBase.Name].Pop();
            // 清空父级引用
            result.transform.parent = null;
            result.SetActive(true);
        }
        else
        {
            result = GameObjectExtension.InstantiateModelFromPacket(voBase.ModelPack, voBase.ModelName, null);//DP_FightPrefabManage.InstantiateAvatar(voBase);
        }

        if (result != null)
        {
            // 加载材质
            var     meshList = result.GetComponentsInChildren <SkinnedMeshRenderer>();
            Texture texture  = null;
            // 区分阵营加载不同皮肤
            switch (voBase.Camp)
            {
            case Utils.MyCamp:
                // 我方阵营
                // 更换皮肤
                texture = PacketManage.Single.GetPacket(voBase.ModelPack).Load(voBase.ModelTexture + Utils.MyCampTextureNameTrail) as Texture;
                break;

            case Utils.EnemyCamp:
                // 敌方阵营
                // 更换皮肤
                texture = PacketManage.Single.GetPacket(voBase.ModelPack).Load(voBase.ModelTexture + Utils.EnemyCampTextureNameTrail) as Texture;
                break;
            }
            foreach (var mesh in meshList)
            {
                mesh.material.mainTexture = texture;
            }
        }
        return(result);
    }