public static void DrawWing(GameObject go, string dir) { XRoleParts parts = go.GetComponent <XRoleParts>(); Transform root = parts.wingRoot; if (root.childCount > 0) { return; } string path = "Assets/BundleRes/Prefabs/Wing/Player_common_" + dir + "_wing.prefab"; var prefab = AssetDatabase.LoadAssetAtPath <GameObject>(path); if (prefab != null) { go = GameObject.Instantiate(prefab); go.transform.SetParent(root); go.transform.localScale = Vector3.one; go.transform.rotation = Quaternion.identity; go.transform.position = Vector3.zero; SkinnedMeshRenderer skm = go.GetComponentInChildren <SkinnedMeshRenderer>(); path = "Assets/BundleRes/FBXRawData/Player_common/Player_common_" + dir + "_wing"; skm.sharedMaterial = AssetDatabase.LoadAssetAtPath <Material>(path + ".mat"); skm.sharedMesh = AssetDatabase.LoadAssetAtPath <Mesh>(path + ".asset"); } }
public static void DrawSuit(GameObject go, FashionSuit.RowData rowData, uint presentid, int weapon_index, bool complete) { if (rowData != null) { XRoleParts xpart = go.GetComponent <XRoleParts>(); XRolePart part = UtilPart(go, rowData.id); if (part != null) { UnloadSuit(go); DrawFace(go, (RoleShape)rowData.shape, TCConst.FACE, xpart.face, presentid); if (complete) { DrawPart(go, rowData.body, (RoleShape)rowData.shape, rowData.dir, TCConst.BODY, part.body, part.sbody, SearchPart(rowData.id, (uint)FPart.BODY)); DrawPart(go, rowData.hair, (RoleShape)rowData.shape, rowData.dir, TCConst.HAIR, part.hair, part.shair, SearchPart(rowData.id, (uint)FPart.HAIR)); DrawPart(go, rowData.helmet, (RoleShape)rowData.shape, rowData.dir, TCConst.HELMET, part.helmet, part.shelmet, SearchPart(rowData.id, (uint)FPart.HELMET)); uint pos = weapon_index == 1 ? (uint)FPart.WEAPON : 5; DrawWeapon(go, (RoleShape)rowData.shape, rowData.dir, part, presentid, weapon_index, SearchPart(rowData.id, pos)); DrawWing(go, rowData.dir); } } } else { Debug.LogError("rowdata is null " + go.name + " presentid: " + presentid); } }
public void Initial(GameObject go, RoleShape shape) { RoleParts = go.GetComponent <XRoleParts>(); string path = "Assets/BundleRes/Config/" + shape.ToString().ToLower(); TextAsset ta = AssetDatabase.LoadAssetAtPath <TextAsset>(path + ".bytes"); if (ta != null) { MemoryStream ms = new MemoryStream(ta.bytes); fbData = new FaceBoneDatas(ms); CleanData(); MakeControlGroups(); ms.Close(); } }
public static XRolePart UtilPart(GameObject go, uint suitid) { XRoleParts xpart = go.GetComponent <XRoleParts>(); if (xpart != null) { for (int i = 0; i < xpart.parts.Count; i++) { if (xpart.parts[i].suitid == suitid) { return(xpart.parts[i]); } } } return(null); }
public static void UnloadSuit(GameObject go) { SkinnedMeshRenderer[] skms = go.GetComponentsInChildren <SkinnedMeshRenderer>(); foreach (var item in skms) { item.sharedMaterials = new Material[] { null }; item.sharedMesh = null; } XRoleParts part = go.GetComponent <XRoleParts>(); if (part != null) { Transform wing = part.wingRoot; int cnt = wing.childCount; for (int i = 0; i < cnt; i++) { GameObject.DestroyImmediate(wing.GetChild(i).gameObject); } } }