コード例 #1
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 ();
        }
コード例 #2
0
        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();
 }
コード例 #6
0
        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> ();
 }
コード例 #8
0
        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;
        }
コード例 #13
0
        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;
        }
コード例 #15
0
        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;
        }
コード例 #16
0
 public static string ToJson(LSDatabase database)
 {
     return(JsonUtility.ToJson(database, true));
 }
コード例 #17
0
 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);
 }
コード例 #19
0
 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;
        }
コード例 #21
0
 public static void Setup()
 {
     LSDatabase database = LSFSettingsManager.GetSettings ().Database;
     _currentDatabase = database;
 }
コード例 #22
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);
            }
        }