Question by
Codinablack · Mar 01, 2018 at 12:32 PM ·
c#errorfile-iocasting
Why I Cannot cast from source type to destination type
I got this script trying to load a config file which loads fine, but when I try to read some results I can't seem to cast them correctly?
using UnityEngine;
using System;
using System.Collections;
using System.Collections.Generic;
using NLua;
public static class ConfigLoader
{
public static void LoadConfig()
{
Lua lua = new Lua();
lua.DoFile("C:\\Users\\Boss\\config.lua");
String result = (string)lua.GetString("login");
Debug.Log(result);
}
}
Even if I change result to a var type nothing, not sure what I am doing wrong... Anybody got an clues? I promise the lua library loads fine, already worked out all those errors.
Comment
Tried like this too
string result = (string)lua["login"];
Your answer
![](https://koobas.hobune.stream/wayback/20220612153714im_/https://answers.unity.com/themes/thub/images/avi.jpg)