胡佳骏 1 rok temu
commit
fb3ded7177

+ 37 - 0
CONTRIBUTING.md

@@ -0,0 +1,37 @@
+# How to Contribute
+
+Please use the [issue tracker](https://github.com/googlevr/cardboard-xr-plugin/issues)
+to report any bugs or request specific features.
+
+We are happy to review your pull requests.
+
+Follow these steps to contribute changes.
+
+1. Sign our Contributor License Agreement (see below).
+2. Submit a pull request on GitHub.
+
+Here's how your pull request is processed.
+
+3. We will review your changes and leave comments on the pull request.
+4. If accepted, we will merge it into our internal repo and tag the pull request with the "fixed in an upcoming release" label.
+5. After the new version is released, we will close the pull request.
+6. Your change will appear in a future release.
+
+
+## Contributor License Agreement
+
+Contributions to this project must be accompanied by a Contributor License
+Agreement (CLA). You (or your employer) retain the copyright to your
+contribution; this simply gives us permission to use and redistribute your
+contributions as part of the project. Head over to
+<https://cla.developers.google.com/> to see your current agreements on file or
+to sign a new one.
+
+You generally only need to submit a CLA once, so if you've already submitted one
+(even if it was for a different project), you probably don't need to do it
+again.
+
+## Community Guidelines
+
+This project follows
+[Google's Open Source Community Guidelines](https://opensource.google/conduct/).

+ 7 - 0
CONTRIBUTING.md.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: aed612770682f404bba2db8bc8a2e79e
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Editor.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: f1e076de859fa49d7bf78a294d512bd7
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 29 - 0
Editor/BuildPostProcessor.cs

@@ -0,0 +1,29 @@
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+
+#if UNITY_EDITOR && UNITY_IOS
+
+namespace Rokid.XR.Core.Editor
+{
+    using System.Collections.Generic;
+    using System.IO;
+    using UnityEditor;
+    using UnityEditor.Callbacks;
+    using UnityEngine;
+
+    /// <summary>Processes the project files after the build is performed.</summary>
+    public static class BuildPostProcessor
+    {
+        /// <summary>Unity callback to process after build.</summary>
+        /// <param name="buildTarget">Target built.</param>
+        /// <param name="path">Path to built project.</param>
+        [PostProcessBuild]
+        public static void OnPostProcessBuild(BuildTarget buildTarget, string path)
+        {
+            
+        }
+    }
+}
+
+#endif

+ 11 - 0
Editor/BuildPostProcessor.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 91fd4af74c46d40d1ba9ef77bf5ec35f
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 22 - 0
Editor/Rokid.XR.Core.Editor.asmdef

@@ -0,0 +1,22 @@
+{
+    "name": "Rokid.XR.Core.Editor",
+    "references": [
+        "Unity.XR.Management.Editor",
+        "Unity.XR.Management",
+        "Rokid.XR.Core"
+    ],
+    "includePlatforms": ["Editor"],
+    "excludePlatforms": [],
+    "allowUnsafeCode": false,
+    "overrideReferences": false,
+    "precompiledReferences": [],
+    "autoReferenced": true,
+    "defineConstraints": [],
+    "versionDefines": [
+        {
+            "name": "com.unity.xr.management",
+            "expression": "3.2.0",
+            "define": "XR_MGMT_GTE_320"
+        }
+    ]
+}

+ 7 - 0
Editor/Rokid.XR.Core.Editor.asmdef.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: ad91be1e774094f99afb64ef26c07397
+AssemblyDefinitionImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 67 - 0
Editor/UXRCoreMetadata.cs

@@ -0,0 +1,67 @@
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+
+#if XR_MGMT_GTE_320
+
+namespace Rokid.XR.Core.Editor
+{
+    using System.Collections.Generic;
+    using UnityEditor;
+    using UnityEditor.XR.Management.Metadata;
+    using UnityEngine;
+
+    /// <summary>
+    /// XR Metadata for XR Plugin.
+    /// Required by XR Management package.
+    /// </summary>
+    public class UXRCorePackage : IXRPackage
+    {
+        /// <summary>
+        /// Package metadata instance.
+        /// </summary>
+        public IXRPackageMetadata metadata => new PackageMetadata();
+
+        /// <summary>
+        /// Populates package settings instance.
+        /// </summary>
+        ///
+        /// <param name="obj">
+        /// Settings object.
+        /// </param>
+        /// <returns>Settings analysis result. Given that nothing is done, returns true.</returns>
+        public bool PopulateNewSettingsInstance(ScriptableObject obj)
+        {
+            return true;
+        }
+
+        private class LoaderMetadata : IXRLoaderMetadata
+        {
+            public string loaderName => "Rokid XR Core";
+
+            public string loaderType => typeof(Rokid.XR.Core.XRLoader).FullName;
+
+            public List<BuildTargetGroup> supportedBuildTargets => new List<BuildTargetGroup>()
+            {
+                BuildTargetGroup.Android,
+               
+            };
+        }
+
+        private class PackageMetadata : IXRPackageMetadata
+        {
+            public string packageName => "Rokid XR Core";
+
+            public string packageId => "com.rokid.xr.core";
+
+            public string settingsType => typeof(Rokid.XR.Core.XRSettings).FullName;
+
+            public List<IXRLoaderMetadata> loaderMetadata => new List<IXRLoaderMetadata>()
+            {
+                new LoaderMetadata()
+            };
+        }
+    }
+}
+
+#endif // XR_MGMT_GTE_320

+ 11 - 0
Editor/UXRCoreMetadata.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: bb13b6275703767449f390565bf6d7c8
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 817 - 0
Editor/UXREnvFix.cs

@@ -0,0 +1,817 @@
+using System.Net.Http.Headers;
+using System.IO;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.Rendering;
+using UnityEngine.XR.Management;
+using UnityEditor.XR.Management;
+
+namespace Rokid.UXR.Editor
+{
+    [InitializeOnLoad]
+    public class UXREnvFix : EditorWindow
+    {
+        #region  Config
+        private const string ignorePrefix = "UXREnvFix";
+        private static FixItem[] fixItems;
+        private static UXREnvFix window;
+        private Vector2 scrollPosition;
+        private static string minUnityVersion = "2020.3.26";
+        private static AndroidSdkVersions minSdkVersion = AndroidSdkVersions.AndroidApiLevel26;
+        private static AndroidArchitecture targetArchitecture = AndroidArchitecture.ARM64;
+
+        #endregion
+
+        static UXREnvFix()
+        {
+            EditorApplication.update -= OnUpdate;
+            EditorApplication.update += OnUpdate;
+        }
+
+        private static void OnUpdate()
+        {
+            bool show = false;
+
+            if (fixItems == null) { RegisterItems(); }
+            foreach (var item in fixItems)
+            {
+                if (!item.IsIgnored() && !item.IsValid() && item.Level > MessageType.Warning && item.IsAutoPop())
+                {
+                    show = true;
+                }
+            }
+
+            if (show)
+            {
+                ShowWindow();
+            }
+
+            EditorApplication.update -= OnUpdate;
+        }
+
+        private static void RegisterItems()
+        {
+            fixItems = new FixItem[]
+            {
+                new CheckBuildTarget(MessageType.Error),
+                new CheckUnityMinVersion(MessageType.Error), 
+            #if UNITY_2020_3_OR_NEWER
+	            new CheckCardboardPackage(MessageType.Error),//Should NOT add Cardboard Package into project
+            #endif 
+	            new CkeckMTRendering(MessageType.Error),
+                new CkeckAndroidGraphicsAPI(MessageType.Error),
+                new CkeckAndroidOrientation(MessageType.Warning),
+	            // new CkeckColorSpace(MessageType.Warning),
+	            new CheckOptimizedFramePacing(MessageType.Warning),
+                new CheckMinmumAPILevel(MessageType.Error),
+                new CheckArchitecture(MessageType.Error)
+            };
+        }
+
+        [MenuItem("UXR/Env/Project Environment Fix", false)]
+        public static void ShowWindow()
+        {
+            RegisterItems();
+            window = GetWindow<UXREnvFix>(true);
+            window.minSize = new Vector2(320, 300);
+            window.maxSize = new Vector2(320, 800);
+            window.titleContent = new GUIContent("UXR SDK | Environment Fix");
+        }
+
+        //[MenuItem("UXR/Env/Delete Ignore", false)]
+        public static void DeleteIgonre()
+        {
+            foreach (var item in fixItems)
+            {
+                item.DeleteIgonre();
+            }
+        }
+
+        public void OnGUI()
+        {
+            string resourcePath = GetResourcePath();
+            Texture2D logo = AssetDatabase.LoadAssetAtPath<Texture2D>(resourcePath + "RokidIcon.png");
+            Rect rect = GUILayoutUtility.GetRect(position.width, 80, GUI.skin.box);
+            GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
+
+            string aboutText = "This window provides tips to help fix common issues with UXR SDK and your project.";
+            EditorGUILayout.LabelField(aboutText, EditorStyles.textArea);
+
+            int ignoredCount = 0;
+            int fixableCount = 0;
+            int invalidNotIgnored = 0;
+
+            for (int i = 0; i < fixItems.Length; i++)
+            {
+                FixItem item = fixItems[i];
+
+                bool ignored = item.IsIgnored();
+                bool valid = item.IsValid();
+                bool fixable = item.IsFixable();
+
+                if (!valid && !ignored && fixable)
+                {
+                    fixableCount++;
+                }
+
+                if (!valid && !ignored)
+                {
+                    invalidNotIgnored++;
+                }
+
+                if (ignored)
+                {
+                    ignoredCount++;
+                }
+            }
+
+            Rect issuesRect = EditorGUILayout.GetControlRect();
+            GUI.Box(new Rect(issuesRect.x - 4, issuesRect.y, issuesRect.width + 8, issuesRect.height), "Tips", EditorStyles.toolbarButton);
+
+            if (invalidNotIgnored > 0)
+            {
+                scrollPosition = GUILayout.BeginScrollView(scrollPosition);
+                {
+                    for (int i = 0; i < fixItems.Length; i++)
+                    {
+                        FixItem item = fixItems[i];
+
+                        if (!item.IsIgnored() && !item.IsValid())
+                        {
+                            invalidNotIgnored++;
+
+                            GUILayout.BeginVertical("box");
+                            {
+                                item.DrawGUI();
+
+                                EditorGUILayout.BeginHorizontal();
+                                {
+                                    // Aligns buttons to the right
+                                    GUILayout.FlexibleSpace();
+
+                                    if (item.IsFixable())
+                                    {
+                                        if (GUILayout.Button("Fix"))
+                                            item.Fix();
+                                    }
+
+                                    //if (GUILayout.Button("Ignore"))
+                                    //    check.Ignore();
+                                }
+                                EditorGUILayout.EndHorizontal();
+                            }
+                            GUILayout.EndVertical();
+                        }
+                    }
+                }
+                GUILayout.EndScrollView();
+            }
+
+            GUILayout.FlexibleSpace();
+
+            if (invalidNotIgnored == 0)
+            {
+                GUILayout.BeginHorizontal();
+                {
+                    GUILayout.FlexibleSpace();
+
+                    GUILayout.BeginVertical();
+                    {
+                        GUILayout.Label("No issue found");
+
+                        if (GUILayout.Button("Close Window"))
+                            Close();
+                    }
+                    GUILayout.EndVertical();
+
+                    GUILayout.FlexibleSpace();
+                }
+                GUILayout.EndHorizontal();
+
+                GUILayout.FlexibleSpace();
+            }
+
+            EditorGUILayout.BeginHorizontal("box");
+            {
+                if (fixableCount > 0)
+                {
+                    if (GUILayout.Button("Accept All"))
+                    {
+                        if (EditorUtility.DisplayDialog("Accept All", "Are you sure?", "Yes, Accept All", "Cancel"))
+                        {
+                            for (int i = 0; i < fixItems.Length; i++)
+                            {
+                                FixItem item = fixItems[i];
+
+                                if (!item.IsIgnored() &&
+                                    !item.IsValid())
+                                {
+                                    if (item.IsFixable())
+                                        item.Fix();
+                                }
+                            }
+                        }
+                    }
+                }
+
+            }
+            GUILayout.EndHorizontal();
+        }
+
+        private string GetResourcePath()
+        {
+            var ms = MonoScript.FromScriptableObject(this);
+            var path = AssetDatabase.GetAssetPath(ms);
+            path = Path.GetDirectoryName(path);
+            return path + "\\Textures\\";
+        }
+
+        private abstract class FixItem
+        {
+            protected string key;
+            protected MessageType level;
+
+            public MessageType Level
+            {
+                get
+                {
+                    return level;
+                }
+            }
+
+            public FixItem(MessageType level)
+            {
+                this.level = level;
+            }
+
+            public void Ignore()
+            {
+                EditorPrefs.SetBool(ignorePrefix + key, true);
+            }
+
+            public bool IsIgnored()
+            {
+                return EditorPrefs.HasKey(ignorePrefix + key);
+            }
+
+            public void DeleteIgonre()
+            {
+                Debug.Log("DeleteIgnore" + ignorePrefix + key);
+                EditorPrefs.DeleteKey(ignorePrefix + key);
+            }
+
+            public abstract bool IsValid();
+
+            public abstract bool IsAutoPop();
+
+            public abstract void DrawGUI();
+
+            public abstract bool IsFixable();
+
+            public abstract void Fix();
+
+            protected void DrawContent(string title, string msg)
+            {
+                EditorGUILayout.HelpBox(title, level);
+                EditorGUILayout.LabelField(msg, EditorStyles.textArea);
+            }
+        }
+
+        private class CheckCardboardPackage : FixItem
+        {
+            private enum PackageStates
+            {
+                None,
+                WaitingForList,
+                Failed,
+                Added,
+            }
+
+            UnityEditor.PackageManager.Requests.ListRequest request;
+            PackageStates packageState = PackageStates.None;
+            bool isvalid = true;
+            bool initOnStart;
+            bool hasLoader;
+
+            public CheckCardboardPackage(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+                request = null;
+                isvalid = true;
+#if UNITY_2020_3_OR_NEWER
+                EditorApplication.update -= CheckPackageUpdate;
+                EditorApplication.update += CheckPackageUpdate;
+#endif
+            }
+
+#if UNITY_2020_3_OR_NEWER
+            void CheckPackageUpdate()
+            {
+                switch (packageState)
+                {
+                    case PackageStates.None:
+                        request = UnityEditor.PackageManager.Client.List(true, false);
+                        packageState = PackageStates.WaitingForList;
+                        break;
+
+                    case PackageStates.WaitingForList:
+                        if (request.IsCompleted)
+                        {
+                            if (request.Error != null || request.Status == UnityEditor.PackageManager.StatusCode.Failure)
+                            {
+                                packageState = PackageStates.Failed;
+                                break;
+                            }
+
+                            UnityEditor.PackageManager.PackageCollection col = request.Result;
+                            foreach (var info in col)
+                            {
+                                if (info.name == "com.google.xr.cardboard")
+                                {
+                                    packageState = PackageStates.Added;
+
+                                    isvalid = false;
+
+                                    break;
+                                }
+                            }
+                            if (packageState != PackageStates.Added) isvalid = true;
+                        }
+                        break;
+
+                    default:
+                        break;
+                }
+            }
+
+#endif
+
+            public override bool IsValid()
+            {
+                return isvalid;//!(isvalid && initOnStart && hasLoader);
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"You must remove Cardboard XR Plugin " + @"
+	            In dropdown list of Window> Package Manager >Select Cardboard XR Plugin> Remove";
+                DrawContent("Please Remove Cardboard XR Plugin", message);
+            }
+
+            public override bool IsFixable()
+            {
+                if (isvalid)
+                {
+                    XRGeneralSettings sets = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Android);
+
+                    if (sets != null)
+                    {
+                        initOnStart = sets.InitManagerOnStart;
+
+                        XRManagerSettings plugins = sets.AssignedSettings;
+                        var loaders = sets.Manager.activeLoaders;
+
+                        hasLoader = false;
+
+                        for (int i = 0; i < loaders.Count; i++)
+                        {
+                            if (loaders[i].GetType() == typeof(Rokid.XR.Core.XRLoader))
+                                hasLoader = true;
+                            break;
+                        }
+                        if (!hasLoader || !initOnStart) return true;
+                    }
+                }
+                return false;
+            }
+
+            public override void Fix()
+            {
+                var sets = XRGeneralSettingsPerBuildTarget.XRGeneralSettingsForBuildTarget(BuildTargetGroup.Android);
+                bool initOnStart = sets.InitManagerOnStart;
+
+                if (!initOnStart) sets.InitManagerOnStart = true;
+
+                XRManagerSettings plugins = sets.AssignedSettings;
+                var loaders = sets.Manager.activeLoaders;
+                bool hasLoader = false;
+
+                for (int i = 0; i < loaders.Count; i++)
+                {
+                    if (loaders[i].GetType() == typeof(Rokid.XR.Core.XRLoader))
+                        hasLoader = true;
+                    break;
+                }
+
+                if (!hasLoader)
+                {
+                    var xrLoader = new Rokid.XR.Core.XRLoader();
+                    plugins.TryAddLoader(xrLoader);
+                }
+            }
+
+            public override bool IsAutoPop()
+            {
+                return false;
+            }
+        }
+
+        private class CkeckAndroidGraphicsAPI : FixItem
+        {
+            public CkeckAndroidGraphicsAPI(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override bool IsValid()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    if (PlayerSettings.GetUseDefaultGraphicsAPIs(BuildTarget.Android))
+                    {
+                        return false;
+                    }
+                    var graphics = PlayerSettings.GetGraphicsAPIs(BuildTarget.Android);
+                    if (graphics != null && graphics.Length >= 1 &&
+                        graphics[0] == UnityEngine.Rendering.GraphicsDeviceType.OpenGLES3)
+                    {
+                        return true;
+                    }
+                    return false;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"Graphics APIs should be set to OpenGLES.  Player Settings > Other Settings > Graphics APIs , choose 'OpenGLES3'.";
+                DrawContent("Graphics APIs is not OpenGLES", message);
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override void Fix()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    PlayerSettings.SetUseDefaultGraphicsAPIs(BuildTarget.Android, false);
+                    PlayerSettings.SetGraphicsAPIs(BuildTarget.Android, new GraphicsDeviceType[1] { GraphicsDeviceType.OpenGLES3 });
+                }
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+        }
+
+        private class CkeckMTRendering : FixItem
+        {
+            public CkeckMTRendering(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override bool IsValid()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    return !PlayerSettings.GetMobileMTRendering(BuildTargetGroup.Android);
+                }
+                else
+                {
+                    return false;
+                }
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"In order to run correct on mobile devices, the RenderingThreadingMode should be set. 
+	in dropdown list of Player Settings > Other Settings > Multithreaded Rendering, close toggle.";
+                DrawContent("Multithreaded Rendering not close", message);
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override void Fix()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    PlayerSettings.SetMobileMTRendering(BuildTargetGroup.Android, false);
+                }
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+        }
+
+        private class CkeckAndroidOrientation : FixItem
+        {
+            public CkeckAndroidOrientation(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override bool IsValid()
+            {
+                return PlayerSettings.defaultInterfaceOrientation == UIOrientation.Portrait;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"In order to display correct on mobile devices, the orientation should be set to portrait. 
+	in dropdown list of Player Settings > Resolution and Presentation > Default Orientation, choose 'Portrait'.";
+                DrawContent("Orientation is not portrait", message);
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override void Fix()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    PlayerSettings.defaultInterfaceOrientation = UIOrientation.Portrait;
+                }
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+        }
+
+        private class CkeckColorSpace : FixItem
+        {
+            public CkeckColorSpace(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override bool IsValid()
+            {
+                return PlayerSettings.colorSpace == ColorSpace.Gamma;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"In order to display correct on mobile devices, the colorSpace should be set to gamma. 
+	in dropdown list of Player Settings > Other Settings > Color Space, choose 'Gamma'.";
+                DrawContent("ColorSpace is not Linear", message);
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override void Fix()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    PlayerSettings.colorSpace = ColorSpace.Gamma;
+                }
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+        }
+
+        private class CkeckAndroidPermission : FixItem
+        {
+            public CkeckAndroidPermission(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override bool IsValid()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    return PlayerSettings.Android.forceInternetPermission;
+                }
+                else
+                {
+                    return false;
+                }
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"In order to run correct on mobile devices, the internet access premission should be set. 
+	in dropdown list of Player Settings > Other Settings > Internet Access, choose 'Require'.";
+                DrawContent("internet access permission not available", message);
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override void Fix()
+            {
+                if (EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android)
+                {
+                    PlayerSettings.Android.forceInternetPermission = true;
+                }
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+        }
+
+        //todo...添加最低版本号的检查
+        private class CheckUnityMinVersion : FixItem
+        {
+            string unityVersion;//
+
+            public CheckUnityMinVersion(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+                unityVersion = Application.unityVersion;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"The minimum Unity version required is 2020.3.36";
+                DrawContent("Unity version not valid ", message);
+            }
+
+            public override void Fix()
+            {
+
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+
+            public override bool IsFixable()
+            {
+                return unityVersion.CompareTo(minUnityVersion) == 1;
+            }
+
+            public override bool IsValid()
+            {
+                return unityVersion.CompareTo(minUnityVersion) == 1;
+            }
+        }
+
+        private class CheckOptimizedFramePacing : FixItem
+        {
+            public CheckOptimizedFramePacing(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"The optimizedFramePacing need to unselect";
+                DrawContent("OptimizedFramePacing", message);
+            }
+
+            public override void Fix()
+            {
+                PlayerSettings.Android.optimizedFramePacing = false;
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override bool IsValid()
+            {
+                return PlayerSettings.Android.optimizedFramePacing == false;
+            }
+        }
+
+        private class CheckMinmumAPILevel : FixItem
+        {
+            public CheckMinmumAPILevel(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"The minSdkVersion needs to be " + minSdkVersion.ToString();
+                DrawContent("MinSDKVersion", message);
+            }
+
+            public override void Fix()
+            {
+                PlayerSettings.Android.minSdkVersion = minSdkVersion;
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override bool IsValid()
+            {
+                return PlayerSettings.Android.minSdkVersion >= minSdkVersion;
+            }
+        }
+
+        private class CheckArchitecture : FixItem
+        {
+            public CheckArchitecture(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"The Target Architecture should be " + targetArchitecture;
+                DrawContent("Target Architecture", message);
+            }
+
+            public override void Fix()
+            {
+                PlayerSettings.SetScriptingBackend(BuildTargetGroup.Android, ScriptingImplementation.IL2CPP);
+                PlayerSettings.Android.targetArchitectures = targetArchitecture;
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override bool IsValid()
+            {
+                return PlayerSettings.GetScriptingBackend(BuildTargetGroup.Android) == ScriptingImplementation.IL2CPP &&
+                    PlayerSettings.Android.targetArchitectures == targetArchitecture;
+            }
+        }
+
+
+        private class CheckBuildTarget : FixItem
+        {
+            public CheckBuildTarget(MessageType level) : base(level)
+            {
+                key = this.GetType().Name;
+            }
+
+            public override void DrawGUI()
+            {
+                string message = @"The Build Target should be Android";
+                DrawContent("Build Target", message);
+            }
+
+            public override void Fix()
+            {
+                EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Android, BuildTarget.Android);
+            }
+
+            public override bool IsAutoPop()
+            {
+                return true;
+            }
+
+            public override bool IsFixable()
+            {
+                return true;
+            }
+
+            public override bool IsValid()
+            {
+                return EditorUserBuildSettings.activeBuildTarget == BuildTarget.Android;
+            }
+        }
+    }
+}

+ 11 - 0
Editor/UXREnvFix.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 33e3b5a9b2916dc4c8cc196be44aa92e
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 201 - 0
LICENSE.md

@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed under the Apache License, Version 2.0 (the "License");
+   you may not use this file except in compliance with the License.
+   You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.

+ 7 - 0
LICENSE.md.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: c2cdf177d3aee4b8392c7e857662a321
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Resources.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 3a92a20fefc6e456cb76dcefde83df4f
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Runtime.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: 7b3736418a3da458ebb6d7f4bb77ffef
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 8 - 0
Runtime/.idea/.idea.Runtime.dir/.idea/indexLayout.xml

@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="UserContentModel">
+    <attachedFolders />
+    <explicitIncludes />
+    <explicitExcludes />
+  </component>
+</project>

+ 6 - 0
Runtime/.idea/.idea.Runtime.dir/.idea/vcs.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="VcsDirectoryMappings">
+    <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
+  </component>
+</project>

+ 8 - 0
Runtime/Android.meta

@@ -0,0 +1,8 @@
+fileFormatVersion: 2
+guid: b87a7e5c753cb443fb61bc39f76430ae
+folderAsset: yes
+DefaultImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

BIN
Runtime/Android/GfxPluginRokidXRLoader.aar


+ 32 - 0
Runtime/Android/GfxPluginRokidXRLoader.aar.meta

@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: 3887409418d8c444b8cc19af555fd3f9
+PluginImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  iconMap: {}
+  executionOrder: {}
+  defineConstraints: []
+  isPreloaded: 1
+  isOverridable: 1
+  isExplicitlyReferenced: 0
+  validateReferences: 1
+  platformData:
+  - first:
+      Android: Android
+    second:
+      enabled: 1
+      settings: {}
+  - first:
+      Any: 
+    second:
+      enabled: 0
+      settings: {}
+  - first:
+      Editor: Editor
+    second:
+      enabled: 0
+      settings:
+        DefaultValueInitialized: true
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 257 - 0
Runtime/Api.cs

@@ -0,0 +1,257 @@
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+
+namespace Rokid.XR.Core
+{
+    using System;
+    using System.Collections;
+    using System.Collections.Generic;
+    using System.Runtime.InteropServices;
+    using UnityEngine;
+
+    /// <summary>
+    /// UXR Plugin API.
+    /// </summary>
+    public static class ApiLegacy
+    {
+        private static Rect _cachedSafeArea;
+        private static ScreenOrientation _cachedScreenOrientation;
+
+
+        /// <summary>
+        /// Updates screen parameters. This method must be called at framerate to ensure the current
+        /// screen orientation is properly taken into account by the head tracker.
+        /// </summary>
+        public static void UpdateScreenParams()
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return;
+            }
+
+            // Only set viewport orientation if it has changed since the last check.
+            if (_cachedScreenOrientation != Screen.orientation)
+            {
+                _cachedScreenOrientation = Screen.orientation;
+                XRLoader.SetViewportOrientation(_cachedScreenOrientation);
+                XRLoader.RecalculateRectangles(Screen.safeArea);
+                //ReloadDeviceParams();
+            }
+        }
+
+        public static void setTrackingType(int type)
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return;
+            }
+
+            setHeadTrackingType(type);
+        }
+
+        /// <summary>
+        /// Recenters the head tracker(yaw only).
+        /// </summary>
+        public static void Recenter()
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return;
+            }
+
+            recenterHeadPose();
+        }
+
+        /// <summary>
+        /// Recenters the head tracker(pitch,yaw and roll).
+        /// </summary>
+        public static void Recenter2()
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return;
+            }
+
+            recenterHeadPoseYPR();
+        }
+
+        public static string getDebugInfoU()
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return "Not Initialized";
+            }
+            IntPtr keyPtr = getDebugInfo();
+            string result = Marshal.PtrToStringAnsi(keyPtr);
+            //Debug.Log("Debug Info: " + result);
+            return result;
+        }
+
+        public static int getHeadTrackerState()
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return 1;
+            }
+            int state = getSlamState();
+            //Debug.Log("head tracker State: " + state);
+            return state;
+        }
+
+
+        /// <summary>
+        /// 获取预测的未来某时刻Head位姿
+        /// </summary>
+        /// <param name="position"></param>
+        /// <param name="orientation"></param>
+        /// <returns></returns>
+        public static long getHeadPose(float[] position, float[] orientation)
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return 1;
+            }
+            long ts = getHeadPoseRHS(position, orientation);
+
+            //R2L
+            position[2] = -position[2];
+            orientation[0] = -orientation[0]; orientation[1] = -orientation[1];
+            return ts;
+        }
+
+
+        /// <summary>
+        /// 获取最新相机时刻(physical camera)的Head位姿
+        /// </summary>
+        /// <param name="position"></param>
+        /// <param name="orientation"></param>
+        /// <returns></returns>
+        public static long GetHeadPoseCameraBase(float[] position, float[] orientation)
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return 1;
+            }
+            long ts = getHeadPoseCameraBaseRHS(position, orientation);
+            //R2L
+            position[2] = -position[2];
+            orientation[0] = -orientation[0]; orientation[1] = -orientation[1];
+            return ts;
+        }
+
+        /// <summary>
+        /// 获取左右眼投影参数
+        /// </summary>
+        /// <param name="frustum_left">float[6] {left,right,bottom,top,near,far}</param>
+        /// <param name="frustum_right">{left,right,bottom,top,near,far}</param>
+        /// <returns></returns>
+        public static bool getFrustum(float[] frustum_left, float[] frustum_right)
+        {
+            if (!XRLoader._isInitialized)
+            {
+                Debug.LogError(
+                        "Please initialize UXR loader before calling this function.");
+                return false;
+            }
+
+            bool result = get_frustum(frustum_left, frustum_right);
+            return result;
+        }
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void setHeadTrackingType(int type);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void recenterHeadPose();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void recenterHeadPoseYPR();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern IntPtr getDebugInfo();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern int getSlamState();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern long getHeadPoseRHS(float[] position, float[] orientation);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern long getHeadPoseCameraBaseRHS(float[] position, float[] orientation);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void getHistoryHeadPosePysRHS(long timestamp, float[] position, float[] orientation);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern bool get_frustum(float[] frustum_left, float[] frustum_right);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern int getGlassProductId();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern bool isUsbConnect();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern IntPtr getGlassName();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern IntPtr getGlassTypeId();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern IntPtr getGlassSn();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern IntPtr getGlassSeed();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void setGlassBrightness(int value);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern int getGlassBrightness();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern IntPtr getGlassCalFile();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern IntPtr getGlassFirmwareVersion();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern bool isPreviewing();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void getPreviewDimen(int[] data);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void openPhoneTracker();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void closePhoneTracker();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void getPhonePose(float[] oritation);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void recenterPhonePose();
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        public static extern void recenterPhonePoseYPR();    
+
+    }
+}

+ 11 - 0
Runtime/Api.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: ebbf2d40118d44471b9c7f06b8561eb0
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 15 - 0
Runtime/ApiConstants.cs

@@ -0,0 +1,15 @@
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+
+namespace Rokid.XR.Core
+{
+    internal static class ApiConstants
+    {
+#if UNITY_ANDROID
+        public const string UXR_GFX_PLUGIN = "GfxPluginRokidXRLoader";
+#else
+        public const string UXR_GFX_PLUGIN = "NOT_AVAILABLE";
+#endif
+    }
+}

+ 11 - 0
Runtime/ApiConstants.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 7ab675fb25945446aa25e3b0a4890185
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 14 - 0
Runtime/Rokid.XR.Core.asmdef

@@ -0,0 +1,14 @@
+{
+    "name": "Rokid.XR.Core",
+    "references": [
+        "Unity.XR.Management"
+    ],
+    "optionalUnityReferences": [],
+    "includePlatforms": [],
+    "excludePlatforms": [],
+    "allowUnsafeCode": false,
+    "overrideReferences": false,
+    "precompiledReferences": [],
+    "autoReferenced": true,
+    "defineConstraints": []
+}

+ 7 - 0
Runtime/Rokid.XR.Core.asmdef.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 2f52f0b6cfdc94464bcc067a11c8e1b6
+AssemblyDefinitionImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 15 - 0
Runtime/UnitySubsystemsManifest.json

@@ -0,0 +1,15 @@
+{
+	"name": "Cardboard",
+	"version": "1.21.6",
+	"libraryName": "GfxPluginRokidXRLoader",
+	"displays": [
+		{
+			"id": "CardboardDisplay"
+		}
+	],
+	"inputs": [
+		{
+			"id": "CardboardInput"
+		}
+	]
+}

+ 7 - 0
Runtime/UnitySubsystemsManifest.json.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 399cb2cca9c0c4b92b795897e5d3db7a
+TextScriptImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 293 - 0
Runtime/XRLoader.cs

@@ -0,0 +1,293 @@
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+
+namespace Rokid.XR.Core
+{
+    using System;
+    using System.Collections.Generic;
+    using System.Runtime.InteropServices;
+    using UnityEngine;
+    using UnityEngine.Rendering;
+    using UnityEngine.XR;
+    using UnityEngine.XR.Management;
+
+    /// <summary>
+    /// XR Loader for UXR Plugin.
+    /// Loads Display and Input Subsystems.
+    /// </summary>
+    public class XRLoader : XRLoaderHelper
+    {
+        private static List<XRDisplaySubsystemDescriptor> _displaySubsystemDescriptors =
+            new List<XRDisplaySubsystemDescriptor>();
+
+        private static List<XRInputSubsystemDescriptor> _inputSubsystemDescriptors =
+            new List<XRInputSubsystemDescriptor>();
+
+        /// <summary>
+        /// Pairs the native enum to set the graphics API being used.
+        /// </summary>
+        private enum UXRGraphicsApi
+        {
+            kOpenGlEs2 = 1,
+            kOpenGlEs3 = 2,           
+            kVulkan = 4,
+            kNone = -1,
+        }
+
+        /// <summary>
+        /// Describes the possible orientation of the viewport.
+        /// </summary>
+        private enum UXRViewportOrientation
+        {
+            kLandscapeLeft = 0,
+            kLandscapeRight = 1,
+            kPortrait = 2,
+            kPortraitUpsideDown = 3,
+        }
+
+        /// <summary>
+        /// Gets a value indicating whether the subsystems are initialized or not.
+        /// </summary>
+        ///
+        /// <returns>
+        /// True after a successful call to Initialize() without a posterior call to
+        /// Deinitialize().
+        /// </returns>
+        //internal static bool _isInitialized { get; private set; }
+         public static bool _isInitialized { get;  set; }
+
+        /// <summary>
+        /// Gets a value indicating whether the subsystems are started or not.
+        /// </summary>
+        ///
+        /// <returns>
+        /// True after a successful call to Start() without a posterior call to Stop().
+        /// </returns>
+        internal static bool _isStarted { get; private set; }
+
+        /// <summary>
+        /// Initialize the loader. This should initialize all subsystems to support the desired
+        /// runtime setup this loader represents.
+        /// </summary>
+        ///
+        /// <returns>Whether or not initialization succeeded.</returns>
+        public override bool Initialize()
+        {
+            UXRSDKInitialize();
+            CreateSubsystem<XRDisplaySubsystemDescriptor, XRDisplaySubsystem>(
+                _displaySubsystemDescriptors, "CardboardDisplay");
+            CreateSubsystem<XRInputSubsystemDescriptor, XRInputSubsystem>(
+                _inputSubsystemDescriptors, "CardboardInput");
+            // add for XRI 
+            OnXRILoaderInitialize?.Invoke(this);
+            _isInitialized = true;
+            return true;
+        }
+
+        /// <summary>
+        /// Ask loader to start all initialized subsystems.
+        /// </summary>
+        ///
+        /// <returns>Whether or not all subsystems were successfully started.</returns>
+        public override bool Start()
+        {
+            StartSubsystem<XRDisplaySubsystem>();
+            StartSubsystem<XRInputSubsystem>();
+            // add for XRI      
+            OnXRILoaderStart?.Invoke(this);
+            _isStarted = true;
+            return true;
+        }
+
+        /// <summary>
+        /// Ask loader to stop all initialized subsystems.
+        /// </summary>
+        ///
+        /// <returns>Whether or not all subsystems were successfully stopped.</returns>
+        public override bool Stop()
+        {
+            StopSubsystem<XRDisplaySubsystem>();
+            StopSubsystem<XRInputSubsystem>();
+            // add for XRI      
+            OnXRILoaderStop?.Invoke(this);
+            _isStarted = false;
+            return true;
+        }
+
+        /// <summary>
+        /// Ask loader to deinitialize all initialized subsystems.
+        /// </summary>
+        ///
+        /// <returns>Whether or not deinitialization succeeded.</returns>
+        public override bool Deinitialize()
+        {
+            DestroySubsystem<XRDisplaySubsystem>();
+            DestroySubsystem<XRInputSubsystem>();
+            // add for XRI
+            OnXRILoaderDeinitialize?.Invoke(this);
+            UXRSDKDeinitialize();
+            _isInitialized = false;
+            return true;
+        }
+
+        /// <summary>
+        /// Sets the screen parameters in the XR scene.
+        /// </summary>
+        ///
+        /// <param name="renderingArea">
+        /// The rectangle where the XR scene will be rendered.
+        /// </param>
+        public  static void RecalculateRectangles(Rect renderingArea)
+        {
+    
+            setScreenParams((int)renderingArea.width, (int)renderingArea.height);
+
+            Debug.Log("-uxr- ScreenParam h:" + Screen.height + ",renderingArea: "+ renderingArea.ToString());            
+            Debug.Log("-uxr-  displays len:" + Display.displays.Length + ",glass systemHeight: " + Display.displays[Display.displays.Length-1].systemHeight +
+                ",renderingHeight: " + Display.displays[Display.displays.Length-1].renderingHeight);
+         
+        }
+
+        /// <summary>
+        /// Sets which viewport orientation is being used by Unity to the native implementation.
+        /// </summary>
+        ///
+        /// <param name="screenOrientation">
+        /// The required screen orientation.
+        /// </param>
+        public static void SetViewportOrientation(ScreenOrientation screenOrientation)//TODO
+        {
+            /*switch (screenOrientation)
+            {
+                case ScreenOrientation.LandscapeLeft:
+                    CardboardUnity_setViewportOrientation(
+                        UXRViewportOrientation.kLandscapeLeft);
+                    break;
+                case ScreenOrientation.LandscapeRight:
+                    CardboardUnity_setViewportOrientation(
+                        UXRViewportOrientation.kLandscapeRight);
+                    break;
+                case ScreenOrientation.Portrait:
+                    CardboardUnity_setViewportOrientation(UXRViewportOrientation.kLandscapeLeft);
+                    break;
+                case ScreenOrientation.PortraitUpsideDown:
+                    CardboardUnity_setViewportOrientation(
+                        UXRViewportOrientation.kPortraitUpsideDown);
+                    break;
+                default:
+                    Debug.LogWarning(
+                      "The UXR Plugin does not support the selected screen orientation." +
+                      "Setting landscape left as default.");
+                    CardboardUnity_setViewportOrientation(
+                        UXRViewportOrientation.kLandscapeLeft);
+                    break;
+            }*/
+        }
+
+        /// <summary>
+        /// Sets which Graphics API is being used by Unity to the native implementation.
+        /// </summary>
+        private static void SetGraphicsApi()
+        {
+            switch (SystemInfo.graphicsDeviceType)
+            {
+                case GraphicsDeviceType.OpenGLES2:
+                    CardboardUnity_setGraphicsApi(UXRGraphicsApi.kOpenGlEs2);
+                    break;
+                case GraphicsDeviceType.OpenGLES3:
+                    CardboardUnity_setGraphicsApi(UXRGraphicsApi.kOpenGlEs3);
+                    break;
+#if UNITY_ANDROID
+                case GraphicsDeviceType.Vulkan:
+                    CardboardUnity_setGraphicsApi(UXRGraphicsApi.kVulkan);
+                    break;
+#endif
+                default:
+                    Debug.LogErrorFormat(
+                      "The UXR Plugin cannot be initialized given that the selected " +
+                      "Graphics API ({0}) is not supported. Please use OpenGL ES 2.0, " +
+                      "OpenGL ES 3.0.", SystemInfo.graphicsDeviceType);
+                    break;
+            }
+        }
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void setScreenParams(int viewport_width, int viewport_height);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void CardboardUnity_setGraphicsApi(UXRGraphicsApi graphics_api);
+
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void CardboardUnity_setViewportOrientation(
+            UXRViewportOrientation viewport_orientation);
+
+#if UNITY_ANDROID
+        [DllImport(ApiConstants.UXR_GFX_PLUGIN)]
+        private static extern void UXRUnity_initializeAndroid(IntPtr context);
+#endif
+
+        /// <summary>
+        /// For Android, initializes JavaVM and Android activity context.
+        /// Then,it sets the screen size in pixels.
+        /// </summary>
+        private void UXRSDKInitialize()
+        {
+#if UNITY_ANDROID
+            // TODO(b/169797155): Move this to UnityPluginLoad().
+            // Gets Unity context (Main Activity).
+            var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
+            var activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
+            var context = activity.Call<AndroidJavaObject>("getApplicationContext");
+
+            // Initializes SDK.
+            UXRUnity_initializeAndroid(activity.GetRawObject());
+#endif
+
+            //SetGraphicsApi();//TODO
+            SetViewportOrientation(Screen.orientation);
+
+            // Safe area is required to avoid rendering behind the notch. If the device does not
+            // have any notch, it will be equivalent to the full screen area.
+            RecalculateRectangles(Screen.safeArea);
+        }
+
+        /// <summary>
+        ///  the XR provider is deinitialized.
+        /// </summary>
+        private void UXRSDKDeinitialize()
+        {
+            
+        }
+
+        #region ForXRI
+        public static Action<XRLoader> OnXRILoaderInitialize;
+        public static Action<XRLoader> OnXRILoaderStart;
+        public static Action<XRLoader> OnXRILoaderStop;
+        public static Action<XRLoader> OnXRILoaderDeinitialize;
+        
+        public void CreateCustomSubsystem<TDescriptor, TSubsystem>(List<TDescriptor> descriptors, string id)
+            where TDescriptor : ISubsystemDescriptor
+            where TSubsystem : ISubsystem
+        {
+            CreateSubsystem<TDescriptor, TSubsystem>(descriptors, id);
+        }
+        
+        public void StartCustomSubsystem<T>() where T : class, ISubsystem
+        {
+            StartSubsystem<T>();
+        }
+        
+        public void StopCustomSubsystem<T>() where T : class, ISubsystem
+        {
+            StopSubsystem<T>();
+        }
+
+        public void DestroyCustomSubsystem<T>() where T : class, ISubsystem
+        {
+            DestroySubsystem<T>();
+        }
+        #endregion
+        
+    }
+}

+ 11 - 0
Runtime/XRLoader.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 44820cf310472441e952b611b9f17c14
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 17 - 0
Runtime/XRSettings.cs

@@ -0,0 +1,17 @@
+//-----------------------------------------------------------------------
+
+//-----------------------------------------------------------------------
+
+namespace Rokid.XR.Core
+{
+    using UnityEngine;
+
+    /// <summary>
+    /// XR Settings for XR Plugin.
+    /// Required by XR Management package.
+    /// </summary>
+    [System.Serializable]
+    public class XRSettings : ScriptableObject
+    {
+    }
+}

+ 11 - 0
Runtime/XRSettings.cs.meta

@@ -0,0 +1,11 @@
+fileFormatVersion: 2
+guid: 8f9643084e7b84786a72ba40c223a7fd
+MonoImporter:
+  externalObjects: {}
+  serializedVersion: 2
+  defaultReferences: []
+  executionOrder: 0
+  icon: {instanceID: 0}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: 

+ 27 - 0
package.json

@@ -0,0 +1,27 @@
+{
+    "name": "com.rokid.xr.core",
+    "displayName": "Rokid XR Core",
+    "version": "1.21.6",
+    "unity": "2020.3",
+	"author": "Rokid",
+    "documentationUrl": "https://s.rokid.com/srAHeF4",
+    "changelogUrl": "https://custom.rokid.com/prod/rokid_web/c88be4bcde4c42c0b8b53409e1fa1701/pc/cn/8d684c36da714eadaa23e47b6ab5a3a2.html?documentId=2639ebc0d6a7458d86be2ab9c8fbba57",
+    "description": "Provides rendering and input support for Rokid UXR.",
+    "keywords": [       
+        "ar",
+        "xr",
+        "reality",
+        "xreditorsubsystem"
+    ],
+    "dependencies": {
+        "com.unity.xr.management": "4.2.0",
+        "com.rokid.ar.mrc": "1.3.3",
+        "com.unity.xr.legacyinputhelpers": "2.1.10",
+		"com.unity.nuget.newtonsoft-json": "3.0.1"
+    },
+    "samples": [
+        {
+           
+        }
+    ]
+}

+ 7 - 0
package.json.meta

@@ -0,0 +1,7 @@
+fileFormatVersion: 2
+guid: 8733a4ec878ee4c25bf4a7f50e019d4b
+PackageManifestImporter:
+  externalObjects: {}
+  userData: 
+  assetBundleName: 
+  assetBundleVariant: