Esempio n. 1
0
 public static void SetDataChanges(ScriptableObject scriptable, data_changes_enum new_data_changes)
 {
     if (scriptable is IntVariable int_var)
     {
         int_var.data_changes = new_data_changes;
     }
     else if (scriptable is StringVariable string_var)
     {
         string_var.data_changes = new_data_changes;
     }
     else if (scriptable is BoolVariable bool_var)
     {
         bool_var.data_changes = new_data_changes;
     }
     else if (scriptable is FloatVariable float_var)
     {
         float_var.data_changes = new_data_changes;
     }
     else if (scriptable is SODict sodict)
     {
         sodict.data_changes = new_data_changes;
     }
     else if (scriptable is SOList solist)
     {
         solist.data_changes = new_data_changes;
     }
     else
     {
         throw new Exception(scriptable.name + " is not supported type!");
     }
 }
Esempio n. 2
0
 public MetaData(string guid, string type_string, data_changes_enum data_changes, created_type_enum created_type)
 {
     this.guid         = guid;
     this.type_string  = type_string;
     this.data_changes = data_changes;
     this.created_type = created_type;
 }
Esempio n. 3
0
    // Start data for non-persistent stuff
    public static ScriptableObject CreateSOD(string type_string, data_changes_enum data_changes, object start_value)
    {
        string guid = NewGUID();

        ScriptableObject new_scriptable = ScriptableObject.CreateInstance(type_string);

        SetDataChanges(new_scriptable, data_changes);
        SetCreatedType(new_scriptable, created_type_enum.code_created);
        root_data.Add(guid, new_scriptable);

        SetStartValue(new_scriptable, start_value);

        // Make sure that we save new_scriptable on disk
        SaveOnDisk(new_scriptable);

        return(new_scriptable);
    }
Esempio n. 4
0
    public static ScriptableObject LoadSOD(string type_string, string guid, data_changes_enum data_changes)
    {
        if (!ES3.KeyExists(guid, main_data_path))
        {
            return(null);
        }

        ScriptableObject new_scriptable = ScriptableObject.CreateInstance(type_string);

        SetDataChanges(new_scriptable, data_changes);
        SetCreatedType(new_scriptable, created_type_enum.code_created);
        root_data.Add(guid, new_scriptable);

        LoadFromDisk(new_scriptable);

        return(new_scriptable);
    }
Esempio n. 5
0
    private static MetaData GetMetadataFromSOD(ScriptableObject scriptable)
    {
        string            type_string     = scriptable.GetType().ToString();
        string            scriptable_guid = GetFirstGUIDByScriptable(root_data, scriptable);
        data_changes_enum data_changes    = GetDataChanges(scriptable);
        created_type_enum created_type    = GetCreatedType(scriptable);

        if (scriptable_guid == "")
        {
            // It should not happen under any circumstances, because
            // editor_created stuff is always in root_data / or it goes through CreateCustomSOD
            // code_created stuff goes through CreateSOD
            // and so all data inside SODict is added in root_data before this method

            Debug.LogError(scriptable.name + " scriptable does not exist in root_data!");
        }

        return(new MetaData(scriptable_guid, type_string, data_changes, created_type));
    }
Esempio n. 6
0
    private void SetEditorDataChanges(data_changes_enum new_data_changes)
    {
        List <ScriptableObject> scrtipables = GetAllScriptables(scriptables_path);

        for (int i = 0; i < scrtipables.Count; i++)
        {
            ScriptableObject scriptable = scrtipables[i];

            if (scriptable is IntVariable int_var)
            {
                int_var.editor_data_changes = new_data_changes;
            }
            else if (scriptable is StringVariable string_var)
            {
                string_var.editor_data_changes = new_data_changes;
            }
            else if (scriptable is BoolVariable bool_var)
            {
                bool_var.editor_data_changes = new_data_changes;
            }
            else if (scriptable is FloatVariable float_var)
            {
                float_var.editor_data_changes = new_data_changes;
            }
            else if (scriptable is SODict sodict)
            {
                sodict.editor_data_changes = new_data_changes;
            }
            else if (scriptable is SOList solist)
            {
                solist.editor_data_changes = new_data_changes;
            }
            else
            {
                throw new Exception(scriptable.name + " is not supported type!");
            }
        }
    }