public static SettingsProvider CreateHumanoidSettingsProvider()
        {
            var provider = new SettingsProvider("Preferences/HumanoidControlSettings", SettingsScope.User)
            {
                label      = "Humanoid Control",
                guiHandler = (searchContext) => {
                    HumanoidSettings settings   = HumanoidSettings.GetOrCreateSettings();
                    bool             anyChanged = false;

                    Configuration oldConfiguration = settings.configuration;
                    settings.configuration = (Configuration)EditorGUILayout.ObjectField("Configuration", settings.configuration, typeof(Configuration), false);
                    SerializedObject serializedConfiguration = new SerializedObject(settings.configuration);
                    anyChanged |= (settings.configuration != oldConfiguration);
                    anyChanged |= Configuration_Editor.ConfigurationGUI(settings.configuration, serializedConfiguration);
                    serializedConfiguration.ApplyModifiedProperties();

                    if (anyChanged)
                    {
                        Configuration_Editor.CheckExtensions(settings.configuration);
                    }
                },
                keywords = new HashSet <string>(
                    new[] { "Humanoid", "Oculus", "SteamVR" }
                    )
            };

            return(provider);
        }
        public static void PreferencesGUI()
        {
            if (!prefsLoaded)
            {
                configurationString = EditorPrefs.GetString("HumanoidConfigurationKey", "DefaultConfiguration");

                LoadConfiguration(configurationString);
                if (configuration == null)
                {
                    configurationString = "DefaultConfiguration";
                    LoadConfiguration(configurationString);
                }
                prefsLoaded = true;
            }

            if (configuration == null)
            {
                Debug.Log("Created new Default Configuration");

                string humanoidPath = Configuration_Editor.FindHumanoidFolder();
                // Create new Default Configuration
                configuration = ScriptableObject.CreateInstance <Configuration>();
                humanoidPath  = humanoidPath.Substring(0, humanoidPath.Length - 1);           // strip last /
                humanoidPath  = humanoidPath.Substring(0, humanoidPath.LastIndexOf('/') + 1); // strip Scripts;
                string path = "Assets" + humanoidPath + configurationString + ".asset";
                AssetDatabase.CreateAsset(configuration, path);
            }

            configuration = (Configuration)EditorGUILayout.ObjectField("Configuration", configuration, typeof(Configuration), false);
            SerializedObject serializedConfiguration = new SerializedObject(configuration);

            bool anyChanged = Configuration_Editor.ConfigurationGUI(configuration, serializedConfiguration);

            serializedConfiguration.ApplyModifiedProperties();
            if (configuration != null)
            {
                if (GUI.changed)
                {
                    configurationString = configuration.name;
                    EditorPrefs.SetString("HumanoidConfigurationKey", configurationString);
                }

                if (GUI.changed || anyChanged)
                {
                    EditorUtility.SetDirty(configuration);
                    Configuration_Editor.CheckExtensions(configuration);
                }
            }
        }
        public static void CopyFilesToPath(string toPath, bool overwrite)
        {
            string humanoidPath = Configuration_Editor.FindHumanoidFolder();

            string[] files = GetFilesToCopy();

            foreach (string file in files)
            {
                string   fullFile    = Application.dataPath + humanoidPath + "Extensions/OpenVR/" + file;
                FileInfo bindingInfo = new FileInfo(fullFile);
                string   newFilePath = Path.Combine(toPath, bindingInfo.Name);

                bool exists = false;
                if (File.Exists(newFilePath))
                {
                    exists = true;
                }

                if (exists)
                {
                    if (overwrite)
                    {
                        FileInfo existingFile = new FileInfo(newFilePath)
                        {
                            IsReadOnly = false
                        };
                        existingFile.Delete();

                        File.Copy(fullFile, newFilePath);

                        Debug.Log("Copied (overwrote) manifest to build: " + newFilePath);
                    }
                    else
                    {
                        Debug.Log("Skipped writing existing manifest in build: " + newFilePath);
                    }
                }
                else
                {
                    File.Copy(fullFile, newFilePath);

                    Debug.Log("Copied manifest to buld: " + newFilePath);
                }
            }
        }
Beispiel #4
0
            protected virtual void CheckQuestManifest()
            {
                string   manifestPath = Application.dataPath + "/Plugins/Android/AndroidManifest.xml";
                FileInfo fileInfo     = new FileInfo(manifestPath);

                fileInfo.Directory.Create();
                bool manifestAvailable = File.Exists(manifestPath);

                if (manifestAvailable)
                {
                    return;
                }

                string humanoidPath      = Configuration_Editor.FindHumanoidFolder();
                string questManifestPath = Application.dataPath + humanoidPath + "Extensions/Oculus/QuestManifest.xml";

                File.Copy(questManifestPath, manifestPath);
            }
        internal static HumanoidSettings GetOrCreateSettings()
        {
            string humanoidPath = Configuration_Editor.FindHumanoidFolder();

            humanoidPath = humanoidPath.Substring(0, humanoidPath.Length - 1);           // strip last /
            humanoidPath = humanoidPath.Substring(0, humanoidPath.LastIndexOf('/') + 1); // strip Scripts;

            var settings = AssetDatabase.LoadAssetAtPath <HumanoidSettings>("Assets" + humanoidPath + "HumanoidSettings.asset");
            SerializedObject serializedSettings = new SerializedObject(settings);

            if (settings == null)
            {
                settings = CreateInstance <HumanoidSettings>();

                AssetDatabase.CreateAsset(settings, settingsPath);
                AssetDatabase.SaveAssets();
            }
            if (settings.configuration == null)
            {
                string        configurationString = EditorPrefs.GetString("HumanoidConfigurationKey", "DefaultConfiguration");
                Configuration configuration       = Configuration_Editor.LoadConfiguration(configurationString);
                if (configuration == null)
                {
                    configurationString = "DefaultConfiguration";
                    Configuration_Editor.LoadConfiguration(configurationString);
                    if (configuration == null)
                    {
                        Debug.Log("Created new Default Configuration");
                        // Create new Default Configuration
                        configuration = CreateInstance <Configuration>();
                        string path = "Assets" + humanoidPath + configurationString + ".asset";
                        AssetDatabase.CreateAsset(configuration, path);
                        AssetDatabase.SaveAssets();
                    }
                }
                SerializedProperty configurationProp = serializedSettings.FindProperty("configuration");
                configurationProp.objectReferenceValue = configuration;
            }
            serializedSettings.ApplyModifiedProperties();
            return((HumanoidSettings)serializedSettings.targetObject);//settings;
        }