Example #1
0
        public void Update()
        {
            // Unity loses its state when it compiles, with the editor pref we can load the opened project automatically.
            if (!ProjectManager.Initialized && !string.IsNullOrEmpty(EditorPrefs.GetString("loadedProject")))
            {
                ProjectManager.AutoLoad();

                _selectedAsset = ProjectManager.AssetPack.Assets.First();
            }

            if (ProjectManager.Initialized)
            {
                ProjectManager.AutoSave();

                // sync the selected game object in the scene with the corresponding asset
                if (_selectedAsset != null && Selection.activeGameObject != _selectedAsset.GameObject)
                {
                    var asset = ProjectManager.AssetPack.Assets.FirstOrDefault(a => a.GameObject == Selection.activeGameObject);

                    if (asset != null)
                    {
                        _selectedAsset = asset;

                        Repaint();
                    }
                }
            }
        }