Ejemplo n.º 1
0
        public static void LoadFromSave(string content, bool transparent = true, bool isNeedHandleCamera = true)
        {
            VRCattleManager.currentLoaded = content;
            VRCattleSaveXml saveXml = XmlTool.DeserializeObject <VRCattleSaveXml>(content);

            VRCattleDifferent.DisableObjsStatic(saveXml.isMale);

            int count = saveXml.disable.Count;

            for (int i = 0; i < count; i++)
            {
                string    str = saveXml.disable[i];
                Transform t   = GetTransformByNodeID(str);
                if (t == null)
                {
                    continue;
                }
                VRCattleManager.disabledObjs.Add(t);
                t.gameObject.SetActive(false);
            }

            VRCattleUIManager.instance.Page06SetBodyAndBt20_31State(saveXml.bodyStates);

            if (transparent)
            {
                count = saveXml.transparent.Count;
                for (int i = 0; i < count; i++)
                {
                    Transform t = GetTransformByNodeID(saveXml.transparent[i]);
                    if (t == null)
                    {
                        continue;
                    }
                    MeshRenderer mr = t.GetComponent <MeshRenderer>();
                    VRCattleManager.transparentObjs.Add(mr);
                    Color color = mr.material.color;
                    color.a           = VRCattleManager.transparentValue;
                    mr.material.color = color;
                }
            }

            if (isNeedHandleCamera)
            {
                VRCattleManager.instance.ResetBodyTransform();
                Vector3 center = instance.GetCenter();

                VRCattleCameraControll.instance.isScrollbar = false;
                VRCattleCameraControll.instance.Distance    = 3.5f;
                VRCattleCameraControll.instance.SetTargetPoint(center);
                //VRCattleCameraControll.instance.ChangeDistance();
                VRCattleCameraControll.instance.MoveToTargetPoint();

                VRCattleObjectControll.instance.SetTargetPoint(center);
            }
        }
Ejemplo n.º 2
0
    private void OnGUI()
    {
        root = (Transform)EditorGUILayout.ObjectField(root, typeof(Transform), true);

        if (GUILayout.Button("重置"))
        {
            int count = root.childCount;
            for (int i = 0; i < count; i++)
            {
                root.GetChild(i).gameObject.SetActive(true);
            }
            MeshRenderer[] mr = root.GetComponentsInChildren <MeshRenderer>(true);
            count = mr.Length;
            for (int i = 0; i < count; i++)
            {
                mr[i].gameObject.SetActive(true);
            }
        }

        if (GUILayout.Button("保存"))
        {
            if (root == null)
            {
                return;
            }
            string path = EditorUtility.SaveFilePanel("保存系统存档", Application.dataPath + "/Resources/Tupu", "存档", "txt");
            if (!string.IsNullOrEmpty(path))
            {
                int    count            = root.childCount;
                bool[] bodySystemStates = new bool[count + 1];
                bodySystemStates[count] = true;
                for (int i = 0; i < count; i++)
                {
                    bodySystemStates[i] = root.GetChild(i).gameObject.activeSelf;
                }
                Transform cameraTrans = SceneView.lastActiveSceneView.camera.transform;
                Vector3   euler       = cameraTrans.rotation.eulerAngles;
                euler.x = 0;
                euler.z = 0;
                VRCattle.VRCattleSaveXml xml = new VRCattle.VRCattleSaveXml(GetDisableArray(), bodySystemStates, cameraTrans.position, Quaternion.Euler(euler));
                File.WriteAllText(path, XmlTool.SerializeObject <VRCattle.VRCattleSaveXml>(xml, true));
                AssetDatabase.Refresh();
            }
        }
    }
Ejemplo n.º 3
0
    static void AddMaleFemaleToTupu()
    {
        string path       = Application.dataPath + "/Resources/Tupu/";
        string malePath   = path + "Male/";
        string femalePath = path + "Female/";

        DirectoryInfo directory = new DirectoryInfo(path);

        FileInfo[] infos = directory.GetFiles();
        VRCattle.VRCattleDifferent diff = FindObjectOfType <VRCattle.VRCattleDifferent>();
        int length = infos.Length;

        for (int i = 0; i < length; i++)
        {
            if (infos[i].Extension == ".meta")
            {
                continue;
            }
            StreamReader sr      = infos[i].OpenText();
            string       content = sr.ReadToEnd();
            sr.Dispose();
            sr.Close();
            VRCattle.VRCattleSaveXml male   = XmlTool.DeserializeObject <VRCattle.VRCattleSaveXml>(content);
            VRCattle.VRCattleSaveXml female = XmlTool.DeserializeObject <VRCattle.VRCattleSaveXml>(content);
            male.isMale   = true;
            female.isMale = false;
            diff.AddToVSX(ref male, true);
            diff.AddToVSX(ref female, false);

            if (!Directory.Exists(malePath))
            {
                Directory.CreateDirectory(malePath);
            }
            if (!Directory.Exists(femalePath))
            {
                Directory.CreateDirectory(femalePath);
            }
            File.WriteAllText(malePath + infos[i].Name, XmlTool.SerializeObject <VRCattle.VRCattleSaveXml>(male));
            File.WriteAllText(femalePath + infos[i].Name, XmlTool.SerializeObject <VRCattle.VRCattleSaveXml>(female));
        }
        AssetDatabase.Refresh();
    }
Ejemplo n.º 4
0
        public void AddToVSX(ref VRCattleSaveXml vsx, bool isMale)
        {
            int length = 0;

            if (!isMale)
            {
                length = beiPiMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(beiPiMale[i].transform));
                }
                length = guGeMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(guGeMale[i].transform));
                }
                length = jiRouMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(jiRouMale[i].transform));
                }
                length = linBaMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(linBaMale[i].transform));
                }
                length = miNiaoMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(miNiaoMale[i].transform));
                }
                length = neiFenMiMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(neiFenMiMale[i].transform));
                }
                length = shengZhiMale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(shengZhiMale[i].transform));
                }
            }
            else
            {
                length = beiPiFemale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(beiPiFemale[i].transform));
                }
                length = miNiaoFemale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(miNiaoFemale[i].transform));
                }
                length = shengZhiFemale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(shengZhiFemale[i].transform));
                }
                length = shenJingFemale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(shenJingFemale[i].transform));
                }
                length = xunHuanFemale.Length;
                for (int i = 0; i < length; i++)
                {
                    vsx.disable.Add(VRCattleBusinessLogic.GetNodeIDByTransform(xunHuanFemale[i].transform));
                }
            }
        }