@@ -174,7 +174,7 @@ public bool GetBool(string variableName)
174174 }
175175 else
176176 {
177- Debug . LogError ( $ "ERROR: No variable names { variableName } found! returning 'false' instead") ;
177+ Debug . LogError ( $ "ERROR: No variable named { variableName } found! returning 'false' instead") ;
178178 return false ;
179179 }
180180 }
@@ -199,7 +199,7 @@ public int GetInt(string variableName)
199199 }
200200 else
201201 {
202- Debug . LogError ( $ "ERROR: No variable names { variableName } found! returning '0' instead") ;
202+ Debug . LogError ( $ "ERROR: No variable named { variableName } found! returning '0' instead") ;
203203 return 0 ;
204204 }
205205 }
@@ -224,7 +224,7 @@ public float GetFloat(string variableName)
224224 }
225225 else
226226 {
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") ;
228228 return 0.0f ;
229229 }
230230 }
@@ -249,7 +249,7 @@ public string GetString(string variableName)
249249 }
250250 else
251251 {
252- Debug . LogError ( $ "ERROR: No variable names '{ variableName } ' found! returning NULL instead") ;
252+ Debug . LogError ( $ "ERROR: No variable named '{ variableName } ' found! returning NULL instead") ;
253253 return null ;
254254 }
255255 }
@@ -273,7 +273,7 @@ public void SetBool(string variableName, bool newBool)
273273
274274 if ( ! found )
275275 {
276- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
276+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
277277 }
278278 }
279279
@@ -292,7 +292,7 @@ public void SetInt(string variableName, int newInt)
292292
293293 if ( ! found )
294294 {
295- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
295+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
296296 }
297297 }
298298
@@ -311,7 +311,7 @@ public void SetFloat(string variableName, float newFloat)
311311
312312 if ( ! found )
313313 {
314- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
314+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
315315 }
316316 }
317317
@@ -330,7 +330,7 @@ public void SetString(string variableName, string newString)
330330
331331 if ( ! found )
332332 {
333- Debug . LogError ( $ "ERROR: No variable names { variableName } found!") ;
333+ Debug . LogError ( $ "ERROR: No variable named { variableName } found!") ;
334334 }
335335 }
336336
@@ -340,31 +340,126 @@ public void SetString(string variableName, string newString)
340340
341341 public void AddBool ( string newItemName , bool newItemValue )
342342 {
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+
343352 boolList . Add ( new JSONBoolean ( newItemName , newItemValue ) ) ;
344353 }
345354
346355 public void AddInt ( string newItemName , int newItemValue )
347356 {
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+
348366 intList . Add ( new JSONInteger ( newItemName , newItemValue ) ) ;
349367 }
350368
351369 public void AddFloat ( string newItemName , float newItemValue )
352370 {
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+
353380 floatList . Add ( new JSONFloat ( newItemName , newItemValue ) ) ;
354381 }
355382
356383 public void AddString ( string newItemName , string newItemValue )
357384 {
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+
358394 stringList . Add ( new JSONString ( newItemName , newItemValue ) ) ;
359395 }
360396
361397 #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+ }
362414
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
363458 }
364459
365460 #region JSON Variables
366461
367- [ System . Serializable ]
462+ [ Serializable ]
368463 public class JSONBoolean
369464 {
370465 public string name ;
@@ -377,7 +472,7 @@ public JSONBoolean(string name, bool value)
377472 }
378473 }
379474
380- [ System . Serializable ]
475+ [ Serializable ]
381476 public class JSONInteger
382477 {
383478 public string name ;
@@ -390,7 +485,7 @@ public JSONInteger(string name, int value)
390485 }
391486 }
392487
393- [ System . Serializable ]
488+ [ Serializable ]
394489 public class JSONFloat
395490 {
396491 public string name ;
@@ -403,7 +498,7 @@ public JSONFloat(string name, float value)
403498 }
404499 }
405500
406- [ System . Serializable ]
501+ [ Serializable ]
407502 public class JSONString
408503 {
409504 public string name ;
0 commit comments