Inheritance: Clothing
Exemple #1
0
 // Use this for initialization
 void Start()
 {
     S                  = this;
     rigidBody          = GetComponent <Rigidbody2D>();
     rigidBody.velocity = Vector2.right;
     ps                 = GetComponentInChildren <ParticleSystem>();
 }
Exemple #2
0
    private static void UpdateUVs(Config[] configs)
    {
        foreach (var config in configs)
        {
            var armorMeshFolderPath  = "Assets/Character_Editor/Meshes/" + config.folderName + "/Armor/";
            var weaponMeshFolderPath = "Assets/Character_Editor/Meshes/" + config.folderName + "/Weapon/";

            var meshPaths = new Dictionary <int, string>()
            {
                { Arm.GetMerheOrder(MeshType.ArmRight), armorMeshFolderPath + "Armor_Arm/ArmRight" },
                { Arm.GetMerheOrder(MeshType.ArmLeft), armorMeshFolderPath + "Armor_Arm/ArmLeft" },
                { Belt.GetMerheOrder(), armorMeshFolderPath + "Armor_Belt" },
                { BeltAdd.GetMerheOrder(), armorMeshFolderPath + "Armor_BeltAdd" },
                { Hair.GetMerheOrder(), armorMeshFolderPath + "Armor_Hair" },
                { Helm.GetMerheOrder(), armorMeshFolderPath + "Armor_Helm" },
                { Beard.GetMerheOrder(), armorMeshFolderPath + "Armor_Jaw" },
                { FaceFeature.GetMerheOrder(), armorMeshFolderPath + "Armor_Feature" },
                { Leg.GetMerheOrder(MeshType.LegRight), armorMeshFolderPath + "Armor_Leg/LegRight" },
                { Leg.GetMerheOrder(MeshType.LegLeft), armorMeshFolderPath + "Armor_Leg/LegLeft" },
                { Shoulder.GetMerheOrder(MeshType.ShoulderRight), armorMeshFolderPath + "Armor_Shoulder/ShoulderRight" },
                { Shoulder.GetMerheOrder(MeshType.ShoulderLeft), armorMeshFolderPath + "Armor_Shoulder/ShoulderLeft" },
                { Torso.GetMerheOrder(), armorMeshFolderPath + "Armor_Torso" },
                { TorsoAdd.GetMerheOrder(), armorMeshFolderPath + "Armor_TorsoAdd" },
                { Hand.GetMerheOrder(MeshType.HandRight), weaponMeshFolderPath + "HandRight" },
                { Hand.GetMerheOrder(MeshType.HandLeft), weaponMeshFolderPath + "HandLeft" },
            };


            var myList = meshPaths.ToList();
            myList.Sort((pair1, pair2) => pair1.Key.CompareTo(pair2.Key));

            int   atlasSize = 4;
            float uvsStep   = 1f / atlasSize;

            for (int itemNum = 0; itemNum < myList.Count; itemNum++)
            {
                if (!AssetDatabase.IsValidFolder(myList[itemNum].Value))
                {
                    continue;
                }

                var meshGUIDs = AssetDatabase.FindAssets("t:GameObject", new string[] { myList[itemNum].Value });
                for (int meshNum = 0; meshNum < meshGUIDs.Length; meshNum++)
                {
                    var tempMesh = AssetDatabase.LoadAssetAtPath <GameObject>(AssetDatabase.GUIDToAssetPath(meshGUIDs[meshNum]));
                    // Mesh tempMesh = UnityEngine.Object.Instantiate(meshObject);

                    //Update LOD parts for each armor item
                    var armorsParts = tempMesh.GetComponentsInChildren <MeshFilter>();
                    for (var armLOD = 0; armLOD < armorsParts.Length; armLOD++)
                    {
                        if (armorsParts[armLOD] != null)
                        {
                            var mTempMesh = (Mesh)GameObject.Instantiate(armorsParts[armLOD].sharedMesh);

                            //Update UVS for new atlas
                            Vector2[] uvs = mTempMesh.uv;
                            for (int i = 0; i < uvs.Length; i++)
                            {
                                uvs[i] = new Vector2(uvs[i].x / atlasSize + uvsStep * (itemNum % atlasSize),
                                                     uvs[i].y / atlasSize + uvsStep * (atlasSize - 1 - (itemNum / atlasSize)));
                            }

                            mTempMesh.uv = uvs;
                            //assigne the selected LOD Mesh with new UV's to the new mesh to be exported
                            if (!Directory.Exists(myList[itemNum].Value + "/Meshes/"))
                            {
                                Directory.CreateDirectory(myList[itemNum].Value + "/Meshes/");
                            }

                            CreateOrReplaceAsset <Mesh>(mTempMesh,
                                                        myList[itemNum].Value + "/Meshes/" + armorsParts[armLOD].sharedMesh.name + "_New.asset");

                            AssetDatabase.SaveAssets();
                        }
                    }
                }
            }

            var prefabsPath = "Assets/Character_Editor/Prefabs/" + config.folderName;
            var prefabGUIDs = AssetDatabase.FindAssets("t:Prefab", new string[] { prefabsPath });
            for (int prefNum = 0; prefNum < prefabGUIDs.Length; prefNum++)
            {
                var pPath = AssetDatabase.GUIDToAssetPath(prefabGUIDs[prefNum]);
                if (pPath.Contains("/Model/"))
                {
                    var originalPrefab         = AssetDatabase.LoadAssetAtPath <GameObject>(pPath);
                    var originalPrefabInstance = GameObject.Instantiate(originalPrefab);
                    originalPrefabInstance.name = originalPrefab.name;

                    foreach (var filter in originalPrefabInstance.GetComponentsInChildren <MeshFilter>())
                    {
                        var lodMeshPath = AssetDatabase.GetAssetPath(filter.sharedMesh);
                        var index       = lodMeshPath.LastIndexOf("/");
                        if (index != -1)
                        {
                            lodMeshPath = lodMeshPath.Substring(0, index) + "/Meshes/" + filter.sharedMesh.name + "_New.asset";

                            var changedMesh = AssetDatabase.LoadAssetAtPath <Mesh>(lodMeshPath);
                            filter.mesh = changedMesh;

                            var newDirPath  = pPath.Substring(0, pPath.IndexOf("Model/")) + "StaticModel/";
                            var fullDirPath = Application.dataPath.Substring(0, Application.dataPath.Length - 6) + newDirPath;
                            if (Directory.Exists(fullDirPath))
                            {
                                Directory.Delete(fullDirPath, true);
                            }

                            Directory.CreateDirectory(fullDirPath);

                            Object prefab = PrefabUtility.CreateEmptyPrefab(newDirPath + originalPrefabInstance.name + ".prefab");
                            PrefabUtility.ReplacePrefab(originalPrefabInstance, prefab, ReplacePrefabOptions.ConnectToPrefab);

                            AssetDatabase.SaveAssets();
                        }
                    }
                    GameObject.DestroyImmediate(originalPrefabInstance);
                }
            }
        }
    }
Exemple #3
0
 public override string GetFolderPath()
 {
     return(Beard.GetFolderPath(CharacterRace));
 }
Exemple #4
0
 public Skin(Beard beard, Hair hair, Hat hat, Body body, Tshirt tshirt, Pant pant, Gloves gloves, Eyes eyes)
 {
     this.beard = beard;
     this.hair = hair;
     this.hat = hat;
     this.body = body;
     this.tshirt = tshirt;
     this.pant = pant;
     this.gloves = gloves;
     this.eyes = eyes;
 }
Exemple #5
0
 // Constructeur
 public Skin()
 {
     this.beard = new Beard();
     this.hair = new Hair();
     this.hat = new Hat();
     this.body = new Body();
     this.tshirt = new Tshirt();
     this.pant = new Pant();
     this.gloves = new Gloves();
     this.eyes = new Eyes();
 }
Exemple #6
0
 public Beard(Beard beard)
     : base(beard)
 {
     this.color = beard.color;
     this.type = beard.type;
 }
Exemple #7
0
    // Method
    public void Randomize()
    {
        List<Eyes> eyes = new List<Eyes>();
        foreach (Eyes e in Clothing.Eyes)
            eyes.Add(e);
        this.eyes = eyes[Random.Range(0, eyes.Count - 1)];

        List<Gloves> gloves = new List<Gloves>();
        foreach (Gloves g in Clothing.Gloves)
            gloves.Add(g);
        this.gloves = gloves[Random.Range(0, gloves.Count - 1)];

        List<Pant> pant = new List<Pant>();
        foreach (Pant p in Clothing.Pants)
            pant.Add(p);
        this.pant = pant[Random.Range(0, pant.Count - 1)];

        List<Tshirt> tshirt = new List<Tshirt>();
        foreach (Tshirt t in Clothing.Tshirts)
            tshirt.Add(t);
        this.tshirt = tshirt[Random.Range(0, tshirt.Count - 1)];

        List<Body> body = new List<Body>();
        foreach (Body b in Clothing.Bodies)
            body.Add(b);
        this.body = body[Random.Range(0, body.Count - 1)];

        List<Hair> hair = new List<Hair>();
        foreach (Hair h in Clothing.Hairs)
            hair.Add(h);
        this.hair = hair[Random.Range(0, hair.Count - 1)];

        if (this.hair.GetTypeHair == Hair.TypeHair.Crete)
            this.hat = Hat.NoneHat;
        else
        {
            List<Hat> hat = new List<Hat>();
            foreach (Hat h in Clothing.Hats)
                hat.Add(h);
            this.hat = hat[Random.Range(0, hat.Count - 1)];
        }

        List<Beard> beard = new List<Beard>();
        foreach (Beard b in Clothing.Beards)
            beard.Add(b);
        this.beard = beard[Random.Range(0, beard.Count - 1)];
    }
Exemple #8
0
 public void ChangeBeard(Beard beard, GameObject character)
 {
     foreach (Transform t in character.transform.FindChild("Character").FindChild("Armature").FindChild("Head_slot").FindChild("Beard"))
     {
         if (t.gameObject.name == beard.GetTypeBeard.ToString())
         {
             t.gameObject.SetActive(true);
             t.gameObject.GetComponentInChildren<Renderer>().material.mainTexture = beard.Texture;
         }
         else
             t.gameObject.SetActive(false);
     }
 }