Bon, alors j'ai un peu avancé mais ça ne fonctionne toujours pas
J'arrive à lire mon fichier, à le modifier, à le sauvegarder. Ou est le problème me direz vous ? Ben il ne prend pas en compte ma modification, allez savoir pourquoi ...
Voici mon fichier .vl (équivalent au .txt)
Code : Tout sélectionner
{
"type": "VisionLibTrackerConfig",
"version": 1,
"meta": {
"author": "",
"description": "",
"name": "",
"vlTrackingConfig": {},
"uuid": "2bcc7e7f-6220-4a6a-af5b-166b7afd17c6",
"timeCreated": 1601545823,
"timeChanged": 1601545825
},
"tracker": {
"type": "modelTracker",
"version": 1,
"parameters": {
"minInlierRatioInit": 0.6,
"minInlierRatioTracking": 0.42,
"laplaceThreshold": 1,
"normalThreshold": 2.5,
"lineGradientThreshold": 40,
"lineSearchLengthInitRelative": 0.04125,
"lineSearchLengthTrackingRelative": 0.03125,
"keyFrameDistance": 50,
"metric": "cm",
"showLineModel": true,
"models": [
{
"name": "Gaio_ModelTarget_V01",
"uri": "project_dir:Gaio_ModelTarget_V01.fbx"
}
],
"initPose": {
"t": [
-7.307137489318848,
37.529937744140625,
299.53997802734375
],
"q": [
0.995162308216095,
0.09824426472187042,
0,
0
]
}
}
}
}
Et voici mon code
[*][*]
Code : Tout sélectionner
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using SimpleJSON;
public class ChangeJsonValue : MonoBehaviour
{
string path;
string jsonString;
// Start is called before the first frame update
void Start()
{
path = Application.dataPath + "/StreamingAssets/VisionLib/Gaio/test.vl";
jsonString = File.ReadAllText(path);
JSONNode data = JSON.Parse(jsonString);
foreach (JSONNode record in data["tracker"])
{
record["showLineModel"] = false;
Debug.Log(record["showLineModel"]);
}
}
private void Update()
{
File.WriteAllText(Application.dataPath + "/StreamingAssets/VisionLib/Gaio/sdsd.vl", jsonString);
}
}
Dans la console d'unity le changement s'effectue bien, mais quand je vérifie sur mon nouveau fichier il n'y a aucune modification. Je ne comprends pas pourquoi.
Si quelqu'un a une idée ça serait super !
Merci bien