public DataHelper(
            Type targetType,
            EditorLSDatabase sourceEditor,
            LSDatabase sourceDatabase,
            string displayName,
            string dataCodeName,
            string dataFieldName,
            SortInfo[] sorts)
        {
            Sorts = sorts;
            this.TargetType = targetType;
            SourceEditor = sourceEditor;
            this.DisplayName = displayName;
            SourceDatabase = sourceDatabase;
            DataCodeName = dataCodeName;
            _dataFieldName = dataFieldName;

            FieldInfo info = sourceDatabase.GetType().GetField(_dataFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
            _getData = () => (DataItem[])info.GetValue(sourceDatabase);
            _setData = (value) => info.SetValue(sourceDatabase, value);
            if (Data == null)
                Data = (DataItem[])Array.CreateInstance (TargetType,0);
            DataItemAttribute dataAttribute = (DataItemAttribute)Attribute.GetCustomAttribute(targetType, typeof (DataItemAttribute));
            _dataAttribute = dataAttribute ?? new DataItemAttribute ();
        }
        void LoadDatabase(LSDatabase database)
        {
            _database = database;
            bool isValid = false;

            if (_database != null)
            {
                if (database.GetType() != DatabaseType)
                {
                    //Note: A hacky fix for changing the type of a previously saved database is to turn on Debug mode
                    //and change the script type of the database asset in the inspector. Back it up before attempting!
                }
                DatabaseEditor = new EditorLSDatabase();
                DatabaseEditor.Initialize(this, Database, out isValid);
            }
            if (!isValid)
            {
                Debug.Log("Load unsuccesful");
                this.DatabaseEditor = null;
                this._database      = null;
                IsLoaded            = false;
                return;
            }
            LSFSettingsManager.GetSettings().Database = database;
            LSFSettingsModifier.Save();
            IsLoaded = true;
        }
Пример #3
0
        public DataHelper(
            Type targetType,
            EditorLSDatabase sourceEditor,
            LSDatabase sourceDatabase,
            string displayName,
            string dataCodeName,
            string dataFieldName,
            SortInfo[] sorts)
        {
            Sorts            = sorts;
            this.TargetType  = targetType;
            SourceEditor     = sourceEditor;
            this.DisplayName = displayName;
            SourceDatabase   = sourceDatabase;
            DataCodeName     = dataCodeName;
            _dataFieldName   = dataFieldName;

            FieldInfo info = sourceDatabase.GetType().GetField(_dataFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            _getData = () => (DataItem[])info.GetValue(sourceDatabase);
            _setData = (value) => info.SetValue(sourceDatabase, value);
            if (Data == null)
            {
                Data = (DataItem[])Array.CreateInstance(TargetType, 0);
            }
            DataItemAttribute dataAttribute = (DataItemAttribute)Attribute.GetCustomAttribute(targetType, typeof(DataItemAttribute));

            _dataAttribute = dataAttribute ?? new DataItemAttribute();
        }
Пример #4
0
        public DataHelper(
            Type targetType,
            EditorLSDatabase sourceEditor,
            LSDatabase sourceDatabase,
            string displayName,
            string dataFieldName,
            SortInfo[] sorts,
            out bool valid)
        {
            Sorts = sorts;
            this.TargetType = targetType;
            SourceEditor = sourceEditor;
            this.DisplayName = displayName;
            SourceDatabase = sourceDatabase;
            _dataFieldName = dataFieldName;

            FieldInfo info = sourceDatabase.GetType().GetField(_dataFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            if (info == null) {
                Debug.Log (string.Format ("Field with fieldName of {0} not found.", dataFieldName));
                valid = false;
                return;
            }

            _getData = () => (DataItem[])info.GetValue(sourceDatabase);
            _setData = (value) => info.SetValue(sourceDatabase, value);
            if (Data == null)
                Data = (DataItem[])Array.CreateInstance (TargetType,0);
            DataItemAttribute dataAttribute = (DataItemAttribute)Attribute.GetCustomAttribute(targetType, typeof (DataItemAttribute));
            _dataAttribute = dataAttribute ?? new DataItemAttribute ();
            valid = true;
        }
Пример #5
0
 void LoadDatabase(LSDatabase database)
 {
     _database       = database;
     _databaseEditor = (EditorLSDatabase)Activator.CreateInstance(DatabaseEditorType);
     _databaseEditor.Initialize(this, Database);
     LSFSettingsManager.GetSettings().Database = database;
     LSFSettingsModifier.Save();
 }
        public static void Setup()
        {
            //LSFSettingsManagers.GetSettings().Database is the most recent database loaded/created.
            //You can also set this manually by dragging the desired database onto the saved LSFSettings in...
            //'Assets/Resources/LockstepFrameworkSettings'
            LSDatabase database = LSFSettingsManager.GetSettings().Database;

            _currentDatabase = database;
        }
Пример #7
0
 public static void Initialize()
 {
     if (Loaded == false)
     {
         LSDatabase database = LSFSettingsManager.GetSettings().Database;
         _currentDatabase = database;
         Loaded           = true;
         LockstepManager.Setup();
     }
     Terrain = GameObject.FindObjectOfType <Terrain> ();
 }
        public static void Initialize()
        {
            if (Loaded == false) {

                LSDatabase database = LSFSettingsManager.GetSettings ().Database;
                _currentDatabase = database;
                Loaded = true;
                LockstepManager.Setup();
            }
            Terrain = GameObject.FindObjectOfType<Terrain> ();
        }
Пример #9
0
        public void Initialize(EditorLSDatabaseWindow window, LSDatabase database)
        {
            this.MainWindow = window;
            Database        = database;

            InitializeData();
            for (int i = 0; i < DataItemInfos.Count; i++)
            {
                DataItemInfo info = DataItemInfos[i];
                CreateDataHelper(info);
            }
        }
Пример #10
0
        bool LoadDatabaseFromPath(string absolutePath)
        {
            string     relativePath = absolutePath.GetRelativeUnityAssetPath();
            LSDatabase database     = AssetDatabase.LoadAssetAtPath <LSDatabase> (relativePath);

            if (database != null)
            {
                LoadDatabase(database);
                return(true);
            }
            _databaseEditor = null;
            return(false);
        }
Пример #11
0
        bool CreateDatabase(string absolutePath)
        {
            LSDatabase database = (LSDatabase)ScriptableObject.CreateInstance(DatabaseType);

            LoadDatabase(database);

            string relativePath = absolutePath.GetRelativeUnityAssetPath();

            AssetDatabase.CreateAsset(database, relativePath);

            AssetDatabase.SaveAssets();
            AssetDatabase.Refresh();

            return(true);
        }
Пример #12
0
        void LoadDatabase(LSDatabase database)
        {
            _database       = database;
            _databaseEditor = (EditorLSDatabase)Activator.CreateInstance(typeof(EditorLSDatabase));
            bool isValid;

            _databaseEditor.Initialize(this, Database, out isValid);
            if (!isValid)
            {
                this._databaseEditor = null;
                this._database       = null;
                IsLoaded             = false;
                return;
            }
            LSFSettingsManager.GetSettings().Database = database;
            LSFSettingsModifier.Save();
            IsLoaded = true;
        }
        public void Initialize(EditorLSDatabaseWindow window, LSDatabase database, out bool valid)
        {
            this.MainWindow = window;
            Database        = database;

            InitializeData();
            IsValid = true;
            for (int i = 0; i < DataItemInfos.Count; i++)
            {
                DataItemInfo info = DataItemInfos[i];
                bool         isValid;
                CreateDataHelper(info, out isValid);
                if (!isValid)
                {
                    Debug.LogError("Database does not match database type described by the database editor. Make sure Lockstep_Database.asset is the correct database type.");
                    IsValid = false;
                    break;
                }
            }
            valid = IsValid;
        }
Пример #14
0
        public DataHelper(
            Type targetType,
            EditorLSDatabase sourceEditor,
            LSDatabase sourceDatabase,
            string displayName,
            string dataFieldName,
            SortInfo[] sorts,
            out bool valid)
        {
            Sorts            = sorts;
            this.TargetType  = targetType;
            SourceEditor     = sourceEditor;
            this.DisplayName = displayName;
            SourceDatabase   = sourceDatabase;
            _dataFieldName   = dataFieldName;

            FieldInfo info = sourceDatabase.GetType().GetField(_dataFieldName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            if (info == null)
            {
                Debug.Log(string.Format("Field with fieldName of {0} not found.", dataFieldName));
                valid = false;
                return;
            }

            _getData = () => (DataItem[])info.GetValue(sourceDatabase);
            _setData = (value) => info.SetValue(sourceDatabase, value);
            if (Data == null)
            {
                Data = (DataItem[])Array.CreateInstance(TargetType, 0);
            }
            DataItemAttribute dataAttribute = (DataItemAttribute)Attribute.GetCustomAttribute(targetType, typeof(DataItemAttribute));

            _dataAttribute = dataAttribute ?? new DataItemAttribute();
            valid          = true;
        }
        public void Initialize(EditorLSDatabaseWindow window, LSDatabase database, out bool valid)
        {
            this.MainWindow = window;
            Database = database;

            InitializeData ();
            IsValid = true;
            for (int i = 0; i < DataItemInfos.Count; i++) {
                DataItemInfo info = DataItemInfos[i];
                bool isValid;
                CreateDataHelper (info, out isValid);
                if (!isValid) {
                    Debug.LogError ("Database does not match database type described by the database editor. Make sure Lockstep_Database.asset is the correct database type.");
                    IsValid = false;
                    break;
                }
            }
            valid = IsValid;
        }
 public static string ToJson(LSDatabase database)
 {
     return(JsonUtility.ToJson(database, true));
 }
 void LoadDatabase(LSDatabase database)
 {
     _database = database;
     _databaseEditor = (EditorLSDatabase)Activator.CreateInstance (DatabaseEditorType);
     _databaseEditor.Initialize (this,Database);
     LSFSettingsManager.GetSettings ().Database = database;
     LSFSettingsModifier.Save ();
 }
Пример #18
0
 public static void ApplyJson <TDatabase> (string json) where TDatabase : LSDatabase, new()
 {
     _currentDatabase = new TDatabase();
     JsonUtility.FromJsonOverwrite(json, _currentDatabase);
 }
 void LoadDatabase(LSDatabase database)
 {
     _database = database;
     _databaseEditor = (EditorLSDatabase)Activator.CreateInstance ((Type)DatabaseEditorType);
     bool isValid;
     _databaseEditor.Initialize (this,Database, out isValid);
     if (!isValid) {
         this._databaseEditor = null;
         this._database = null;
         IsLoaded = false;
         return;
     }
     LSFSettingsManager.GetSettings ().Database = database;
     LSFSettingsModifier.Save ();
     IsLoaded = true;
 }
Пример #20
0
        public static void Setup()
        {
            LSDatabase database = LSFSettingsManager.GetSettings().Database;

            _currentDatabase = database;
        }
 public static void Setup()
 {
     LSDatabase database = LSFSettingsManager.GetSettings ().Database;
     _currentDatabase = database;
 }
        public void Initialize(EditorLSDatabaseWindow window, LSDatabase database)
        {
            this.MainWindow = window;
            Database = database;

            InitializeData ();
            for (int i = 0; i < DataItemInfos.Count; i++) {
                DataItemInfo info = DataItemInfos[i];
                CreateDataHelper (info);
            }
        }