Пример #1
0
        void OnEnable()
        {
            instance = this;

            //Init formula data store
            formulaDataStore = FormulaDataStore.LoadFromAssetDatabaseOrCreate();
            //Init Web Helper
            webHelper = ScriptableObject.CreateInstance <WebHelper>();
            webHelper.Init(formulaDataStore);
            webHelper.FormulaDataUpdated += FormulaDataUpdated;

            DebugMode = EditorPrefs.GetBool(Constants.debugModePrefKey, false);
            //These two properties cause search results to be refreshed
            //So formulaDataStore needs to be initialized before these are set
            ShowHiddenFormulas = EditorPrefs.GetBool(Constants.showHiddenFormulasPrefKey, false);
            ShowOnlineFormulas = EditorPrefs.GetBool(Constants.showOnlineFormulasPrefKey, true);

            webHelper.DebugMode = DebugMode;

            //This code can be used to get the path to this class' path and use relative paths if necessary
            //Debug.Log("Path: " + AssetDatabase.GetAssetPath(MonoScript.FromScriptableObject(this)));

            //Init GUIContents
            downloadButtonGUIContent = new GUIContent(downloadTexture, "Download Formula");
            updateButtonGUIContent   = new GUIContent(updateTexture, "Update Available");
            optionsButtonGUIContent  = new GUIContent(optionsTexture, "Options");

            waitSpinGUIContents = new GUIContent[12];
            for (int i = 0; i < 12; i++)
            {
                waitSpinGUIContents[i] = new GUIContent(EditorGUIUtility.FindTexture("WaitSpin" + i.ToString("00")));
            }

            LoadLocalFormulas();

            //Set up parameters
            var usableFormulas = formulaDataStore.FormulaData.FindAll(x => x.IsUsable);

            parametersDictionary      = new Dictionary <MethodInfo, ParameterInfo[]>(usableFormulas.Count);
            parameterValuesDictionary = new Dictionary <MethodInfo, object[]>(usableFormulas.Count);
            foreach (var formula in usableFormulas)
            {
                var methodInfo = formula.methodInfo;
                parametersDictionary.Add(methodInfo, methodInfo.GetParameters());
                parameterValuesDictionary.Add(methodInfo, new object[methodInfo.GetParameters().Length]);
            }

            FilterBySearchText(searchText);

            webHelper.GetOnlineFormulas();
//			webHelper.CheckForAllFormulaUpdates();

            EditorApplication.update += OnUpdate;
        }
Пример #2
0
 public void Init(FormulaDataStore formulaDataStore)
 {
     this.formulaDataStore = formulaDataStore;
 }