public static void CheckForAllIssues()
    {
        VRAvatar avatar           = null;
        var      sceneGameObjects = new List <GameObject>();
        Scene    scene            = SceneManager.GetActiveScene();

        scene.GetRootGameObjects(sceneGameObjects);

        foreach (var item in sceneGameObjects)
        {
            if (item.GetComponentInChildren <VRAvatar>())
            {
                avatar = item.GetComponentInChildren <VRAvatar>();
                break;
            }
        }

        var forbiddenCallsAndScripts = new Dictionary <string, string>();

        CheckForForbiddenCalls("Library/ScriptAssemblies/Assembly-CSharp.dll", ref forbiddenCallsAndScripts);

        if (HasEditorIssues() ||
            HasRenderingIssues() ||
            HasAvatarIssues(avatar) ||
            HasIncompatiblePackages(AppDomain.CurrentDomain.GetAssemblies().ToList(), out var allItems) ||
            HasForbiddenCalls(forbiddenCallsAndScripts))
        {
            return;
        }

        EditorPrefs.SetBool("HasBuildIssues", false);
    }
    public static void CheckEyes(VRAvatar avatar, out bool eyePosWrong, out bool eyeRotWrong, out List <Camera> eyes)
    {
        eyePosWrong = false;
        eyeRotWrong = false;

        eyes = new List <Camera>
        {
            avatar.Head.CenterEyeCamera,
            avatar.Head.LeftEyeCamera,
            avatar.Head.RightEyeCamera
        };

        foreach (var item in eyes)
        {
            if (item.transform.localEulerAngles != Vector3.zero)
            {
                eyeRotWrong = true;
            }

            if (item.transform.localPosition != Vector3.zero)
            {
                eyePosWrong = true;
            }
        }
    }
    public static bool HasAvatarIssues(VRAvatar avatar)
    {
        if (avatar != null)
        {
            CheckEyes(avatar, out var posWrong, out var rotWrong, out var eyeList);

            if (!posWrong && !rotWrong && avatar.Head.Transform.localPosition == new Vector3(0, 1.7f, 0) && avatar.Head.Transform.localEulerAngles == Vector3.zero)
            {
                return(false);
            }
        }

        EditorPrefs.SetBool("HasBuildIssues", true);
        return(true);
    }
Exemplo n.º 4
0
        private void DisplayVRAvatarTab()
        {
            VRAvatar avatar = null;

            foreach (var item in _sceneGameObjects)
            {
                if (item.GetComponentInChildren <VRAvatar>())
                {
                    avatar = item.GetComponentInChildren <VRAvatar>();
                    break;
                }
            }

            if (!IssuesUtility.HasAvatarIssues(avatar))
            {
                return;
            }

            EditorGUIHelper.DrawTitleFoldout("VR Avatar", ref _showVRAvatar, () =>
            {
                EditorGUI.indentLevel++;

                if (avatar == null)
                {
                    EditorGUIHelper.DrawSpritedLabel("Scene Must Contain A VR Avatar", ErrorTexture, GUILayout.MaxWidth(16), GUILayout.MaxHeight(16));
                    GUILayout.Space(EditorGUIUtility.singleLineHeight);
                    EditorGUI.indentLevel--;
                    return;
                }

                IssuesUtility.CheckEyes(avatar, out var eyePosWrong, out var eyeRotWrong, out var eyes);

                if (avatar.Head.Transform.localEulerAngles != Vector3.zero)
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUIHelper.DrawSpritedLabel("VR Avatar Head rotation must be Zeroed", ErrorTexture, GUILayout.MaxWidth(16), GUILayout.MaxHeight(16));

                    if (GUILayout.Button("Reset Head Rotation"))
                    {
                        avatar.Head.Transform.localEulerAngles = Vector3.zero;
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (avatar.Head.Transform.localPosition != new Vector3(0, 1.7f, 0))
                {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUIHelper.DrawSpritedLabel("VR Avatar Head postion should be (0, 1.7f, 0)", ErrorTexture, GUILayout.MaxWidth(16), GUILayout.MaxHeight(16));

                    if (GUILayout.Button("Reset Head Position"))
                    {
                        avatar.Head.Transform.localPosition = new Vector3(0, 1.7f, 0);
                    }

                    EditorGUILayout.EndHorizontal();
                }

                if (eyePosWrong || eyeRotWrong)
                {
                    if (eyeRotWrong)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUIHelper.DrawSpritedLabel("Eye Local Rotation Must be Zeroed", ErrorTexture, GUILayout.MaxWidth(16), GUILayout.MaxHeight(16));

                        if (GUILayout.Button("Reset Eye Rotation"))
                        {
                            eyes.ForEach(x => x.transform.localEulerAngles = Vector3.zero);
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    if (eyePosWrong)
                    {
                        EditorGUILayout.BeginHorizontal();
                        EditorGUIHelper.DrawSpritedLabel("Eye Local Position Must be Zeroed", ErrorTexture, GUILayout.MaxWidth(16), GUILayout.MaxHeight(16));

                        if (GUILayout.Button("Reset Eye Position"))
                        {
                            eyes.ForEach(x => x.transform.localPosition = Vector3.zero);
                        }

                        EditorGUILayout.EndHorizontal();
                    }

                    GUILayout.Space(EditorGUIUtility.singleLineHeight);
                }

                EditorGUI.indentLevel--;
            });