public void TeleportTo(GameObject teleportObject, GameObject targetObject)
        {
            if (teleportObject == null || targetObject == null)
            {
                logger.LOG("远程传送传送/目标为空" + teleportObject + " / " + targetObject);
            }
            logger.LOG("远程传送 " + GameObjectUtil.GetGameObjectPath(teleportObject) + " 到 " + GameObjectUtil.GetGameObjectPath(targetObject));
            Vector3 position = new Vector3(targetObject.transform.position.x + 3f, targetObject.transform.position.y, targetObject.transform.position.z);

            teleportObject.transform.position = position;
        }
Esempio n. 2
0
 private void ReadCameraState()
 {
     cameraState = "";
     foreach (Camera c in Camera.allCameras)
     {
         if (c != null)
         {
             cameraState += GameObjectUtil.GetGameObjectPath(c.gameObject) + "\n";
             cameraState += "\t farClipPlane :  " + c.farClipPlane + "\n";
             cameraState += "\t nearClipPlane :  " + c.nearClipPlane + "\n";
             cameraState += "\t orthographic :  " + c.orthographic + "\n";
             cameraState += "\t pixelRect :  " + c.pixelRect + "\n";
         }
     }
     cameraState += "current : " + (Camera.current != null ? Camera.current.name : "null") + "\n";
     cameraState += "main : " + (Camera.main != null ? Camera.main.name : "null") + "\n" + "\n";
 }
Esempio n. 3
0
 private void RayGameObject()
 {
     if (GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits != null && GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits.Length > 0)
     {
         string text = "GameObject检测(LeftCtrl + M写入文件)->鼠标位置(" + Input.mousePosition + ")对应的Object(" + GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits.Length + ") : \n";
         foreach (RaycastHit hitInfo in GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits)
         {
             if (hitInfo.collider != null)
             {
                 GameObject gameObject = hitInfo.collider.gameObject;
                 if (gameObject != null)
                 {
                     text += gameObject.name + "->" + GameObjectUtil.GetGameObjectPath(gameObject);
                 }
             }
         }
         GUI.Label(new Rect(Input.mousePosition.x, (-Input.mousePosition.y), Screen.width, Screen.height), text, guiStyle);
         if (Input.GetKey(KeyCode.LeftControl) && Input.GetKey(KeyCode.M))
         {
             WriteText(text, "_mouse.txt");
         }
     }
 }
        public void WindowFunction(int windowsId)
        {
            scrollPoint = GUILayout.BeginScrollView(scrollPoint);
            if (GUILayout.Button("关闭"))
            {
                isShowWindow = false;
            }
            GUILayout.Label("暂时只有列出当前车辆安装的那些部件中的所有螺栓/丝情况(数据仅供参考并非100%准确)");

            foreach (string name in reportDict.Keys)
            {
                GUILayout.Label("");
                GUILayout.Label(name);
                if (reportDict.ContainsKey(name))
                {
                    Dictionary <string, object> partAndBoltDict = reportDict[name] as Dictionary <string, object>;
                    if (partAndBoltDict.ContainsKey(CarReport.BOLT_COUNT) && partAndBoltDict.ContainsKey(CarReport.PART_AND_BOLT))
                    {
                        int boltCount = Convert.ToInt16(partAndBoltDict[CarReport.BOLT_COUNT]);
                        Dictionary <GameObject, List <GameObject> >           partDict     = partAndBoltDict[CarReport.PART_AND_BOLT] as Dictionary <GameObject, List <GameObject> >;
                        Dictionary <GameObject, Dictionary <string, object> > partAttrDict = partAndBoltDict[CarReport.PART_ATTR] as Dictionary <GameObject, Dictionary <string, object> >;

                        GUILayout.Label("已安装部件一共有个" + boltCount + "螺栓/丝");

                        foreach (GameObject partGameObject in partDict.Keys)
                        {
                            string partName = partGameObject.name.Replace("_", " ").Replace("(Clone)", "").Replace("(itemx)", "").Replace("(xxxxx)", "");

                            GUILayout.Label("部件名称:" + partName + "(" + GlobalVariables.GetGlobalVariables().mscTranslate.translateText.TranslateString(partName, TranslateText.DICT_PARTNAME) + ")");
                            GUILayout.Label("路径:" + GameObjectUtil.GetGameObjectPath(partGameObject));
                            List <GameObject> boltPmGameObjectList = partDict[partGameObject];
                            if (boltPmGameObjectList != null)
                            {
                                GUILayout.Label("该部件有" + boltPmGameObjectList.Count + "个螺栓/丝");

                                if (partAttrDict.ContainsKey(partGameObject))
                                {
                                    Dictionary <string, object> partAttrDataDict = partAttrDict[partGameObject];
                                    if (partAttrDataDict.ContainsKey(CarReport.FSM_FLOAT_TIGHTNESS) && partAttrDataDict[CarReport.FSM_FLOAT_TIGHTNESS] != null)
                                    {
                                        FsmFloat fsmFloatTightness = partAttrDataDict[CarReport.FSM_FLOAT_TIGHTNESS] as FsmFloat;

                                        GUILayout.Label("部件螺栓锁定状态 -> 值" + fsmFloatTightness.Value + " -> 完全锁紧值 -> " + (8 * boltPmGameObjectList.Count));
                                        GUILayout.BeginHorizontal();
                                        Color heightLightColor = Color.yellow;
                                        if (fsmFloatTightness.Value == 8 * boltPmGameObjectList.Count)
                                        {
                                            GUILayout.Label("螺栓全部锁紧");
                                            heightLightColor = Color.yellow;
                                        }
                                        else
                                        {
                                            GUILayout.Label("螺栓未完全锁紧");
                                            heightLightColor = Color.red;
                                        }
                                        if (GUILayout.Button("高亮显示"))
                                        {
                                            foreach (GameObject boltGameObject in boltPmGameObjectList)
                                            {
                                                GlobalVariables.GetGlobalVariables().boltTip.HeightLightNotKeyDown(boltGameObject, heightLightColor);
                                            }
                                        }
                                        GUILayout.EndHorizontal();
                                    }
                                    if (partAttrDataDict.ContainsKey(CarReport.FSM_FLOAT_TIREHEALTH) && partAttrDataDict[CarReport.FSM_FLOAT_TIREHEALTH] != null)
                                    {
                                        GUILayout.BeginHorizontal();
                                        FsmFloat fsmFloatTireHealth = partAttrDataDict[CarReport.FSM_FLOAT_TIREHEALTH] as FsmFloat;
                                        GUILayout.Label("部件生命值:" + fsmFloatTireHealth.Value);
                                        if (GUILayout.Button("-0.1"))
                                        {
                                            fsmFloatTireHealth.Value -= 0.1f;
                                        }
                                        if (GUILayout.Button("-1"))
                                        {
                                            fsmFloatTireHealth.Value -= 1f;
                                        }
                                        if (GUILayout.Button("-10"))
                                        {
                                            fsmFloatTireHealth.Value -= 10f;
                                        }
                                        if (GUILayout.Button("0"))
                                        {
                                            fsmFloatTireHealth.Value = 0f;
                                        }
                                        if (GUILayout.Button("100"))
                                        {
                                            fsmFloatTireHealth.Value = 100f;
                                        }
                                        if (GUILayout.Button("+0.1"))
                                        {
                                            fsmFloatTireHealth.Value += 0.1f;
                                        }
                                        if (GUILayout.Button("+1"))
                                        {
                                            fsmFloatTireHealth.Value += 1f;
                                        }
                                        if (GUILayout.Button("+10"))
                                        {
                                            fsmFloatTireHealth.Value += 10f;
                                        }
                                        GUILayout.EndHorizontal();
                                    }
                                }
                                else
                                {
                                    GUILayout.Label("未读取到该部件其它属性");
                                }
                            }
                            else
                            {
                                GUILayout.Label("该部件没有螺栓/丝");
                            }
                        }
                    }
                }
            }

            GUILayout.EndScrollView();
            GUI.DragWindow();
        }
Esempio n. 5
0
        private void RayGameObject()
        {
            if (GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits != null && GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits.Length > 0)
            {
                string text = "";
                foreach (RaycastHit hitInfo in GlobalVariables.GetGlobalVariables().physicsRaycast.mainCameraRaycastHits)
                {
                    GameObject targetGameObject = hitInfo.collider.gameObject;
                    if (GlobalVariables.GetGlobalVariables().gameObjectSatsuma == targetGameObject.transform.root.gameObject
                        ||
                        (
                            GlobalVariables.GetGlobalVariables().gameObjectEngine != null &&
                            GlobalVariables.GetGlobalVariables().gameObjectEngine == targetGameObject.transform.root.gameObject
                        )
                        )
                    {
                        Color             heightLightColor        = Color.yellow;
                        GameObject        partAssembledGameObject = null;
                        FsmFloat          fsmFloatTightness       = null;
                        FsmFloat          fsmFloatTireHealth      = null;
                        FsmString         fsmStringPart           = null;
                        List <GameObject> allBoltPmGameObjectList = null;


                        if (targetGameObject.name.ToLower().IndexOf("boltpm") > -1)
                        {
                            PlayMakerFSM[] playMakerFSMArray = targetGameObject.GetComponents <PlayMakerFSM>();

                            foreach (PlayMakerFSM playMakerFSM in playMakerFSMArray)
                            {
                                if (playMakerFSM != null && playMakerFSM.FsmName != null && playMakerFSM.FsmName.ToLower().Equals("screw"))
                                {
                                    FsmGameObject fsmGameObject = playMakerFSM.FsmVariables.FindFsmGameObject("PartAssembled");
                                    if (fsmGameObject != null)
                                    {
                                        partAssembledGameObject = fsmGameObject.Value;
                                    }
                                }
                            }
                            GameObject parentGameObject = targetGameObject.transform.parent.gameObject;
                            if (parentGameObject != null)
                            {
                                allBoltPmGameObjectList = GameObjectUtil.GetChildGameObjectLikeName(parentGameObject, "boltpm");
                            }

                            PlayMakerFSM[] partAssembledPlayMakerFSMArray = partAssembledGameObject.GetComponents <PlayMakerFSM>();

                            foreach (PlayMakerFSM playMakerFSM in partAssembledPlayMakerFSMArray)
                            {
                                if (playMakerFSM != null && playMakerFSM.FsmName != null &&
                                    (
                                        playMakerFSM.FsmName.ToLower().Equals("use") ||
                                        playMakerFSM.FsmName.ToLower().Equals("boltcheck")
                                    )
                                    )
                                {
                                    fsmFloatTightness  = playMakerFSM.FsmVariables.FindFsmFloat("Tightness");
                                    fsmFloatTireHealth = playMakerFSM.FsmVariables.FindFsmFloat("TireHealth");
                                }
                                if (playMakerFSM != null && playMakerFSM.FsmName != null && playMakerFSM.FsmName.ToLower().Equals("paint"))
                                {
                                    fsmStringPart = playMakerFSM.FsmVariables.FindFsmString("Part");
                                }
                            }
                            if (partAssembledGameObject == null || fsmFloatTightness == null) // || fsmFloatTireHealth == null || fsmStringPart == null)
                            {
                                text += "\n 取不到部件数据 路径 -> partAssembled:" + partAssembledGameObject + " Tightness:" + fsmFloatTightness + " TireHealth:" + fsmFloatTireHealth + " Part" + fsmStringPart + "\n";
                                text += "\n -> " + GameObjectUtil.GetGameObjectPath(targetGameObject) + "\n";
                            }
                            else
                            {
                                text += "\n -> " + GameObjectUtil.GetGameObjectPath(targetGameObject) + "\n";
                                if (fsmStringPart == null)
                                {
                                    text += "\n 部件名称 -> (GameObject)" + partAssembledGameObject.name.Replace("(Clone)", "").Replace("(itemx)", "").Replace("(xxxxx)", "") + "\n";
                                }
                                else
                                {
                                    text += "\n 部件名称 -> (PART)" + fsmStringPart.Value + "\n";
                                }
                                if (fsmFloatTireHealth == null)
                                {
                                    text += "\n 部件生命值 -> 无\n";
                                }
                                else
                                {
                                    text += "\n 部件生命值 -> " + fsmFloatTireHealth.Value + "\n";
                                }
                                text += "\n 部件螺栓情况 -> " + fsmFloatTightness.Value + " -> ";
                                if (allBoltPmGameObjectList.Count * 8 == fsmFloatTightness.Value)
                                {
                                    text            += "已经锁紧";
                                    heightLightColor = Color.yellow;
                                }
                                else
                                {
                                    text            += "尚未锁紧,请检查.";
                                    heightLightColor = Color.red;
                                }
                                text += "\n一共应该有" + allBoltPmGameObjectList.Count + "个螺栓/丝";
                                text += "应该是" + Convert.ToInt32(Math.Round(targetGameObject.transform.localScale.x * 10)) + "号扳手";

                                foreach (GameObject gameObject in allBoltPmGameObjectList)
                                {
                                    if (gameObject == targetGameObject)
                                    {
                                        continue;
                                    }
                                    HeightLight(gameObject, heightLightColor);
                                }
                            }
                        }
                    }
                }
                GUI.Label(new Rect(Input.mousePosition.x, (-Input.mousePosition.y), Screen.width, Screen.height), text, mouseTipGuiStyle);
            }
        }
        private void DevelopConfigWindowsFunction(int windowsId)
        {
            scrollPosition = GUILayout.BeginScrollView(scrollPosition);
            if (GUILayout.Button("关闭"))
            {
                IsEnable = false;
            }
            GUILayout.Label("左Ctrl+R,重新读取所有txt文本");
            GUILayout.Label("左Ctrl+W,写入Systems下的GameObject到txt");
            GUILayout.Label("左Ctrl+F,写入所有FsmVariables变量到FsmVariables.txt");
            GUILayout.Label("左Ctrl+F,写入所有FsmVariables变量到FsmVariables.txt");
            GlobalVariables.GetGlobalVariables().develop.isRayGameObject = GUILayout.Toggle(GlobalVariables.GetGlobalVariables().develop.isRayGameObject, "是否显示鼠标指向的GameObject信息");

            GlobalVariables.GetGlobalVariables().guiGameObjectExplorer.IsEnable = GUILayout.Toggle(GlobalVariables.GetGlobalVariables().guiGameObjectExplorer.IsEnable, "是否启用GUI GameObject查看");
            if (GUILayout.Button("GUI GameObject 查看窗口"))
            {
                GlobalVariables.GetGlobalVariables().guiGameObjectExplorer.isShow = true;
            }

            if (GUILayout.Button("读取所有Renderer名到文件"))
            {
                Renderer[] renderers = Resources.FindObjectsOfTypeAll <Renderer>();
                string     text      = "";
                foreach (Renderer renderer in renderers)
                {
                    text += renderer.name + "\n";
                    text += "  " + GameObjectUtil.GetGameObjectPath(renderer.gameObject) + "\n";
                }
                File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_renderers.txt"), new string[] { text });
            }

            if (GUILayout.Button("读取所有Material名到文件"))
            {
                Material[] materials = Resources.FindObjectsOfTypeAll <Material>();
                string     text      = "";
                foreach (Material material in materials)
                {
                    text += material.name + "\n";
                }
                File.WriteAllLines(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_materials.txt"), new string[] { text });
            }

            if (GUILayout.Button("重新初始化Mod全局变量"))
            {
                GlobalVariables.GetGlobalVariables().Init();
            }
            isShowGlobalVariablesValue = GUILayout.Toggle(isShowGlobalVariablesValue, "是否显示Mod全局变量详情");
            if (isShowGlobalVariablesValue)
            {
                ShowGlobalVariablesValue();
            }

            isShowAllExecutionTime = GUILayout.Toggle(isShowAllExecutionTime, "是否显示Mod执行效率详情");
            if (isShowAllExecutionTime)
            {
                ShowAllExecutionTime();
            }

            isShowCameraData = GUILayout.Toggle(isShowCameraData, "是否显示摄像机详情");
            if (isShowCameraData)
            {
                ShowCameraData();
            }

            isShowGameOverGameObjectCheck = GUILayout.Toggle(isShowGameOverGameObjectCheck, "是否显示GameOver变量详情");
            if (isShowGameOverGameObjectCheck)
            {
                ShowGameOverGameObjectCheck();
            }

            isShowGameObjectTransformUpdate = GUILayout.Toggle(isShowGameObjectTransformUpdate, "是否显示GameObject位置微调");
            if (isShowGameObjectTransformUpdate)
            {
                ShowGameObjectTransformUpdate();
            }
            isViewFsmAllVariablesAndVaule = GUILayout.Toggle(isViewFsmAllVariablesAndVaule, "是否显示所有游戏内全局变量");
            if (isViewFsmAllVariablesAndVaule)
            {
                ViewFsmAllVariablesAndVaule();
            }

            GUILayout.EndScrollView();
            GUI.DragWindow();
        }
        private void ShowGameObjectTransformUpdate()
        {
            GUILayout.BeginHorizontal("box");
            GUILayout.Label("GameObject Path:");
            targetGameObjectPath = GUILayout.TextField(targetGameObjectPath);
            if (GUILayout.Button("获取目标"))
            {
                targetGameObject = GameObject.Find(targetGameObjectPath);
            }
            if (targetGameObject != null)
            {
                GUILayout.Label("目标GameObject:" + GameObjectUtil.GetGameObjectPath(targetGameObject));
            }
            GUILayout.EndHorizontal();

            if (targetGameObject != null)
            {
                GUILayout.BeginHorizontal("box");
                GUILayout.Label("目标GameObject位置微调");
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("position");
                string positionXStr = Convert.ToString(targetGameObject.transform.position.x);
                string positionYStr = Convert.ToString(targetGameObject.transform.position.y);
                string positionZStr = Convert.ToString(targetGameObject.transform.position.z);
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr) - 1f, float.Parse(positionYStr), float.Parse(positionZStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr) - 0.1f, float.Parse(positionYStr), float.Parse(positionZStr));
                }
                positionXStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.position.x));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr) + 0.1f, float.Parse(positionYStr), float.Parse(positionZStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr) + 1f, float.Parse(positionYStr), float.Parse(positionZStr));
                }
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr) - 1f, float.Parse(positionZStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr) - 0.1f, float.Parse(positionZStr));
                }
                positionYStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.position.y));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr) + 0.1f, float.Parse(positionZStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr) + 1f, float.Parse(positionZStr));
                }
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr), float.Parse(positionZStr) - 1f);
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr), float.Parse(positionZStr) - 0.1f);
                }
                positionZStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.position.z));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr), float.Parse(positionZStr) + 0.1f);
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.position = new Vector3(float.Parse(positionXStr), float.Parse(positionYStr), float.Parse(positionZStr) + 1f);
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("position");
                string rotationXStr = Convert.ToString(targetGameObject.transform.rotation.x);
                string rotationYStr = Convert.ToString(targetGameObject.transform.rotation.y);
                string rotationZStr = Convert.ToString(targetGameObject.transform.rotation.z);
                string rotationWStr = Convert.ToString(targetGameObject.transform.rotation.w);
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr) - 1f, float.Parse(rotationYStr), float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr) - 0.1f, float.Parse(rotationYStr), float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                positionXStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.rotation.x));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr) + 0.1f, float.Parse(rotationYStr), float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr) + 1f, float.Parse(rotationYStr), float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr) - 1f, float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr) - 0.1f, float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                positionYStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.rotation.y));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr) + 0.1f, float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr) + 1f, float.Parse(rotationZStr), float.Parse(rotationWStr));
                }
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr), float.Parse(rotationZStr) - 1f, float.Parse(rotationWStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr), float.Parse(rotationZStr) - 0.1f, float.Parse(rotationWStr));
                }
                positionZStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.rotation.z));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr), float.Parse(rotationZStr) + 0.1f, float.Parse(rotationWStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.rotation = new Quaternion(float.Parse(rotationXStr), float.Parse(rotationYStr), float.Parse(rotationZStr) + 1f, float.Parse(rotationWStr));
                }
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal("box");
                GUILayout.Label("position");
                string localScaleXStr = Convert.ToString(targetGameObject.transform.localScale.x);
                string localScaleYStr = Convert.ToString(targetGameObject.transform.localScale.y);
                string localScaleZStr = Convert.ToString(targetGameObject.transform.localScale.z);
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr) - 1f, float.Parse(localScaleYStr), float.Parse(localScaleZStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr) - 0.1f, float.Parse(localScaleYStr), float.Parse(localScaleZStr));
                }
                positionXStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.localScale.x));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr) + 0.1f, float.Parse(localScaleYStr), float.Parse(localScaleZStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr) + 1f, float.Parse(localScaleYStr), float.Parse(localScaleZStr));
                }
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr) - 1f, float.Parse(localScaleZStr));
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr) - 0.1f, float.Parse(localScaleZStr));
                }
                positionYStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.localScale.y));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr) + 0.1f, float.Parse(localScaleZStr));
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr) + 1f, float.Parse(localScaleZStr));
                }
                if (GUILayout.Button("<"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr), float.Parse(localScaleZStr) - 1f);
                }
                if (GUILayout.Button("<<"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr), float.Parse(localScaleZStr) - 0.1f);
                }
                positionZStr = GUILayout.TextField(Convert.ToString(targetGameObject.transform.localScale.z));
                if (GUILayout.Button(">>"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr), float.Parse(localScaleZStr) + 0.1f);
                }
                if (GUILayout.Button(">"))
                {
                    targetGameObject.transform.localScale = new Vector3(float.Parse(localScaleXStr), float.Parse(localScaleYStr), float.Parse(localScaleZStr) + 1f);
                }
                GUILayout.EndHorizontal();
            }
        }
Esempio n. 8
0
        private void GuiGameObjectExplorerWindows(int windowsId)
        {
            if (GUILayout.Button("关闭 unity版本:" + Application.unityVersion))
            {
                isShow = false;
            }

            try
            {
                scrollPosition = GUILayout.BeginScrollView(scrollPosition);

                GUILayout.BeginArea(new Rect(0, 0, 500, 600));

                if (GUILayout.Button("所有GameObject列表(先输筛选的文本再点)"))
                {
                    parentGameObject = null;
                    gameObjectList   = GameObjectUtil.GetAllGameObject();
                }
                if (GUILayout.Button("所有GameObject写入txt(out目录,会卡到吐血)"))
                {
                    parentGameObject = null;
                    gameObjectList   = GameObjectUtil.GetAllGameObject();
                    string text  = "";
                    int    index = 0;
                    foreach (GameObject gameObject in gameObjectList)
                    {
                        text += GameObjectUtil.GetGameObjectText(gameObject, 0, true, true, true, false, false);
                        text += "\n";
                        logger.LOG("写入gameObject ->" + index++);
                        File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "out/_AllGameObject" + index + "_" + gameObject.name + ".txt"), text);
                    }
                }

                GUILayout.BeginHorizontal();
                if (GUILayout.Button("读取根节点"))
                {
                    parentGameObject = null;
                    // gameObjectList = new List<GameObject>(Application. UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects());
                    gameObjectList = GameObjectUtil.GetRootGameObject();
                }

                if (parentGameObject != null)
                {
                    if (GUILayout.Button("<"))
                    {
                        if (parentGameObject.transform.parent == null)
                        {
                            parentGameObject = null;
                            gameObjectList   = GameObjectUtil.GetRootGameObject();
                            // gameObjectList = new List<GameObject>( UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects());
                        }
                        else
                        {
                            gameObjectList   = GameObjectUtil.GetChildGameObjectList(parentGameObject.transform.parent.gameObject);
                            parentGameObject = parentGameObject.transform.parent.gameObject;
                        }
                    }
                }
                GUILayout.EndHorizontal();
                searchName = GUILayout.TextField(searchName);

                gameObjectListScrollPosition = GUILayout.BeginScrollView(gameObjectListScrollPosition);
                if (gameObjectList != null)
                {
                    foreach (GameObject gameObject in gameObjectList)
                    {
                        if (searchName != null && !searchName.Equals(""))
                        {
                            if (gameObject.name.ToLower().IndexOf(searchName.ToLower()) == -1)
                            {
                                continue;
                            }
                        }
                        GUILayout.BeginHorizontal();
                        if (GUILayout.Button(gameObject.name))
                        {
                            selectGameObject          = gameObject;
                            selectGameObjectComponent = new List <Component>(gameObject.GetComponents <Component>());
                        }
                        if (GUILayout.Button(">"))
                        {
                            parentGameObject = gameObject;
                            gameObjectList   = GameObjectUtil.GetChildGameObjectList(gameObject);
                        }
                        if (GUILayout.Button("传过去"))
                        {
                            GlobalVariables.GetGlobalVariables().teleport.TeleportTo(GameObjectUtil.GetGameObjectPath(gameObject));
                        }
                        if (GUILayout.Button("传过来"))
                        {
                            GameObject playerGameObject = GameObject.Find("PLAYER");
                            Vector3    clonePosition    = new Vector3(playerGameObject.transform.position.x, playerGameObject.transform.position.y + 3f, playerGameObject.transform.position.z);
                            gameObject.transform.position = clonePosition;
                        }
                        if (GUILayout.Button("克隆"))
                        {
                            GameObject playerGameObject = GameObject.Find("PLAYER");
                            Vector3    clonePosition    = new Vector3(playerGameObject.transform.position.x, playerGameObject.transform.position.y + 3f, playerGameObject.transform.position.z);
                            // GameObject cloneGameObject = MonoBehaviour.Instantiate(gameObject, clonePosition, gameObject.transform.rotation) as GameObject;
                            gameObject.SetActive(false);
                            GameObject cloneGameObject = GameObject.Instantiate(gameObject);
                            cloneGameObject.transform.position = clonePosition;
                        }
                        if (gameObject.activeSelf == false)
                        {
                            if (GUILayout.Button("启用"))
                            {
                                gameObject.SetActive(true);
                            }
                        }
                        else
                        {
                            if (GUILayout.Button("禁用"))
                            {
                                gameObject.SetActive(false);
                            }
                        }

                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();

                GUILayout.EndArea();


                GUILayout.BeginArea(new Rect(500, 0, 500, 600));
                if (selectGameObject != null)
                {
                    GUILayout.Label("选中GameObject:" + GameObjectUtil.GetGameObjectPath(selectGameObject));
                    if (GUILayout.Button("写入txt"))
                    {
                        File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObject.txt"), GameObjectUtil.GetGameObjectText(selectGameObject, 0, true, true, true, false, false));
                    }

                    viewScrollPosition = GUILayout.BeginScrollView(viewScrollPosition);
                    string text = "";
                    foreach (Component component in selectGameObjectComponent)
                    {
                        Type type = component.GetType();
                        GUILayout.Label(type.FullName);
                        GUILayout.BeginVertical("box");
                        foreach (FieldInfo fieldInfo in type.GetFields())
                        {
                            string view = fieldInfo.Name + " : " + fieldInfo.GetValue(component);
                            text += view + "\n";
                            GUILayout.Label(view);
                        }
                        foreach (PropertyInfo propertyInfo in type.GetProperties())
                        {
                            try
                            {
                                string view = "  " + propertyInfo.Name + " : \n" + propertyInfo.GetValue(component, null);
                                text += view + "\n";
                                GUILayout.Label(view);
                            }
                            catch (Exception e)
                            {
                                string view = "  " + propertyInfo.Name + " : \n Error " + e.Message;
                                text += view + "\n";
                                GUILayout.Label(view);
                            }
                        }
                        if (component.GetType().Name.Equals("PlayMakerFSM"))
                        {
                            PlayMakerFSM playMakerFSM = component as PlayMakerFSM;
                            string       view         = "Component is PlayMakerFSM : \n" + FsmVariablesUtil.GetAllFsmVariablesAndVaule(playMakerFSM.FsmVariables);
                            text += view + "\n";
                            GUILayout.Label(view);
                        }

                        GUILayout.EndVertical();
                    }
                    if (GUILayout.Button("写入显示内容到txt"))
                    {
                        File.WriteAllText(Path.Combine(ModLoader.GetModAssetsFolder(GlobalVariables.GetGlobalVariables().mscTranslateChs), "_gameObjectViewText.txt"), text);
                    }
                    GUILayout.EndScrollView();
                }
                GUILayout.EndArea();


                GUILayout.EndScrollView();
            }
            catch (Exception e)
            {
                GUILayout.Label("exception : " + e.Message);
            }
            GUI.DragWindow();
        }