public void SetMaskSlots(Maid maid, List <CCSlot> slotList)
        {
            foreach (var slotItem in slotList)
            {
                // 未読み込みの場合はスキップ
                if (slotItem.mask == SlotState.NotLoaded)
                {
                    continue;
                }

                TBodySkin slot = maid.body0.GetSlot((int)slotItem.id);
                if (slotItem.mask == SlotState.Masked)
                {
                    slot.listMaskSlot.Add((int)slotItem.id);
                }
                else if (slotItem.mask == SlotState.Displayed)
                {
                    // 全スロットから削除する
                    foreach (TBodySkin tBodySkin in maid.body0.goSlot)
                    {
                        tBodySkin.listMaskSlot.Remove((int)slotItem.id);
                    }
                }
                // NonDisplayの場合は何もしない
            }
        }
        private void CreateMorphs(TBodySkin skin)
        {
            if (skin == null || skin.morph == null || skin.morph.BlendDatas.Count <= 0)
            {
                return;
            }
            if (!vertexIndexMap.ContainsKey(skin.obj.name))
            {
                Debug.Log($"Morph: {skin.obj.name} -> Missing vertex base!");
                return;
            }
            int vertexBase = vertexIndexMap[skin.obj.name];

            Debug.Log($"Morph: {skin.obj.name} -> {skin.morph.BlendDatas.Count} ({vertexBase})");
            for (int j = 0; j < skin.morph.BlendDatas.Count; j++)
            {
                BlendData blendData = skin.morph.BlendDatas[j];
                if (blendData != null)
                {
                    PmxMorph pmxMorph = GetOrCreateMorph(blendData.name);
                    for (int k = 0; k < blendData.v_index.Length; k++)
                    {
                        PmxVertexMorph pmxVertexMorph = new PmxVertexMorph(blendData.v_index[k] + vertexBase, new PmxLib.Vector3(-blendData.vert[k].x, blendData.vert[k].z, blendData.vert[k].y));
                        pmxVertexMorph.Offset *= scaleFactor;
                        pmxMorph.OffsetList.Add(pmxVertexMorph);
                    }
                }
            }
        }
 // Token: 0x060002AB RID: 683 RVA: 0x00016864 File Offset: 0x00014A64
 public void SetSlotVisibles(Maid maid, Dictionary <TBody.SlotID, MaskInfo> maskDic, bool temporary)
 {
     foreach (KeyValuePair <TBody.SlotID, MaskInfo> keyValuePair in maskDic)
     {
         MaskInfo value = keyValuePair.Value;
         if (value.state != SlotState.NotLoaded)
         {
             value.slot.boVisible = value.value;
             if (!temporary)
             {
                 TBodySkin slot = maid.body0.GetSlot((int)keyValuePair.Key);
                 if (!value.value)
                 {
                     slot.listMaskSlot.Add((int)keyValuePair.Key);
                 }
                 else
                 {
                     foreach (TBodySkin tbodySkin in maid.body0.goSlot)
                     {
                         tbodySkin.listMaskSlot.Remove((int)keyValuePair.Key);
                     }
                 }
             }
         }
     }
 }
Example #4
0
        private Texture ChangeTexFile(string dir, string filename, int matNo1, string propName)
        {
            Texture changedTex;
            // キャッシュ削除用に変更前のテクスチャを取得
            var    srcTex    = material.GetTexture(propName) as Texture2D;
            string extension = Path.GetExtension(filename).ToLower();

            if (extension.Length == 0 || extension == FileConst.EXT_TEXTURE)
            {
                string texName;
                if (extension.Length == 0)
                {
                    texName   = filename;
                    filename += FileConst.EXT_TEXTURE;
                }
                else
                {
                    texName = filename.Substring(0, filename.Length - 4);
                }
                holder.currentMaid.body0.ChangeTex(holder.currentSlot.Name, matNo1, propName, filename, null, MaidParts.PARTS_COLOR.NONE);

                // ChangeTexは、Materialからロードした時と違い、nameにファイル名が設定されてしまうため、
                // 拡張子を除いた名前を再設定
                changedTex = material.GetTexture(propName);
                if (changedTex != null)
                {
                    changedTex.name = texName;
                }
            }
            else
            {
                TBodySkin slot = holder.currentMaid.body0.GetSlot(holder.currentSlot.Name);
                // 直接イメージをロードして適用(要dir指定)
                var mat = holder.GetMaterial(slot, matNo1);
                if (mat == null)
                {
                    return(null);
                }

                byte[] img   = UTY.LoadImage(Path.Combine(dir, filename));
                var    tex2d = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                tex2d.LoadImage(img);
                slot.listDEL.Add(tex2d);
                // tex以外は拡張子を付与したままとする
                tex2d.name = filename;   //Path.GetFileNameWithoutExtension(filename);

                mat.SetTexture(propName, tex2d);
                changedTex = tex2d;
            }

            // テクスチャ変更後は、以前のFilterParamやキャッシュをリセット
            if (srcTex != null)
            {
                textureModifier.RemoveCache(srcTex);
                textureModifier.RemoveFilter(holder.currentMaid, holder.currentSlot.Name, material, srcTex);
            }
            return(changedTex);
        }
Example #5
0
        // Token: 0x060003F8 RID: 1016 RVA: 0x0002322C File Offset: 0x0002142C
        public void ChangeMenu(Maid maid, MaidProp prop)
        {
            if (prop.nFileNameRID == 0 || this.NoAnimMenuId.Contains(prop.nFileNameRID))
            {
                return;
            }
            List <MenuFileHandler.ChangeInfo> list = this.menuHandler.Parse(prop.strFileName);

            if (list == null)
            {
                return;
            }
            bool flag = false;

            foreach (MenuFileHandler.ChangeInfo changeInfo in list)
            {
                TBody.SlotID f_nSlotNo;
                if (EnumUtil.TryParse <TBody.SlotID>(changeInfo.slot, true, out f_nSlotNo))
                {
                    TBodySkin slot = maid.body0.GetSlot((int)f_nSlotNo);
                    if (slot != null && !(slot.obj == null))
                    {
                        TexAnimator texAnimator = slot.obj.transform.GetComponentInChildren <TexAnimator>(false);
                        if (texAnimator == null)
                        {
                            Material[]      materials = this.GetMaterials(slot);
                            List <AnimItem> list2     = this.ParseMaidSlot(slot, materials, changeInfo.matInfos);
                            if (list2 != null)
                            {
                                LogUtil.Debug(new object[]
                                {
                                    "AddComponent for ",
                                    slot,
                                    ", from ",
                                    prop.name
                                });
                                texAnimator      = slot.obj.AddComponent <TexAnimator>();
                                texAnimator.name = "TexAnimator";
                                texAnimator.SetTargets(list2);
                                flag = true;
                            }
                        }
                        else if (changeInfo.matInfos == null)
                        {
                            flag |= texAnimator.ParseMaterials();
                        }
                        else
                        {
                            flag |= texAnimator.ParseMaterials(changeInfo.matInfos);
                        }
                    }
                }
            }
            if (!flag)
            {
                this.NoAnimMenuId.Add(prop.nFileNameRID);
            }
        }
        // Token: 0x0600029E RID: 670 RVA: 0x000163D4 File Offset: 0x000145D4
        public Material[] GetMaterials(TBodySkin slot)
        {
            Renderer renderer = this.GetRenderer(slot);

            if (!(renderer == null))
            {
                return(renderer.materials);
            }
            return(this._emptyList);
        }
        // Token: 0x060002A1 RID: 673 RVA: 0x00016464 File Offset: 0x00014664
        public Renderer GetRenderer(TBodySkin slot)
        {
            GameObject obj = slot.obj;

            if (!(obj == null))
            {
                return(this.GetRenderer(obj, 0));
            }
            return(null);
        }
    public static void SetYureState(Maid maid, int slotNo, bool state)
    {
        bool flag = !maid;

        if (!flag)
        {
            bool flag2 = slotNo == -2 || slotNo == -1;
            if (!flag2)
            {
                bool flag3 = maid.body0.goSlot[slotNo].obj == null;
                if (!flag3)
                {
                    TBoneHair_ bonehair = maid.body0.goSlot[slotNo].bonehair;
                    YureUtil.fi_m_bEnable.SetValue(bonehair, state);
                    TBodySkin        tbodySkin  = maid.body0.goSlot[slotNo];
                    DynamicBone      component  = maid.body0.goSlot[slotNo].obj.GetComponent <DynamicBone>();
                    DynamicSkirtBone component2 = maid.body0.goSlot[slotNo].obj.GetComponent <DynamicSkirtBone>();
                    BoneHair3        bonehair2  = tbodySkin.bonehair3;
                    bool             flag4      = component;
                    if (flag4)
                    {
                        Dictionary <Transform, Vector3>    dictionary  = new Dictionary <Transform, Vector3>();
                        Dictionary <Transform, Quaternion> dictionary2 = new Dictionary <Transform, Quaternion>();
                        Dictionary <Transform, Vector3>    dictionary3 = new Dictionary <Transform, Vector3>();
                        foreach (DynamicBone.Particle particle in component.m_Particles)
                        {
                            dictionary[particle.m_Transform]  = particle.m_Transform.localPosition;
                            dictionary2[particle.m_Transform] = particle.m_Transform.localRotation;
                            dictionary3[particle.m_Transform] = particle.m_Transform.localScale;
                        }
                        component.enabled = state;
                        foreach (DynamicBone.Particle particle2 in component.m_Particles)
                        {
                            particle2.m_Transform.localPosition = dictionary[particle2.m_Transform];
                            particle2.m_Transform.localRotation = dictionary2[particle2.m_Transform];
                            particle2.m_Transform.localScale    = dictionary3[particle2.m_Transform];
                        }
                    }
                    bool flag5 = component2;
                    if (flag5)
                    {
                        component2.enabled = state;
                        if (state)
                        {
                            YureUtil.fi_m_SkirtBone.SetValue(bonehair2, component2);
                        }
                        else
                        {
                            YureUtil.fi_m_SkirtBone.SetValue(bonehair2, null);
                        }
                    }
                }
            }
        }
    }
Example #9
0
        // Token: 0x060003F9 RID: 1017 RVA: 0x000233C4 File Offset: 0x000215C4
        public List <AnimItem> ParseMaidSlot(TBodySkin slot, Material[] mates, IList <MenuFileHandler.MateInfo> miList)
        {
            if (mates == null)
            {
                return(null);
            }
            List <AnimItem> list = null;

            try
            {
                if (miList == null)
                {
                    int num = 0;
                    foreach (Material material in mates)
                    {
                        AnimTex[] array = ParseAnimUtil.ParseAnimTex(material);
                        if (array != null)
                        {
                            if (list == null)
                            {
                                list = new List <AnimItem>();
                            }
                            list.Add(new AnimItem(material, num, array));
                        }
                        num++;
                    }
                }
                else
                {
                    foreach (MenuFileHandler.MateInfo mateInfo in miList)
                    {
                        Material  material2 = mates[mateInfo.matNo];
                        AnimTex[] array2    = ParseAnimUtil.ParseAnimTex(material2);
                        if (array2 != null)
                        {
                            if (list == null)
                            {
                                list = new List <AnimItem>();
                            }
                            list.Add(new AnimItem(material2, mateInfo.matNo, array2));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                LogUtil.Debug(new object[]
                {
                    "slotId:",
                    slot,
                    ex.Message
                });
            }
            return(list);
        }
        public Material GetMaterial(TBodySkin slot, int matNo)
        {
            if (slot.obj == null)
            {
                return(null);
            }

            var r = GetRenderer(slot.obj, matNo);

            return(r != null ? r.materials[matNo] : null);
        }
        public Renderer GetRenderer(TBodySkin slot)
        {
            GameObject gobj = slot.obj;

            if (gobj == null)
            {
                return(null);
            }

            return(GetRenderer(gobj, 0));
        }
Example #12
0
 // Token: 0x060003FA RID: 1018 RVA: 0x000234CC File Offset: 0x000216CC
 private Material[] GetMaterials(TBodySkin slot)
 {
     Renderer[] componentsInChildren = slot.obj.transform.GetComponentsInChildren <Renderer>(true);
     foreach (Renderer renderer in componentsInChildren)
     {
         if (renderer.material != null && renderer.materials.Length > 0 && renderer.material.shader != null)
         {
             return(renderer.materials);
         }
     }
     return(null);
 }
 // Token: 0x060002A7 RID: 679 RVA: 0x0001658C File Offset: 0x0001478C
 public void SetDelNodes(Maid maid, Dictionary <string, bool> dDelNodes, bool bApply)
 {
     if (!dDelNodes.Any <KeyValuePair <string, bool> >())
     {
         return;
     }
     foreach (KeyValuePair <string, bool> keyValuePair in dDelNodes)
     {
         NodeItem nodeItem = ACConstants.NodeNames[keyValuePair.Key];
         if (keyValuePair.Value)
         {
             using (List <TBodySkin> .Enumerator enumerator2 = maid.body0.goSlot.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     TBodySkin tbodySkin = enumerator2.Current;
                     if (!(tbodySkin.obj == null) && tbodySkin.m_dicDelNodeBody.ContainsKey(keyValuePair.Key))
                     {
                         tbodySkin.m_dicDelNodeBody[keyValuePair.Key] = true;
                     }
                 }
                 continue;
             }
         }
         bool flag = false;
         foreach (TBody.SlotID f_nSlotNo in nodeItem.slots)
         {
             TBodySkin slot = maid.body0.GetSlot((int)f_nSlotNo);
             if (!(slot.obj == null))
             {
                 if (slot.m_dicDelNodeBody.ContainsKey(keyValuePair.Key))
                 {
                     slot.m_dicDelNodeBody[keyValuePair.Key] = false;
                 }
                 flag = true;
                 break;
             }
         }
         if (!flag)
         {
             TBodySkin slot2 = maid.body0.GetSlot(0);
             if (!(slot2.obj == null) && slot2.m_dicDelNodeBody.ContainsKey(keyValuePair.Key))
             {
                 slot2.m_dicDelNodeBody[keyValuePair.Key] = false;
             }
         }
     }
     if (bApply)
     {
         this.FixFlag();
     }
 }
        // Token: 0x060002A0 RID: 672 RVA: 0x00016424 File Offset: 0x00014624
        public Material GetMaterial(TBodySkin slot, int matNo)
        {
            if (slot.obj == null)
            {
                return(null);
            }
            Renderer renderer = this.GetRenderer(slot.obj, matNo);

            if (!(renderer != null))
            {
                return(null);
            }
            return(renderer.materials[matNo]);
        }
        private void CreateMorphs()
        {
            Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);

            CreateMorphs(maid.body0.Face);
            for (int i = 0; i < maid.body0.goSlot.Count; i++)
            {
                TBodySkin skin = maid.body0.goSlot[i];
                if (skin != maid.body0.Face)
                {
                    CreateMorphs(skin);
                }
            }
        }
        public List <AnimItem> ParseMaidSlot(TBodySkin slot, Material[] mates, IList <MenuFileHandler.MateInfo> miList)
        {
            if (mates == null)
            {
                return(null);
            }

            // 変更のあったスロットをパースし、マテリアル/テクスチャからアニメーション対象を抽出
            List <AnimItem> targets = null;

            try {
                if (miList == null)
                {
                    var mateNo = 0;
                    foreach (var mate in mates)
                    {
                        var animTexes = ParseAnimUtil.ParseAnimTex(mate);
                        if (animTexes != null)
                        {
                            if (targets == null)
                            {
                                targets = new List <AnimItem>();
                            }
                            targets.Add(new AnimItem(mate, mateNo, animTexes));
                        }
                        mateNo++;
                    }
                }
                else
                {
                    foreach (var mi in miList)
                    {
                        var mate      = mates[mi.matNo];
                        var animTexes = ParseAnimUtil.ParseAnimTex(mate);
                        if (animTexes != null)
                        {
                            if (targets == null)
                            {
                                targets = new List <AnimItem>();
                            }
                            targets.Add(new AnimItem(mate, mi.matNo, animTexes));
                        }
                    }
                }
            } catch (Exception e) {
                LogUtil.Debug("slotId:", slot, e.Message);
            }
            return(targets);
        }
        // Token: 0x060002A3 RID: 675 RVA: 0x00016504 File Offset: 0x00014704
        public Material GetMaterial(string slotName, int matNo)
        {
            TBodySkin slot = this.CurrentMaid.body0.GetSlot(slotName);

            if (slot.obj == null)
            {
                return(null);
            }
            Renderer renderer = this.GetRenderer(slot.obj, matNo);

            if (!(renderer != null))
            {
                return(null);
            }
            return(renderer.materials[matNo]);
        }
Example #18
0
        public static void FaceTypeHook(TBody self, ref string slotname, ref int matno,
                                        ref string prop_name, ref string filename, ref Dictionary <string, byte[]> dicModTexData, ref MaidParts.PARTS_COLOR f_ePartsColorId)
        {
            int       num       = (int)TBody.hashSlotName[slotname];
            TBodySkin tBodySkin = self.goSlot[num];
            string    modelname = (Path.GetFileNameWithoutExtension(tBodySkin.m_strModelFileName));

            int start = modelname.IndexOf("facetype");

            if (slotname == "head" && start != -1 && filename.IndexOf("*") != -1)
            {
                if (!GameUty.FileSystemMod.IsExistentFile(filename.Replace("*", tBodySkin.m_strModelFileName)))
                {
                    string type = modelname.Substring(start + 8, 3);

                    filename = filename.Replace("*", "face" + type);
                }
            }
        }
        /// <summary>
        /// スロットの可視性を設定する.
        /// temporaryにtrueを設定すると可視性のみ設定するがfalseの場合は、スロットへのマスク設定を行う
        /// </summary>
        /// <param name="maskDic">マスク設定Dic</param>
        /// <param name="temporary">一時適用フラグ</param>
        public void SetSlotVisibles(Dictionary <TBody.SlotID, MaskInfo> maskDic, bool temporary)
        {
//            Hashtable m_foceHide = GetMaskTable();
//            if (m_foceHide == null) {
//                LogUtil.Error("cannot take MaskTable");
//                return;
//            }

            foreach (KeyValuePair <TBody.SlotID, MaskInfo> pair in maskDic)
            {
                MaskInfo maskInfo = pair.Value;
                // 未読み込みの場合はスキップ

                if (maskInfo.state == SlotState.NotLoaded)
                {
                    continue;
                }

                maskInfo.slot.boVisible = maskInfo.value;

                if (!temporary)
                {
                    TBodySkin slot = currentMaid.body0.GetSlot((int)pair.Key);
                    if (!maskInfo.value)
                    {
                        slot.listMaskSlot.Add((int)pair.Key);
                    }
                    else
                    {
                        // 全スロットから削除する
                        //slot.listMaskSlot.Remove((int)pair.Key);
                        foreach (TBodySkin tBodySkin in currentMaid.body0.goSlot)
                        {
                            tBodySkin.listMaskSlot.Remove((int)pair.Key);
                        }
                    }
                    // 下記の情報はGetMaskで取得されるフラグに関するものであるが、
                    // maskItemとは別で、下着モード、ヌードモードなどの指定で使われるフラグ
                    //if (!tmp) m_foceHide[pair.Key] = !maskInfo.value;
                }
            }
        }
		static void ImportCMReadMaterialCallback(BinaryReader r, TBodySkin bodyskin, Material existmat, Material retMat)
		{
			Material material = retMat;

			string shaderName = material.shader.name;
			if(! shaders.ContainsKey(shaderName)) {
				string shaderPath = GetShaderPath(shaderName);
				if(System.IO.File.Exists(shaderPath)) {
					string shaderCode = GetShaderCode(shaderPath);
					Material m = new Material(shaderCode);
					if(m.shader != null) {
						DontDestroyOnLoad(m.shader);
						shaders[shaderName] = m.shader;
					}
					Destroy(m);
				}
			}
			Shader newShader;
			if(shaders.TryGetValue(shaderName, out newShader)) {
				material.shader = newShader;
			}
		}
    public static bool GetYureState(Maid maid, int slotNo)
    {
        bool flag = !maid;
        bool result;

        if (flag)
        {
            result = false;
        }
        else
        {
            bool flag2 = slotNo == -2 || slotNo == -1;
            if (flag2)
            {
                result = false;
            }
            else
            {
                bool flag3 = maid.body0.goSlot[slotNo].obj == null;
                if (flag3)
                {
                    result = false;
                }
                else
                {
                    TBoneHair_       bonehair   = maid.body0.goSlot[slotNo].bonehair;
                    bool             flag4      = (bool)YureUtil.fi_m_bEnable.GetValue(bonehair);
                    TBodySkin        tbodySkin  = maid.body0.goSlot[slotNo];
                    DynamicBone      component  = maid.body0.goSlot[slotNo].obj.GetComponent <DynamicBone>();
                    DynamicSkirtBone component2 = maid.body0.goSlot[slotNo].obj.GetComponent <DynamicSkirtBone>();
                    BoneHair3        bonehair2  = tbodySkin.bonehair3;
                    flag4  = (flag4 || (component && component.enabled) || (bonehair2 != null && YureUtil.fi_m_SkirtBone.GetValue(bonehair2) != null));
                    result = flag4;
                }
            }
        }
        return(result);
    }
        // Token: 0x060002AF RID: 687 RVA: 0x00016994 File Offset: 0x00014B94
        public void SetMaskSlots(Maid maid, List <CCSlot> slotList)
        {
            foreach (CCSlot ccslot in slotList)
            {
                if (ccslot.mask != SlotState.NotLoaded)
                {
                    TBodySkin slot = maid.body0.GetSlot((int)ccslot.id);
                    switch (ccslot.mask)
                    {
                    case SlotState.Displayed:
                        foreach (TBodySkin tbodySkin in maid.body0.goSlot)
                        {
                            tbodySkin.listMaskSlot.Remove((int)ccslot.id);
                        }
                        break;

                    case SlotState.Masked:
                        slot.listMaskSlot.Add((int)ccslot.id);
                        break;
                    }
                }
            }
        }
        private bool GetSlotActive(TBodySkin tbs)
        {
            bool flag = tbs == null;
            bool result;

            if (flag)
            {
                result = false;
            }
            else
            {
                bool flag2 = !tbs.obj;
                if (flag2)
                {
                    result = false;
                }
                else
                {
                    bool flag3 = !tbs.boVisible;
                    result = !flag3;
                }
            }
            return(result);
        }
    private bool InitDelNodes(TBodySkin body) {
        if (body == null) {
            if (holder.currentMaid == null) return false;

            const int slotNo = (int)TBody.SlotID.body;
            // 身体からノード一覧と表示状態を取得
            if (slotNo >= holder.currentMaid.body0.goSlot.Count) return false;
            body = holder.currentMaid.body0.GetSlot(slotNo);
        }
        Dictionary<string, bool> dic = body.m_dicDelNodeBody;
        foreach (string key in ACConstants.NodeNames.Keys) {
            bool val;
            if (dic.TryGetValue(key, out val)){
                dDelNodes[key] = val;
            }
        }
        return true;
    }
        public Material[] GetMaterials(TBodySkin slot)
        {
            var renderer = GetRenderer(slot);

            return(renderer == null ? EmptyList : renderer.materials);
        }
Example #26
0
        public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes)
        {
            Maid maid = holder.currentMaid;
            // カレントのメイドデータからプリセットデータを抽出
            var preset = new PresetData();

            preset.name = presetName;
            foreach (SlotInfo slotInfo in ACConstants.SlotNames.Values)
            {
                if (!slotInfo.enable)
                {
                    continue;
                }

                TBodySkin slot = maid.body0.GetSlot((int)slotInfo.Id);
                // マスク情報を抽出
                SlotState maskState;
                if (slot.obj == null)
                {
                    maskState = SlotState.NotLoaded;
                }
                else if (!slot.boVisible)
                {
                    maskState = SlotState.Masked;
                }
                else
                {
                    maskState = SlotState.Displayed;
                }

                Material[] materialList = holder.GetMaterials(slot);
                if (materialList.Length == 0)
                {
                    continue;
                }

                var slotItem = new CCSlot(slotInfo.Id);
                slotItem.mask = maskState;

                foreach (Material material in materialList)
                {
                    var type = ShaderType.Resolve(material.shader.name);
                    if (type == ShaderType.UNKNOWN)
                    {
                        continue;
                    }
                    var cmat = new CCMaterial(material, type);
                    slotItem.Add(cmat);
                    foreach (var texProp in type.texProps)
                    {
                        var tex2d = material.GetTexture(texProp.propId) as Texture2D;
                        if (tex2d == null || string.IsNullOrEmpty(tex2d.name))
                        {
                            continue;
                        }

                        var ti = new TextureInfo();
                        cmat.Add(ti);
                        ti.propName = texProp.keyName;
                        ti.texFile  = tex2d.name;
                        var fp = texModifier.GetFilter(maid, slotInfo.Id.ToString(), material.name, tex2d.name);
                        if (fp != null && !fp.hasNotChanged())
                        {
                            ti.filter = new TexFilter(fp);
                        }
                    }
                }
                preset.slots.Add(slotItem);
            }

            for (int i = TypeUtil.BODY_START; i <= TypeUtil.BODY_END; i++)
            {
                var      mpn = (MPN)Enum.ToObject(typeof(MPN), i);
                MaidProp mp  = maid.GetProp(mpn);
                if (mp != null)
                {
                    if (!String.IsNullOrEmpty(mp.strFileName))
                    {
                        preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
                    }
                    else
                    {
                        preset.mpnvals.Add(new CCMPNValue(mpn, mp.value, mp.min, mp.max));
                    }
                }
            }

            for (int i = TypeUtil.WEAR_START; i <= TypeUtil.WEAR_END; i++)
            {
                var      mpn = (MPN)Enum.ToObject(typeof(MPN), i);
                MaidProp mp  = maid.GetProp(mpn);
                if (mp != null && !String.IsNullOrEmpty(mp.strFileName))
                {
                    preset.mpns.Add(new CCMPN(mpn, mp.strFileName));
                }
            }
//            for (int i = (int)MPN_TYPE_RANGE.FOLDER_BODY_START; i <= (int)MPN_TYPE_RANGE.FOLDER_BODY_END; i++) {
//                var mpn = (MPN)Enum.ToObject(typeof(MPN), i);
//                MaidProp mp = maid.GetProp(mpn);
//                if (mp != null) {
//                    LogUtil.Debug(mpn,":", mp.type, ", value=", mp.value, ", temp=", mp.temp_value, ", file=", mp.strFileName);
//                }
//            }

            // 無限色
            for (int j = TypeUtil.PARTSCOLOR_START; j <= TypeUtil.PARTSCOLOR_END; j++)
            {
                var pcEnum = (MaidParts.PARTS_COLOR)j;
                MaidParts.PartsColor part = maid.Parts.GetPartsColor(pcEnum);
                preset.partsColors[pcEnum.ToString()] = new CCPartsColor(part);
            }

            // 表示ノード
            preset.delNodes = new Dictionary <string, bool>(dDelNodes);

            LogUtil.Debug("create preset...", fileName);
            SavePreset(fileName, preset);
        }
Example #27
0
        // Token: 0x06000375 RID: 885 RVA: 0x0001F3F4 File Offset: 0x0001D5F4
        private Texture ChangeTexFile(string dir, string filename, int matNo1, string propName)
        {
            Texture2D texture2D = this.material.GetTexture(propName) as Texture2D;
            string    text      = Path.GetExtension(filename).ToLower();
            Texture   texture;

            if (text.Length == 0 || text == FileConst.EXT_TEXTURE)
            {
                string name;
                if (text.Length == 0)
                {
                    name      = filename;
                    filename += FileConst.EXT_TEXTURE;
                }
                else
                {
                    name = filename.Substring(0, filename.Length - 4);
                }
                LogUtil.Debug(new object[]
                {
                    "ChangeTex:",
                    filename,
                    ", propName:",
                    propName
                });
                ACCTexturesView.holder.CurrentMaid.body0.ChangeTex(ACCTexturesView.holder.CurrentSlot.Name, matNo1, propName, filename, null, MaidParts.PARTS_COLOR.NONE);
                texture = this.material.GetTexture(propName);
                if (texture != null)
                {
                    texture.name = name;
                }
            }
            else
            {
                TBodySkin slot     = ACCTexturesView.holder.CurrentMaid.body0.GetSlot((int)ACCTexturesView.holder.CurrentSlot.Id);
                Material  material = ACCTexturesView.holder.GetMaterial(slot, matNo1);
                if (material == null)
                {
                    return(null);
                }
                byte[]    data       = UTY.LoadImage(Path.Combine(dir, filename));
                Texture2D texture2D2 = new Texture2D(1, 1, TextureFormat.ARGB32, false);
                texture2D2.LoadImage(data);
                slot.listDEL.Add(texture2D2);
                texture2D2.name = filename;
                LogUtil.Debug(new object[]
                {
                    "SetTexture:",
                    filename,
                    ", propName:",
                    propName,
                    ", (",
                    texture2D2.width,
                    ",",
                    texture2D2.height,
                    ")"
                });
                material.SetTexture(propName, texture2D2);
                texture = texture2D2;
            }
            if (texture2D == null)
            {
                return(texture);
            }
            ACCTexturesView.textureModifier.RemoveCache(texture2D);
            ACCTexturesView.textureModifier.RemoveFilter(ACCTexturesView.holder.CurrentMaid, ACCTexturesView.holder.CurrentSlot.Name, this.material, texture2D);
            return(texture);
        }
 // Token: 0x06000199 RID: 409 RVA: 0x0000F0DD File Offset: 0x0000D2DD
 public MaskInfo(SlotInfo si, TBodySkin slot)
 {
     this.slotInfo = si;
     this.slot     = slot;
 }
Example #29
0
        public void ApplyPresetMaterial(Maid maid, PresetData preset)
        {
            if (maid == null)
            {
                maid = holder.currentMaid;
            }
            if (maid == null)
            {
                return;
            }

            foreach (var ccslot in preset.slots)
            {
                int slotNo = (int)ccslot.id;
                if (slotNo >= maid.body0.goSlot.Count)
                {
                    continue;                                    // スロットがないケースはスキップ
                }
                // スロット上のマテリアル番号での判断に変更
                TBodySkin  slot      = maid.body0.GetSlot(slotNo);
                Material[] materials = holder.GetMaterials(slot);
                if (slot.obj == null)
                {
                    LogUtil.Debug("slot.obj null. name=", ccslot.id);
                }
                if (!materials.Any())
                {
                    continue;                   // 未装着スロットはスキップ
                }
                var slotName = ccslot.id.ToString();
                int matNo    = -1;
                foreach (CCMaterial cmat in ccslot.materials)
                {
                    if (++matNo < materials.Length)
                    {
                        Material m = materials[matNo];
                        if (cmat.name != m.name)
                        {
                            LogUtil.DebugF("Material name mismatched. skipping apply preset-slot={0}, matNo={1}, name=({2}<=>{3})",
                                           ccslot.id, matNo, cmat.name, m.name);
                            continue;
                        }
                        cmat.Apply(m);

                        // テクスチャ適用
                        List <TextureInfo> texes = cmat.texList;
                        if (texes == null)
                        {
                            continue;
                        }

                        foreach (var texInfo in texes)
                        {
                            var tex = m.GetTexture(texInfo.propName);
                            // テクスチャファイルの変更
                            if (tex == null || tex.name != texInfo.texFile)
                            {
                                var filename = texInfo.texFile;
                                if (filename.LastIndexOf('.') == -1)
                                {
                                    filename += FileConst.EXT_TEXTURE;
                                }
                                // if (!filename.EndsWith(FileConst.EXT_TEXTURE, StringComparison.OrdinalIgnoreCase)) {
                                // ファイルが存在する場合にのみ適用
                                if (fileUtil.Exists(filename))
                                {
                                    maid.body0.ChangeTex(slotName, matNo, texInfo.propName, filename, null, MaidParts.PARTS_COLOR.NONE);

                                    // ChangeTexは、nameにファイル名が設定されてしまうため、拡張子を除いた名前を再設定
                                    var changedTex = m.GetTexture(texInfo.propName);
                                    if (changedTex != null)
                                    {
                                        changedTex.name = texInfo.texFile;
                                    }
                                }
                                else
                                {
                                    LogUtil.Debug("texture file not found. file=", filename);
                                }
                            }

                            // フィルタ適用
                            if (texInfo.filter != null)
                            {
                                var fp = texInfo.filter.ToFilter();
                                texModifier.ApplyFilter(maid, slotName, m, texInfo.propName, fp);
                            }
                        }
                    }
                    else
                    {
                        LogUtil.LogF("マテリアル番号に一致するマテリアルが見つかりません。 slot={0}, matNo={1}, name={2}",
                                     ccslot.id, matNo, cmat.name);
                        break;
                    }
                }
            }
        }
Example #30
0
 // Token: 0x0600006A RID: 106 RVA: 0x000079DC File Offset: 0x00005BDC
 public void ApplyPresetMaterial(Maid maid, PresetData preset)
 {
     if (maid == null)
     {
         maid = this._holder.CurrentMaid;
     }
     if (maid == null)
     {
         return;
     }
     foreach (CCSlot ccslot in preset.slots)
     {
         int id = (int)ccslot.id;
         if (id < maid.body0.goSlot.Count)
         {
             TBodySkin  slot      = maid.body0.GetSlot(id);
             Material[] materials = this._holder.GetMaterials(slot);
             if (slot.obj == null)
             {
                 LogUtil.Debug(new object[]
                 {
                     "slot.obj null. name=",
                     ccslot.id
                 });
             }
             if (materials.Any <Material>())
             {
                 string text = ccslot.id.ToString();
                 int    num  = -1;
                 foreach (CCMaterial ccmaterial in ccslot.materials)
                 {
                     if (++num < materials.Length)
                     {
                         Material material = materials[num];
                         if (ccmaterial.name != material.name)
                         {
                             LogUtil.DebugF("Material name mismatched. skipping apply preset-slot={0}, matNo={1}, name=({2}<=>{3})", new object[]
                             {
                                 ccslot.id,
                                 num,
                                 ccmaterial.name,
                                 material.name
                             });
                             continue;
                         }
                         ccmaterial.Apply(material);
                         List <TextureInfo> texList = ccmaterial.texList;
                         if (texList == null)
                         {
                             continue;
                         }
                         using (List <TextureInfo> .Enumerator enumerator3 = texList.GetEnumerator())
                         {
                             while (enumerator3.MoveNext())
                             {
                                 TextureInfo textureInfo = enumerator3.Current;
                                 Texture     texture     = material.GetTexture(textureInfo.propName);
                                 if (texture == null || texture.name != textureInfo.texFile)
                                 {
                                     string text2 = textureInfo.texFile;
                                     if (text2.LastIndexOf('.') == -1)
                                     {
                                         text2 += FileConst.EXT_TEXTURE;
                                     }
                                     if (this._fileUtil.Exists(text2))
                                     {
                                         maid.body0.ChangeTex(text, num, textureInfo.propName, text2, null, MaidParts.PARTS_COLOR.NONE);
                                         Texture texture2 = material.GetTexture(textureInfo.propName);
                                         if (texture2 != null)
                                         {
                                             texture2.name = textureInfo.texFile;
                                         }
                                     }
                                     else
                                     {
                                         LogUtil.Debug(new object[]
                                         {
                                             "texture file not found. file=",
                                             text2
                                         });
                                     }
                                 }
                                 if (textureInfo.offsetX != null || textureInfo.offsetY != null)
                                 {
                                     Vector2 textureOffset = material.GetTextureOffset(textureInfo.propName);
                                     if (textureInfo.offsetX != null)
                                     {
                                         textureOffset.x = textureInfo.offsetX.Value;
                                     }
                                     if (textureInfo.offsetY != null)
                                     {
                                         textureOffset.y = textureInfo.offsetY.Value;
                                     }
                                     material.SetTextureOffset(textureInfo.propName, textureOffset);
                                 }
                                 if (textureInfo.scaleX != null || textureInfo.scaleY != null)
                                 {
                                     Vector2 textureScale = material.GetTextureScale(textureInfo.propName);
                                     if (textureInfo.scaleX != null)
                                     {
                                         textureScale.x = textureInfo.scaleX.Value;
                                     }
                                     if (textureInfo.scaleY != null)
                                     {
                                         textureScale.y = textureInfo.scaleY.Value;
                                     }
                                     material.SetTextureScale(textureInfo.propName, textureScale);
                                 }
                                 if (textureInfo.filter != null)
                                 {
                                     TextureModifier.FilterParam filter = textureInfo.filter.ToFilter();
                                     this._texModifier.ApplyFilter(maid, text, material, textureInfo.propName, filter);
                                 }
                             }
                             continue;
                         }
                     }
                     LogUtil.LogF("ACCPresetに指定されたマテリアル番号に対応するマテリアルが見つかりません。スキップします。 slot={0}, matNo={1}, name={2}", new object[]
                     {
                         ccslot.id,
                         num,
                         ccmaterial.name
                     });
                     break;
                 }
             }
         }
     }
 }
Example #31
0
        // Token: 0x06000066 RID: 102 RVA: 0x00007270 File Offset: 0x00005470
        public void Save(string fileName, string presetName, Dictionary <string, bool> dDelNodes)
        {
            Maid       currentMaid = this._holder.CurrentMaid;
            PresetData presetData  = new PresetData
            {
                name = presetName
            };

            foreach (SlotInfo slotInfo in ACConstants.SlotNames.Values)
            {
                if (slotInfo.enable)
                {
                    TBodySkin slot = currentMaid.body0.GetSlot((int)slotInfo.Id);
                    SlotState mask;
                    if (slot.obj == null)
                    {
                        mask = SlotState.NotLoaded;
                    }
                    else if (!slot.boVisible)
                    {
                        mask = SlotState.Masked;
                    }
                    else
                    {
                        mask = SlotState.Displayed;
                    }
                    Material[] materials = this._holder.GetMaterials(slot);
                    if (materials.Length != 0)
                    {
                        CCSlot ccslot = new CCSlot(slotInfo.Id)
                        {
                            mask = mask
                        };
                        foreach (Material material in materials)
                        {
                            ShaderType shaderType = ShaderType.Resolve(material.shader.name);
                            if (shaderType != ShaderType.UNKNOWN)
                            {
                                CCMaterial ccmaterial = new CCMaterial(material, shaderType);
                                ccslot.Add(ccmaterial);
                                foreach (ShaderPropTex shaderPropTex in shaderType.texProps)
                                {
                                    Texture2D texture2D = material.GetTexture(shaderPropTex.propId) as Texture2D;
                                    if (!(texture2D == null) && !string.IsNullOrEmpty(texture2D.name))
                                    {
                                        TextureInfo textureInfo = new TextureInfo();
                                        ccmaterial.Add(textureInfo);
                                        textureInfo.propName = shaderPropTex.keyName;
                                        textureInfo.texFile  = texture2D.name;
                                        TextureModifier.FilterParam filter = this._texModifier.GetFilter(currentMaid, slotInfo.Id.ToString(), material.name, texture2D.name);
                                        if (filter != null && !filter.HasNotChanged())
                                        {
                                            textureInfo.filter = new TexFilter(filter);
                                        }
                                        Vector2 textureOffset = material.GetTextureOffset(shaderPropTex.propId);
                                        if (Math.Abs(textureOffset.x) > 0.001f)
                                        {
                                            textureInfo.offsetX = new float?(textureOffset.x);
                                        }
                                        if (Math.Abs(textureOffset.y) > 0.001f)
                                        {
                                            textureInfo.offsetY = new float?(textureOffset.y);
                                        }
                                        Vector2 textureScale = material.GetTextureScale(shaderPropTex.propId);
                                        if (Math.Abs(textureScale.x) > 0.001f)
                                        {
                                            textureInfo.scaleX = new float?(textureScale.x);
                                        }
                                        if (Math.Abs(textureScale.y) > 0.001f)
                                        {
                                            textureInfo.scaleY = new float?(textureScale.y);
                                        }
                                    }
                                }
                            }
                        }
                        presetData.slots.Add(ccslot);
                    }
                }
            }
            for (int k = TypeUtil.BODY_START; k <= TypeUtil.BODY_END; k++)
            {
                MPN      mpn  = (MPN)Enum.ToObject(typeof(MPN), k);
                MaidProp prop = currentMaid.GetProp(mpn);
                if (prop != null)
                {
                    if (prop.type == 1 || prop.type == 2)
                    {
                        presetData.mpnvals.Add(new CCMPNValue(mpn, prop.value, prop.min, prop.max));
                    }
                    else if (prop.type == 3 && prop.nFileNameRID != 0)
                    {
                        presetData.mpns.Add(new CCMPN(mpn, prop.strFileName));
                    }
                }
            }
            for (int l = TypeUtil.WEAR_START; l <= TypeUtil.WEAR_END; l++)
            {
                MPN      mpn2  = (MPN)Enum.ToObject(typeof(MPN), l);
                MaidProp prop2 = currentMaid.GetProp(mpn2);
                if (prop2 != null && prop2.nFileNameRID != 0)
                {
                    presetData.mpns.Add(new CCMPN(mpn2, prop2.strFileName));
                }
            }
            for (MaidParts.PARTS_COLOR parts_COLOR = TypeUtil.PARTS_COLOR_START; parts_COLOR <= TypeUtil.PARTS_COLOR_END; parts_COLOR++)
            {
                MaidParts.PartsColor partsColor = currentMaid.Parts.GetPartsColor(parts_COLOR);
                presetData.partsColors[parts_COLOR.ToString()] = new CCPartsColor(partsColor);
            }
            presetData.delNodes = new Dictionary <string, bool>(dDelNodes);
            LogUtil.Debug(new object[]
            {
                "create preset...",
                fileName
            });
            this.SavePreset(fileName, presetData);
        }
 public MaskInfo(SlotInfo si, TBodySkin slot) {
     this.slotInfo = si;
     this.slot = slot;
 }
        public Material GetMaterial(TBodySkin slot, int matNo)
        {
            if (slot.obj == null) return null;

            Transform[] componentsInChildren = slot.obj.transform.GetComponentsInChildren<Transform>(true);
            foreach (Transform tf in componentsInChildren) {
                Renderer r = tf.renderer;
                if (r != null && r.material != null && r.materials.Length > matNo && r.material.shader != null) {
                    return r.materials[matNo];
                }
            }
            return null;
        }
 public Material[] GetMaterials(TBodySkin slot)
 {
     var renderer = GetRenderer(slot);
     return renderer == null ? EmptyList : renderer.materials;
 }
        public Renderer GetRenderer(TBodySkin slot) 
        {
            GameObject gobj = slot.obj;
            if (gobj == null) return null;

            Transform[] componentsInChildren = gobj.transform.GetComponentsInChildren<Transform>(true);
            foreach (Transform tf in componentsInChildren) {
                Renderer r = tf.renderer;
                if (r != null && r.material != null && r.materials.Length > 0 && r.material.shader != null) {
                    // 確認:複数回ヒットするケースが存在するか?
                    // もし、存在するとマテリアル番号と一致しなくなる恐れがあるため存在しないはずだが…
                    return r;
                }
            }
            return null;
        }
    // Token: 0x0600006A RID: 106 RVA: 0x000B857C File Offset: 0x000B757C
    public static Material ReadMaterial(BinaryReader r, TBodySkin bodyskin, Material existmat, string filename)
    {
        existmat = null;
        if (ImportCM2.m_hashPriorityMaterials == null)
        {
            ImportCM2.m_hashPriorityMaterials = new Dictionary <int, KeyValuePair <string, float> >();
            string[] list = GameUty.FileSystem.GetList("prioritymaterial", ListType.AllFile);
            if (list != null && 0 < list.Length)
            {
                for (int i = 0; i < list.Length; i++)
                {
                    if (Path.GetExtension(list[i]) == ".pmat")
                    {
                        string text = list[i];
                        using (AFileBase afileBase = GameUty.FileOpen(text, null))
                        {
                            NDebug.Assert(afileBase.IsValid(), text + "を開けませんでした");
                            byte[] buffer = afileBase.ReadAll();
                            using (BinaryReader binaryReader = new BinaryReader(new MemoryStream(buffer), Encoding.UTF8))
                            {
                                string a = binaryReader.ReadString();
                                NDebug.Assert(a == "CM3D2_PMATERIAL", "ヘッダーエラー\n" + text);
                                int    num   = binaryReader.ReadInt32();
                                int    key   = binaryReader.ReadInt32();
                                string key2  = binaryReader.ReadString();
                                float  value = binaryReader.ReadSingle();
                                NDebug.Assert(!ImportCM2.m_hashPriorityMaterials.ContainsKey(key), "すでにハッシュが登録されています");
                                ImportCM2.m_hashPriorityMaterials.Add(key, new KeyValuePair <string, float>(key2, value));
                            }
                        }
                    }
                }
            }
        }
        string   name  = r.ReadString();
        string   text2 = r.ReadString();
        string   str   = r.ReadString();
        string   path  = "DefMaterial/" + str;
        Material material2;

        if (existmat == null)
        {
            Material material = Resources.Load(path, typeof(Material)) as Material;
            if (material == null)
            {
                return(material);
            }
            material2 = UnityEngine.Object.Instantiate <Material>(material);
        }
        else
        {
            material2 = existmat;
            NDebug.Assert(material2.shader.name == text2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + text2 + " -> " + material2.shader.name);
        }
        material2.name = name;
        int hashCode = material2.name.GetHashCode();

        if (ImportCM2.m_hashPriorityMaterials != null && ImportCM2.m_hashPriorityMaterials.ContainsKey(hashCode))
        {
            KeyValuePair <string, float> keyValuePair = ImportCM2.m_hashPriorityMaterials[hashCode];
            if (keyValuePair.Key == material2.name)
            {
                material2.SetFloat("_SetManualRenderQueue", keyValuePair.Value);
                material2.renderQueue = (int)keyValuePair.Value;
            }
        }
        Vector2 value2;
        Vector2 value3;
        Color   value4;
        Vector4 value5;

        for (;;)
        {
            string a2 = r.ReadString();
            if (a2 == "end")
            {
                break;
            }
            string name2 = r.ReadString();
            if (a2 == "tex")
            {
                string a3 = r.ReadString();
                if (a3 == "null")
                {
                    material2.SetTexture(name2, null);
                }
                else if (a3 == "tex2d")
                {
                    try
                    {
                        string text3 = r.ReadString();
                        string text4 = r.ReadString();
                        byte[] data  = ImportCM.LoadTexture(GameUty.FileSystem, text3 + ".tex", false).data;
                        value2.x = r.ReadSingle();
                        value2.y = r.ReadSingle();
                        value3.x = r.ReadSingle();
                        value3.y = r.ReadSingle();
                        if (filename == null || !filename.Contains(".mate"))
                        {
                            Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                            texture2D.LoadImage(data);
                            texture2D.name     = text3;
                            texture2D.wrapMode = TextureWrapMode.Clamp;
                            material2.SetTexture(name2, texture2D);
                            material2.SetTextureOffset(name2, value2);
                            material2.SetTextureScale(name2, value3);
                        }
                    }
                    catch
                    {
                        break;
                    }
                }
                else if (a3 == "texRT")
                {
                    string text5 = r.ReadString();
                    string text6 = r.ReadString();
                }
            }
            else if (a2 == "col")
            {
                value4.r = r.ReadSingle();
                value4.g = r.ReadSingle();
                value4.b = r.ReadSingle();
                value4.a = r.ReadSingle();
                material2.SetColor(name2, value4);
            }
            else if (a2 == "vec")
            {
                value5.x = r.ReadSingle();
                value5.y = r.ReadSingle();
                value5.z = r.ReadSingle();
                value5.w = r.ReadSingle();
                material2.SetVector(name2, value5);
            }
            else if (a2 == "f")
            {
                float value6 = r.ReadSingle();
                material2.SetFloat(name2, value6);
            }
        }
        if (filename != null && filename.Contains(".mate"))
        {
            try
            {
                using (AFileBase afileBase = GameUty.FileOpen(filename, null))
                {
                    if (ImportCM2.m_matTempFile == null)
                    {
                        ImportCM2.m_matTempFile = new byte[Math.Max(10000, afileBase.GetSize())];
                    }
                    else if (ImportCM2.m_matTempFile.Length < afileBase.GetSize())
                    {
                        ImportCM2.m_matTempFile = new byte[afileBase.GetSize()];
                    }
                    afileBase.Read(ref ImportCM2.m_matTempFile, afileBase.GetSize());
                }
            }
            catch
            {
            }
            BinaryReader binaryReader2 = new BinaryReader(new MemoryStream(ImportCM2.m_matTempFile), Encoding.UTF8);
            string       text7         = binaryReader2.ReadString();
            NDebug.Assert(text7 == "CM3D2_MATERIAL", "ProcScriptBin 例外 : ヘッダーファイルが不正です。" + text7);
            int    num2  = binaryReader2.ReadInt32();
            string text8 = binaryReader2.ReadString();
            r     = binaryReader2;
            name  = r.ReadString();
            text2 = r.ReadString();
            str   = r.ReadString();
            path  = "DefMaterial/" + str;
            if (existmat == null)
            {
                Material material = Resources.Load(path, typeof(Material)) as Material;
                if (material == null)
                {
                    return(material);
                }
                material2 = UnityEngine.Object.Instantiate <Material>(material);
            }
            else
            {
                material2 = existmat;
                NDebug.Assert(material2.shader.name == text2, "マテリアル入れ替えエラー。違うシェーダーに入れようとしました。 " + text2 + " -> " + material2.shader.name);
            }
            material2.name = name;
            hashCode       = material2.name.GetHashCode();
            if (ImportCM2.m_hashPriorityMaterials != null && ImportCM2.m_hashPriorityMaterials.ContainsKey(hashCode))
            {
                KeyValuePair <string, float> keyValuePair = ImportCM2.m_hashPriorityMaterials[hashCode];
                if (keyValuePair.Key == material2.name)
                {
                    material2.SetFloat("_SetManualRenderQueue", keyValuePair.Value);
                    material2.renderQueue = (int)keyValuePair.Value;
                }
            }
            for (;;)
            {
                string a2 = r.ReadString();
                if (a2 == "end")
                {
                    break;
                }
                string name2 = r.ReadString();
                if (a2 == "tex")
                {
                    string a3 = r.ReadString();
                    if (a3 == "null")
                    {
                        material2.SetTexture(name2, null);
                    }
                    else if (a3 == "tex2d")
                    {
                        try
                        {
                            string    text3     = r.ReadString();
                            string    text4     = r.ReadString();
                            byte[]    data      = ImportCM.LoadTexture(GameUty.FileSystem, text3 + ".tex", false).data;
                            Texture2D texture2D = new Texture2D(1, 1, TextureFormat.RGBA32, false);
                            texture2D.LoadImage(data);
                            texture2D.name     = text3;
                            texture2D.wrapMode = TextureWrapMode.Clamp;
                            material2.SetTexture(name2, texture2D);
                            value2.x = r.ReadSingle();
                            value2.y = r.ReadSingle();
                            material2.SetTextureOffset(name2, value2);
                            value3.x = r.ReadSingle();
                            value3.y = r.ReadSingle();
                            material2.SetTextureScale(name2, value3);
                        }
                        catch
                        {
                            break;
                        }
                    }
                    else if (a3 == "texRT")
                    {
                        string text5 = r.ReadString();
                        string text6 = r.ReadString();
                    }
                }
                else if (a2 == "col")
                {
                    value4.r = r.ReadSingle();
                    value4.g = r.ReadSingle();
                    value4.b = r.ReadSingle();
                    value4.a = r.ReadSingle();
                    material2.SetColor(name2, value4);
                }
                else if (a2 == "vec")
                {
                    value5.x = r.ReadSingle();
                    value5.y = r.ReadSingle();
                    value5.z = r.ReadSingle();
                    value5.w = r.ReadSingle();
                    material2.SetVector(name2, value5);
                }
                else if (a2 == "f")
                {
                    float value6 = r.ReadSingle();
                    material2.SetFloat(name2, value6);
                }
            }
        }
        return(material2);
    }