Example #1
0
        string GetAssetVersion(Hashtable _definition)
        {
            string name = (string)_definition["Name"];

            if (name.Equals("PlayMaker"))
            {
                return(MyUtils.GetPlayMakerVersion());
            }

            if (_definition.ContainsKey("VersionScanMethod"))
            {
                Hashtable _versionScanDetails = (Hashtable)_definition["VersionScanMethod"];
                if (_versionScanDetails.ContainsKey("FindInTextFile"))
                {
                    try
                    {
                        Regex pattern = new Regex((string)_versionScanDetails["VersionRegexPattern"]);

                        using (StreamReader inputReader = new StreamReader(Application.dataPath + _versionScanDetails["FindInTextFile"]))
                        {
                            while (!inputReader.EndOfStream)
                            {
                                try
                                {
                                    Match m = pattern.Match(inputReader.ReadLine());
                                    if (m.Success)
                                    {
                                        return(m.Value);
                                    }
                                }
                                catch (FormatException) {}
                                catch (OverflowException) {}
                            }
                        }
                    }catch (Exception e)
                    {
                        Debug.LogError("Project Scanning error for version scanning of " + name + " :" + e.Message);
                    }
                }
                else if (_versionScanDetails.ContainsKey("FindInVersionInfo"))
                {
                    string _jsonText = File.ReadAllText(Application.dataPath + _versionScanDetails["FindInVersionInfo"]);
                    return(VersionInfo.VersionInfoFromJson(_jsonText).ToString());
                }
            }

            return("n/a");
        }
        /// <summary>
        /// Launch the scanning process.
        /// </summary>
        public void LaunchScanningProcess(bool ConsoleOutput, string EditorPlayerPrefKey = "")
        {
            OutputInConsole = ConsoleOutput;

            _editorPlayerPrefKey = EditorPlayerPrefKey;

            if (OutputInConsole)
            {
                Debug.Log("Project Scanner: Downloading Assets Description");
            }

            _hasError   = false;
            _isScanning = true;
            AssetsList  = new SortedDictionary <string, AssetItem>();

            _wwwWrapper = new HttpWrapper();

            WWWForm _form = new WWWForm();

            _form.AddField("UnityVersion", Application.unityVersion);
            _form.AddField("PlayMakerVersion", MyUtils.GetPlayMakerVersion());

            _wwwWrapper.GET
            (
                "http://www.fabrejean.net/projects/playmaker_ecosystem/assetsDescription"
                ,
                _form
                ,
                (WWW www) =>
            {
                if (!string.IsNullOrEmpty(www.error))
                {
                    Debug.LogError("Project Scanner: Error downloading assets definition :" + www.error);

                    _isScanning = false;
                    _hasError   = true;
                }
                else
                {
                    EditorCoroutine.start(DoScanProject(www.text));
                }
            }
            );
        }
Example #3
0
        IEnumerator FindAsset(Hashtable _definition)
        {
            // just for nice asynch effect
            for (int i = 0; i < 10; i++)
            {
                yield return(null);
            }

            if (_cancelFlag)
            {
                yield break;
            }

            if (_definition == null)
            {
                Debug.LogWarning("FindAsset failed, details are missing");
                yield break;
            }

            string _name = (string)_definition["Name"];

            AssetItem _item = AssetItem.AssetItemFromHashTable(_definition);

            AssetsList[_name] = _item;

            yield return(null);

            // get the scan methods
            ArrayList _scanMethods = (ArrayList)_definition["ScanMethods"];

            if (_scanMethods == null)
            {
                if (OutputInConsole)
                {
                    Debug.LogWarning("Scanning failed for " + _definition["Name"] + ": missing 'ScanMethod' definitions");
                }
                yield break;
            }

            bool _found = false;

            foreach (Hashtable entry in _scanMethods)
            {
                if (entry.ContainsKey("FindByFile"))
                {
                    _found = MyUtils.DoesFileExistsAssets((string)entry["FindByFile"]);
                }
                else if (entry.ContainsKey("FindByClass"))
                {
                    _found = MyUtils.isClassDefined((string)entry["FindByClass"]);
                }

                if (_found)
                {
                    // get the version
                    _item.ProjectVersion = new VersionInfo(GetAssetVersion(_definition));
                    if (OutputInConsole)
                    {
                        Debug.Log(_definition["Name"] + " <color=green>found</color> in Project, version: " + _item.ProjectVersion);
                    }

                    _item.FoundInProject = true;

                    ArrayUtility.Add <string>(ref AssetsFoundList, _name);

                    yield break;
                }
                yield return(null);
            }

            if (OutputInConsole)
            {
                Debug.Log(_definition["Name"] + " <color=red>not found</color> in Project");
            }

            yield break;
        }
        IEnumerator FindAsset(Hashtable _definition)
        {
            // just for nice asynch effect
            for (int i = 0; i < 10; i++)
            {
                yield return(null);
            }

            if (_cancelFlag)
            {
                yield break;
            }

            if (_definition == null)
            {
                Debug.LogWarning("FindAsset failed, details are missing");
                yield break;
            }

            string _name = (string)_definition["Name"];

            AssetItem _item = AssetItem.AssetItemFromHashTable(_definition);


            AssetsList[_name] = _item;

            yield return(null);

            // get the scan methods
            ArrayList _scanMethods = (ArrayList)_definition["ScanMethods"];

            if (_scanMethods == null)
            {
                if (OutputInConsole)
                {
                    Debug.LogWarning("Scanning failed for " + _definition["Name"] + ": missing 'ScanMethod' definitions");
                }
                yield break;
            }

            bool _found = false;

            foreach (Hashtable entry in _scanMethods)
            {
                if (entry.ContainsKey("FindByFile"))
                {
                    _found = MyUtils.DoesFileExistsAssets((string)entry["FindByFile"]);
                }
                else if (entry.ContainsKey("FindByClass"))
                {
                    _found = MyUtils.isClassDefined((string)entry["FindByClass"]);
                }
                else if (entry.ContainsKey("FindByNamespace"))
                {
                    _found = MyUtils.isNamespaceDefined((string)entry["FindByNamespace"]);
                }

                if (_found)
                {
                    // get the version
                    _item.ProjectVersion = new VersionInfo(GetAssetVersion(_definition));
                    if (OutputInConsole)
                    {
                        Debug.Log(_definition["Name"] + " <color=green>found</color> in Project, version: " + _item.ProjectVersion);
                    }

                    _item.FoundInProject = true;

                    ArrayUtility.Add <string>(ref AssetsFoundList, _name);

                    yield return(null);

                    continue;
                }
                else
                {
                    ArrayUtility.Add <string>(ref AssetsNotFoundList, _name);
                }

                yield return(null);
            }

            // append automatically to selected list
            // TODO: give the user some higher level settings like ignore all unfound toggle or something.
            // TODO: also remember user preference.
            if (_found)
            {
                AssetsSelectedList.Remove(_name);
                AssetsSelectedList.Add(_name);
                _item.SelectAllCategories();
            }

            if (OutputInConsole)
            {
                Debug.Log(_definition["Name"] + " <color=red>not found</color> in Project");
            }

            yield break;
        }