@@ -174,7 +174,7 @@ public bool GetBool(string variableName)
174
174
}
175
175
else
176
176
{
177
- Debug . LogError ( $ "ERROR: No variable names { variableName } found! returning 'false' instead") ;
177
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found! returning 'false' instead") ;
178
178
return false ;
179
179
}
180
180
}
@@ -199,7 +199,7 @@ public int GetInt(string variableName)
199
199
}
200
200
else
201
201
{
202
- Debug . LogError ( $ "ERROR: No variable names { variableName } found! returning '0' instead") ;
202
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found! returning '0' instead") ;
203
203
return 0 ;
204
204
}
205
205
}
@@ -224,7 +224,7 @@ public float GetFloat(string variableName)
224
224
}
225
225
else
226
226
{
227
- Debug . LogError ( $ "ERROR: No variable names '{ variableName } ' found! returning '0.0f' instead") ;
227
+ Debug . LogError ( $ "ERROR: No variable named '{ variableName } ' found! returning '0.0f' instead") ;
228
228
return 0.0f ;
229
229
}
230
230
}
@@ -249,7 +249,7 @@ public string GetString(string variableName)
249
249
}
250
250
else
251
251
{
252
- Debug . LogError ( $ "ERROR: No variable names '{ variableName } ' found! returning NULL instead") ;
252
+ Debug . LogError ( $ "ERROR: No variable named '{ variableName } ' found! returning NULL instead") ;
253
253
return null ;
254
254
}
255
255
}
@@ -273,7 +273,7 @@ public void SetBool(string variableName, bool newBool)
273
273
274
274
if ( ! found )
275
275
{
276
- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
276
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
277
277
}
278
278
}
279
279
@@ -292,7 +292,7 @@ public void SetInt(string variableName, int newInt)
292
292
293
293
if ( ! found )
294
294
{
295
- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
295
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
296
296
}
297
297
}
298
298
@@ -311,7 +311,7 @@ public void SetFloat(string variableName, float newFloat)
311
311
312
312
if ( ! found )
313
313
{
314
- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
314
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
315
315
}
316
316
}
317
317
@@ -330,7 +330,7 @@ public void SetString(string variableName, string newString)
330
330
331
331
if ( ! found )
332
332
{
333
- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
333
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
334
334
}
335
335
}
336
336
@@ -340,31 +340,126 @@ public void SetString(string variableName, string newString)
340
340
341
341
public void AddBool ( string newItemName , bool newItemValue )
342
342
{
343
+ for ( int i = 0 ; i < boolList . Count ; i ++ )
344
+ {
345
+ if ( boolList [ i ] . name == newItemName )
346
+ {
347
+ Debug . LogError ( $ "ERROR: There is already a boolean named { newItemValue } in { jsonFile . name } .json!") ;
348
+ return ;
349
+ }
350
+ }
351
+
343
352
boolList . Add ( new JSONBoolean ( newItemName , newItemValue ) ) ;
344
353
}
345
354
346
355
public void AddInt ( string newItemName , int newItemValue )
347
356
{
357
+ for ( int i = 0 ; i < intList . Count ; i ++ )
358
+ {
359
+ if ( intList [ i ] . name == newItemName )
360
+ {
361
+ Debug . LogError ( $ "ERROR: There is already a integer named { newItemValue } in { jsonFile . name } .json!") ;
362
+ return ;
363
+ }
364
+ }
365
+
348
366
intList . Add ( new JSONInteger ( newItemName , newItemValue ) ) ;
349
367
}
350
368
351
369
public void AddFloat ( string newItemName , float newItemValue )
352
370
{
371
+ for ( int i = 0 ; i < floatList . Count ; i ++ )
372
+ {
373
+ if ( floatList [ i ] . name == newItemName )
374
+ {
375
+ Debug . LogError ( $ "ERROR: There is already a float named { newItemValue } in { jsonFile . name } .json!") ;
376
+ return ;
377
+ }
378
+ }
379
+
353
380
floatList . Add ( new JSONFloat ( newItemName , newItemValue ) ) ;
354
381
}
355
382
356
383
public void AddString ( string newItemName , string newItemValue )
357
384
{
385
+ for ( int i = 0 ; i < stringList . Count ; i ++ )
386
+ {
387
+ if ( stringList [ i ] . name == newItemName )
388
+ {
389
+ Debug . LogError ( $ "ERROR: There is already a string named { newItemValue } in { jsonFile . name } .json!") ;
390
+ return ;
391
+ }
392
+ }
393
+
358
394
stringList . Add ( new JSONString ( newItemName , newItemValue ) ) ;
359
395
}
360
396
361
397
#endregion Add Functions
398
+
399
+ #region Remove Functions
400
+
401
+ public void RemoveBool ( string variableName )
402
+ {
403
+ for ( int i = 0 ; i < boolList . Count ; i ++ )
404
+ {
405
+ if ( boolList [ i ] . name == variableName )
406
+ {
407
+ boolList . Remove ( boolList [ i ] ) ;
408
+ return ;
409
+ }
410
+ }
411
+
412
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
413
+ }
362
414
415
+ public void RemoveInt ( string variableName )
416
+ {
417
+ for ( int i = 0 ; i < intList . Count ; i ++ )
418
+ {
419
+ if ( intList [ i ] . name == variableName )
420
+ {
421
+ intList . Remove ( intList [ i ] ) ;
422
+ return ;
423
+ }
424
+ }
425
+
426
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
427
+ }
428
+
429
+ public void RemoveFloat ( string variableName )
430
+ {
431
+ for ( int i = 0 ; i < floatList . Count ; i ++ )
432
+ {
433
+ if ( floatList [ i ] . name == variableName )
434
+ {
435
+ floatList . Remove ( floatList [ i ] ) ;
436
+ return ;
437
+ }
438
+ }
439
+
440
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
441
+ }
442
+
443
+ public void RemoveString ( string variableName )
444
+ {
445
+ for ( int i = 0 ; i < stringList . Count ; i ++ )
446
+ {
447
+ if ( stringList [ i ] . name == variableName )
448
+ {
449
+ stringList . Remove ( stringList [ i ] ) ;
450
+ return ;
451
+ }
452
+ }
453
+
454
+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
455
+ }
456
+
457
+ #endregion Remove Functions
363
458
}
364
459
365
460
#region JSON Variables
366
461
367
- [ System . Serializable ]
462
+ [ Serializable ]
368
463
public class JSONBoolean
369
464
{
370
465
public string name ;
@@ -377,7 +472,7 @@ public JSONBoolean(string name, bool value)
377
472
}
378
473
}
379
474
380
- [ System . Serializable ]
475
+ [ Serializable ]
381
476
public class JSONInteger
382
477
{
383
478
public string name ;
@@ -390,7 +485,7 @@ public JSONInteger(string name, int value)
390
485
}
391
486
}
392
487
393
- [ System . Serializable ]
488
+ [ Serializable ]
394
489
public class JSONFloat
395
490
{
396
491
public string name ;
@@ -403,7 +498,7 @@ public JSONFloat(string name, float value)
403
498
}
404
499
}
405
500
406
- [ System . Serializable ]
501
+ [ Serializable ]
407
502
public class JSONString
408
503
{
409
504
public string name ;
0 commit comments