internal static VariablesSettingsAsset LoadOrCreate()
        {
            if (!System.IO.Directory.Exists(VARIABLES_PATH))
            {
                System.IO.Directory.CreateDirectory(VARIABLES_PATH);
            }

            if (!System.IO.Directory.Exists(VARIABLES_PATH_RESOURCES))
            {
                System.IO.Directory.CreateDirectory(VARIABLES_PATH_RESOURCES);
            }

            if (_settings == null)
            {
                _settings = ExAssets.FindAssetsByType <VariablesSettingsAsset>().First();
            }

            if (_settings == null)
            {
                _settings = Resources.FindObjectsOfTypeAll <VariablesSettingsAsset>().FirstOrDefault();
            }

            if (_settings == null)
            {
                _settings = ExAssets.CreateAsset <VariablesSettingsAsset>(VARIABLES_PATH_RESOURCES, VARIABLES_SETTINGS_FILENAME, true, true);
            }

            if (_settings)
            {
                _settings.variables = ExAssets.FindAssetsByType <Variable>();
            }

            return(_settings);
        }
        void InitIfNeeded()
        {
            if (_db == null)
            {
                _db = VariablesUtility.Settings;
            }

            if (_rectLayout == null || _resized)
            {
                _resized = false;
                Rect rpos = base.position.CopyToZero();
                _rectLayout = rpos.Split(SplitMode.Vertical, 20, 21, -1);
                //Rect r;
                Vector2 center;
                for (int x = 1; x < _rectLayout.Length; x++)
                {
                    center = _rectLayout[x].center;
                    _rectLayout[x].size   = new Vector2(_rectLayout[x].width - 40, _rectLayout[x].height - 5);
                    _rectLayout[x].center = center;
                }
            }


            VariablesUtilityEditor.onNewVariablesCreated -= ReupdateTable;
            VariablesUtilityEditor.onNewVariablesCreated += ReupdateTable;

            if (!m_Initialized)
            {
                // Check if it already exists (deserialized from window layout file or scriptable object)
                if (m_TreeViewState == null)
                {
                    m_TreeViewState = new TreeViewState();
                }

                bool firstInit   = m_MultiColumnHeaderState == null;
                var  headerState = VariablesTable.CreateDefaultMultiColumnHeaderState(EntryTableViewRect.width);
                if (MultiColumnHeaderState.CanOverwriteSerializedFields(m_MultiColumnHeaderState, headerState))
                {
                    MultiColumnHeaderState.OverwriteSerializedFields(m_MultiColumnHeaderState, headerState);
                }
                m_MultiColumnHeaderState = headerState;

                var multiColumnHeader = new MyMultiColumnHeader(headerState);
                if (firstInit)
                {
                    multiColumnHeader.ResizeToFit();
                }

                var treeModel = new TreeModel <VariablesElement>(GetData());

                m_TreeView = new VariablesTable(m_TreeViewState, multiColumnHeader, treeModel);

                m_SearchField = new UnityEditor.IMGUI.Controls.SearchField();
                m_SearchField.downOrUpArrowKeyPressed += m_TreeView.SetFocusAndEnsureSelectedItem;

                m_TreeView.searchString = "";
                m_Initialized           = true;
            }
        }
Пример #3
0
        static List <VariablesElement> GenerateItems(List <VariablesElement> roots)
        {
            VariablesSettingsAsset _idb = VariablesUtilityEditor.Settings;

            foreach (Variable variable in _idb.variables.OrderBy(s => s.group).ThenBy(s => s.name))
            {
                roots.Add(CreateItem(variable, 0));
            }
            return(roots);
        }
Пример #4
0
        internal static VariablesSettingsAsset LoadAsset()
        {
            if (_settings == null)
            {
                _settings = ExAssets.FindAssetsByType <VariablesSettingsAsset>().FirstOrDefault();
            }

            if (_settings == null)
            {
                _settings = Resources.FindObjectsOfTypeAll <VariablesSettingsAsset>().FirstOrDefault();
            }

            return(_settings);
        }
 public void SetTreeAsset(VariablesSettingsAsset Inputdb)
 {
     _db           = Inputdb;
     m_Initialized = false;
 }