コード例 #1
0
        static public void Initialize()
        {
#if UNITY_EDITOR
            if (!main)
            {
                //Get the Preference
                string[] targetData = AssetDatabase.FindAssets("t:TEXPreference");
                if (targetData.Length > 0)
                {
                    var path = AssetDatabase.GUIDToAssetPath(targetData[0]);
                    main = AssetDatabase.LoadAssetAtPath <TEXPreference>(path);
                    main.MainFolderPath = Path.GetDirectoryName(path);
                    // TEXDraw preference now put into resources files after 3.0
                    if (main.MainFolderPath.Contains("Resources"))
                    {
                        main.MainFolderPath = Path.GetDirectoryName(main.MainFolderPath);
                    }
                    if (targetData.Length > 1)
                    {
                        Debug.LogWarning("You have more than one TEXDraw preference, ensure that only one Preference exist in your Project");
                    }
                }
                else
                {
                    //Create New One
                    main = CreateInstance <TEXPreference>();
                    if (AssetDatabase.IsValidFolder(DefaultTexFolder))
                    {
                        AssetDatabase.CreateAsset(main, DefaultTexFolder + "/Resources/TEXDrawPreference.asset");
                        main.FirstInitialize(DefaultTexFolder);
                    }
                    else
                    {
                        //Find alternative path to the TEXPreference, that's it: Parent path of TEXPreference script.
                        string AlternativePath = AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(main));
                        AlternativePath = Directory.GetParent(AlternativePath).Parent.FullName;
                        AssetDatabase.CreateAsset(main, AlternativePath + "/Resources/TEXDrawPreference.asset");
                        main.FirstInitialize(AlternativePath);
                    }
                }
            }
#else
            if (!main)
            {
                // The only thing that we can found is in the Resource folder
                main = (TEXPreference)Resources.Load("TEXDrawPreference");
            }
#endif
            // also init the neighborhood
            TEXConfiguration.Initialize();
        }
コード例 #2
0
ファイル: TEXConfiguration.cs プロジェクト: step4/rac-quiz
        public static void Initialize()
        {
            if (!main)
            {
                // The only thing that we can found is in the Resource folder
                if (TEXPreference.main)
                {
                    main = TEXPreference.main.preferences;
                }
                if (!main)
                {
                    main = TEXPreference.main.preferences = (TEXConfiguration)Resources.Load("TEXDrawConfiguration");
#if UNITY_EDITOR
                    if (!main)
                    {
                        main = TEXPreference.main.preferences = CreateInstance <TEXConfiguration>();
                        UnityEditor.AssetDatabase.CreateAsset(main, TEXPreference.main.MainFolderPath + "/Resources/TEXDrawConfiguration.asset");
                    }
                    UnityEditor.EditorUtility.SetDirty(TEXPreference.main);
#endif
                }
            }
        }