Beispiel #1
0
 static int ChangeClothes(IntPtr L)
 {
     try
     {
         int count = LuaDLL.lua_gettop(L);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckUnityObject(L, 1, typeof(UnityEngine.GameObject));
         string[] arg1 = ToLua.CheckParamsString(L, 2, count - 1);
         DressPart.ChangeClothes(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Beispiel #2
0
    static int set_skinMeshInfo(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DressPart    obj  = (DressPart)o;
            SkinMeshInfo arg0 = (SkinMeshInfo)ToLua.CheckObject(L, 2, typeof(SkinMeshInfo));
            obj.skinMeshInfo = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index skinMeshInfo on a nil value" : e.Message));
        }
    }
Beispiel #3
0
    static int get_skinMeshInfo(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            DressPart    obj = (DressPart)o;
            SkinMeshInfo ret = obj.skinMeshInfo;
            ToLua.PushObject(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index skinMeshInfo on a nil value" : e.Message));
        }
    }
Beispiel #4
0
    public static void ChangeClothes(GameObject root, params string[] dressInfos)
    {
        List <SkinMeshInfo> smiList = new List <SkinMeshInfo>();
        int num = 0;

        for (int i = 0; i < dressInfos.Length; i++)
        {
            if (dressInfos[i] == null || dressInfos[i] == "")
            {
                continue;
            }
            num++;
        }
        foreach (var dressInfo in dressInfos)
        {
            if (dressInfo == null || dressInfo == "")
            {
                continue;
            }
            ObjectPoolManager.NewObject(dressInfo, EResType.eResCharacter, obj => {
                var part = obj as GameObject;
                if (part == null)
                {
                    return;
                }
                DressPart p = part.GetComponent <DressPart>();
                if (p == null)
                {
                    return;
                }
                smiList.Add(p.skinMeshInfo);
                ObjectPoolManager.RecycleObject(part);
                if (smiList.Count == num)
                {
                    List <CombineInstance> combineInstances = new List <CombineInstance>();
                    List <Material> materials = new List <Material>();
                    List <Transform> bones    = new List <Transform>();
                    Transform[] transforms    = root.GetComponentsInChildren <Transform>();

                    foreach (var item in smiList)
                    {
                        for (int sub = 0; sub < item.mesh.subMeshCount; sub++)
                        {
                            CombineInstance ci = new CombineInstance();
                            ci.mesh            = item.mesh;
                            ci.subMeshIndex    = sub;
                            combineInstances.Add(ci);
                        }

                        foreach (string bone in item.bonesName)
                        {
                            foreach (Transform transform in transforms)
                            {
                                if (transform.name != bone)
                                {
                                    continue;
                                }
                                bones.Add(transform);
                                break;
                            }
                        }
                        materials.AddRange(item.materials);
                    }

                    SkinnedMeshRenderer r = root.GetComponent <SkinnedMeshRenderer>();
                    if (r == null)
                    {
                        r = root.AddComponent <SkinnedMeshRenderer>();
                    }
                    r.bones      = bones.ToArray();
                    r.materials  = materials.ToArray();
                    r.sharedMesh = new Mesh();
                    r.sharedMesh.CombineMeshes(combineInstances.ToArray(), false, false);
                    root.SetActive(false);
                    root.SetActive(true);
                }
            });
        }
    }
Beispiel #5
0
 public void Merge()
 {
     DressPart.ChangeClothes(gameObject, dressParts);
 }