public static PKFxSettings GetOrCreateSettingsAsset() { PKFxSettings instance = Resources.Load(PKFxSettings.kSettingsAssetName) as PKFxSettings; _CheckForMultipleSettingsObject(instance); if (instance == null) { string targetFolder = PKFxSettings.kSettingsPath; // no asset found, we need to create it. if (!Directory.Exists(Path.Combine(UnityAssetFolder, targetFolder))) { targetFolder = "Resources"; if (!Directory.Exists(Path.Combine(UnityAssetFolder, targetFolder))) { AssetDatabase.CreateFolder(UnityAssetFolder, targetFolder); } } string fullPath = Path.Combine(Path.Combine(UnityAssetFolder, targetFolder), PKFxSettings.kSettingsAssetName + PKFxSettings.kSettingsAssetExtension); if (targetFolder == "Resources") { Debug.LogWarning("[PKFX] Unable to find the PopcornFX folder, creating the settings asset to " + fullPath + ".\n You should move it into PopcornFX/Resources."); } instance = CreateInstance <PKFxSettings>(); AssetDatabase.CreateAsset(instance, fullPath); AssetDatabase.SaveAssets(); } return(instance); }
static void ImportEffectPack() { PKFxSettings.GetAllAssetPath(); ImportPKFxListEditor window = ScriptableObject.CreateInstance(typeof(ImportPKFxListEditor)) as ImportPKFxListEditor; window.Paths = PKFxSettings.AssetPathList; window.ShowUtility(); }
void OnGUI() { EditorGUILayout.LabelField("Select Effects:"); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Select All")) { for (int i = 0; i < m_checked.Count; ++i) { m_checked[i] = true; } } if (GUILayout.Button("Select None")) { for (int i = 0; i < m_checked.Count; ++i) { m_checked[i] = false; } } EditorGUILayout.EndHorizontal(); scrollVector = EditorGUILayout.BeginScrollView(scrollVector); for (int i = 0; i < Paths.Count; ++i) { EditorGUILayout.BeginHorizontal(); if (EditorGUILayout.ToggleLeft(Paths[i], m_checked[i]) != m_checked[i]) { m_checked[i] = !m_checked[i]; } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); EditorGUILayout.BeginHorizontal(); if (GUILayout.Button("Bake and Import")) { Close(); List <string> path = new List <string>(); for (int i = 0; i < m_Paths.Count; ++i) { if (m_checked[i]) { path.Add(m_Paths[i]); } } PKFxSettings.ReimportAssets(path); } GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel")) { Close(); } EditorGUILayout.EndHorizontal(); }
private static void _CheckForMultipleSettingsObject(PKFxSettings instance) { string[] guids = AssetDatabase.FindAssets("t:PKFxSettings"); if (guids.Length > 1) { string instancePath = AssetDatabase.GetAssetPath(instance); string objPaths = ""; foreach (var guid in guids) { string path = AssetDatabase.GUIDToAssetPath(guid); if (path != instancePath) { objPaths += " - " + path + "\n"; } } Debug.Assert(false, "[PKFX] Found more than one PKFxSettings object, loading " + instancePath + "\nThis objects will not be used: " + objPaths); } }
public override void OnInspectorGUI() { PKFxSettings settings = (PKFxSettings)target; PKFxSettings.SetInstance(settings); using (var category = new PKFxEditorCategory(() => EditorGUILayout.Foldout(PKFxSettings.GeneralCategory, "General"))) { PKFxSettings.GeneralCategory = category.IsExpanded(); if (category.IsExpanded()) { DisplayGeneralCategory(); } } using (var category = new PKFxEditorCategory(() => EditorGUILayout.Foldout(PKFxSettings.RenderingCategory, "Rendering"))) { PKFxSettings.RenderingCategory = category.IsExpanded(); if (category.IsExpanded()) { DisplayRenderingCategory(); } } using (var category = new PKFxEditorCategory(() => EditorGUILayout.Foldout(PKFxSettings.ThreadingCategory, "Multithreading"))) { PKFxSettings.ThreadingCategory = category.IsExpanded(); if (category.IsExpanded()) { DisplayThreadingCategory(); } } if (PKFxSettings.EnableFileLog != PKFxManagerImpl.FileLoggingEnabled()) { EditorGUILayout.HelpBox("At least one of the changes requires a restart of Unity to be effective.", MessageType.Warning, true); } if (GUI.changed) { EditorUtility.SetDirty(settings); } }
private void DisplayGeneralCategory() { GUIStyle boldStyleRed = new GUIStyle(); boldStyleRed.fontStyle = FontStyle.Bold; boldStyleRed.normal.textColor = Color.red; boldStyleRed.hover.textColor = Color.red; EditorGUILayout.BeginHorizontal(); PKFxSettings.TimeMultiplier = EditorGUILayout.Slider(timeMultiplierLabel, PKFxSettings.TimeMultiplier, 0.0f, 10.0f); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); PKFxSettings.EnableFileLog = EditorGUILayout.ToggleLeft(enableFileLogLabel, PKFxSettings.EnableFileLog); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); PKFxSettings.EnableRaycastForCollisions = EditorGUILayout.ToggleLeft(enableRaycastForCollisionsLabel, PKFxSettings.EnableRaycastForCollisions); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(PKFxSettings.PopcornPackFxPath)) { EditorGUILayout.LabelField(PKFxSettings.PopcornPackFxPath); } else { EditorGUILayout.LabelField("<empty>", boldStyleRed); } if (GUILayout.Button("Set Pack Fx Path")) { string path = EditorUtility.OpenFolderPanel("Choose PopcornFx Asset Folder", "", ""); if (Directory.Exists(path)) { var fileUri = new Uri(path); var referenceUri = new Uri(Application.dataPath); PKFxSettings.PopcornPackFxPath = referenceUri.MakeRelativeUri(fileUri).ToString(); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); if (!string.IsNullOrEmpty(PKFxSettings.UnityPackFxPath)) { EditorGUILayout.LabelField(PKFxSettings.UnityPackFxPath); } else { EditorGUILayout.LabelField("<empty>", boldStyleRed); } if (GUILayout.Button("Set Unity Fx Path")) { string path = EditorUtility.OpenFolderPanel("Choose Unity Fx Assets Folder", "Resources", ""); if (Directory.Exists(path)) { PKFxSettings.UnityPackFxPath = path.Substring(Application.dataPath.Length); } } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Reimport Pack"); if (GUILayout.Button("Choose files")) { PKFxSettings.GetAllAssetPath(); ImportPKFxListEditor window = ScriptableObject.CreateInstance(typeof(ImportPKFxListEditor)) as ImportPKFxListEditor; window.Paths = PKFxSettings.AssetPathList; window.ShowUtility(); } if (GUILayout.Button("All")) { PKFxSettings.ReimportAllAssets(); } EditorGUILayout.EndHorizontal(); }
void OnDisable() { // make sure the runtime code will load the Asset from Resources when it next tries to access this. PKFxSettings.SetInstance(null); }
public static void SetInstance(PKFxSettings settings) { g_Instance = settings; }