예제 #1
0
        /**
         * @language zh_CN
         * 加载、解析并添加贴图集数据。
         * @param path 贴图集数据在 Resources 中的路径。(其他形式的加载可自行扩展,使用 factory.ParseTextureAtlasData(JSONObject, Material))
         * @param name 为数据指定一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
         * @param scale 为贴图集设置一个缩放值。
         * @returns 贴图集数据
         * @see #ParseTextureAtlasData()
         * @see #GetTextureAtlasData()
         * @see #AddTextureAtlasData()
         * @see #RemoveTextureAtlasData()
         * @see DragonBones.UnityTextureAtlasData
         */
        public UnityTextureAtlasData LoadTextureAtlasData(string path, string name = null, float scale = 0.0f)
        {
            var index = path.LastIndexOf("Assets/");

            if (index > -1)
            {
                path = path.Substring(index + 7);
            }

            //index = path.LastIndexOf(".");
            //if (index > 0)
            //{
            //    path = path.Substring(0, index);
            //}

            UnityTextureAtlasData textureAtlasData = null;

            if (_pathTextureAtlasDataMap.ContainsKey(path))
            {
                textureAtlasData = _pathTextureAtlasDataMap[path] as UnityTextureAtlasData;
                _refreshTextureAtlas(textureAtlasData);
            }
            else
            {
                _textureAtlasPath = path;
                TextAsset ta = CAssetManager.GetAsset(path) as TextAsset;
                textureAtlasData = LoadTextureAtlasData(ta, name, scale);
                if (textureAtlasData != null)
                {
                    _pathTextureAtlasDataMap[path] = textureAtlasData;
                }
            }

            return(textureAtlasData);
        }
예제 #2
0
    static int GetAssetSprite(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                UnityEngine.Sprite o    = CAssetManager.GetAssetSprite(arg0);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                string             arg1 = ToLua.CheckString(L, 2);
                UnityEngine.Sprite o    = CAssetManager.GetAssetSprite(arg0, arg1);
                ToLua.PushSealed(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: CAssetManager.GetAssetSprite"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #3
0
        /**
         * @language zh_CN
         * 加载、解析并添加龙骨数据。
         * @param path 龙骨数据在 Resources 中的路径。(其他形式的加载可自行扩展)
         * @param name 为数据提供一个名称,以便可以通过这个名称获取数据,如果未设置,则使用数据中的名称。
         * @param scale 为所有骨架设置一个缩放值。
         * @returns 龙骨数据
         * @see #ParseDragonBonesData()
         * @see #GetDragonBonesData()
         * @see #AddDragonBonesData()
         * @see #RemoveDragonBonesData()
         * @see DragonBones.DragonBonesData
         */
        public DragonBonesData LoadDragonBonesData(string path, string name = null, float scale = 0.01f)
        {
            var index = path.LastIndexOf("Assets/");

            if (index > -1)
            {
                path = path.Substring(index + 7);
            }

            //index = path.LastIndexOf(".");
            //if (index > 0)
            //{
            //    path = path.Substring(0, index);
            //}

            if (_pathDragonBonesDataMap.ContainsKey(path))
            {
                return(_pathDragonBonesDataMap[path]);
            }
            TextAsset ta = CAssetManager.GetAsset(path) as TextAsset;
            var       dragonBonesData = LoadDragonBonesData(ta, name);

            if (dragonBonesData != null)
            {
                _pathDragonBonesDataMap[path] = dragonBonesData;
            }

            return(dragonBonesData);
        }
예제 #4
0
    static int GetAsset(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                UnityEngine.Object o    = CAssetManager.GetAsset(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string             arg0 = ToLua.CheckString(L, 1);
                System.Type        arg1 = ToLua.CheckMonoType(L, 2);
                UnityEngine.Object o    = CAssetManager.GetAsset(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: CAssetManager.GetAsset"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #5
0
    public static Dictionary <string, string> m_taskMap     = new Dictionary <string, string>(); //任务配置里面的文字

    public static void Initialize()
    {
        //加载模板文字
        TextAsset   xmlAsset = CAssetManager.GetAsset("config/language/lang_tpl.xml", typeof(TextAsset)) as TextAsset; //Resources.Load<TextAsset>("config/language/lang_tpl");
        XmlDocument xmlDoc   = new XmlDocument();

        xmlDoc.LoadXml(xmlAsset.text);

        XmlNode xmlData = xmlDoc.SelectSingleNode("/root/data");

        if (xmlData != null)
        {
            foreach (XmlElement dor in xmlData.ChildNodes)
            {
                m_tplMap.Add(dor.Attributes["id"].Value, dor.Attributes["str"].Value);
            }
        }

        //加载错误码
        //xmlAsset = Resources.Load<TextAsset>("config/language/errorcode");
        xmlAsset = CAssetManager.GetAsset("config/language/errorcode.xml", typeof(TextAsset)) as TextAsset;
        XmlDocument xmlDoc1 = new XmlDocument();

        xmlDoc1.LoadXml(xmlAsset.text);

        XmlNode xmlData1 = xmlDoc1.SelectSingleNode("/errorcode");

        if (xmlData1 != null)
        {
            foreach (XmlElement dor in xmlData1.ChildNodes)
            {
                if (!m_errorMap.ContainsKey(dor.Attributes["id"].Value))
                {
                    m_errorMap.Add(dor.Attributes["id"].Value, dor.Attributes["text"].Value);
                }
            }
        }

        ////加载任务文字
        //xmlAsset = Resources.Load<TextAsset>("config/language/task_txt");
        //XmlDocument xmlDoc2 = new XmlDocument();
        //xmlDoc2.LoadXml(xmlAsset.text);
        //XmlNode xmlData2 = xmlDoc2.SelectSingleNode("/data");
        //if (xmlData2 != null)
        //{
        //    foreach (XmlElement dor in xmlData2.ChildNodes)
        //    {
        //        m_taskMap.Add(dor.Attributes["id"].Value, dor.Attributes["str"].Value);
        //    }
        //}

        InitLanguageData();
        //InitConfigLanguage();
    }
예제 #6
0
파일: LuaXml.cs 프로젝트: maple0303/bombMan
    public static string LoadXml(string strXmlPath)
    {
        //TextAsset xmlAsset = Resources.Load<TextAsset>(strXmlPath);
        TextAsset xmlAsset = CAssetManager.GetAsset(strXmlPath + ".xml", typeof(TextAsset)) as TextAsset;

        if (xmlAsset == null)
        {
            return("");
        }

        return(LoadXmlForText(xmlAsset.text));
    }
예제 #7
0
 static int StopCurAsyncLoading(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         CAssetManager.StopCurAsyncLoading();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #8
0
        /**
         * @private
         */
        protected void _refreshTextureAtlas(UnityTextureAtlasData textureAtlasData)
        {
            if (textureAtlasData.texture == null)
            {
                //Texture2D textureAtlas = Resources.Load<Texture2D>(textureAtlasData.imagePath);
                Texture2D textureAtlas = CAssetManager.GetAsset(textureAtlasData.imagePath) as Texture2D;
                var       shader       = Shader.Find(defaultShaderName);
                var       material     = new Material(shader);
                material.mainTexture = textureAtlas;

                textureAtlasData.texture = material;
            }
        }
예제 #9
0
 static int UnloadAsset(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         CAssetManager.UnloadAsset(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #10
0
 static int ClearAsyncLoadingTask(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         CAssetManager obj = (CAssetManager)ToLua.CheckObject <CAssetManager>(L, 1);
         obj.ClearAsyncLoadingTask();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #11
0
 static int LoadResAsync(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string arg0 = ToLua.CheckString(L, 1);
         System.Action <UnityEngine.Object> arg1 = (System.Action <UnityEngine.Object>)ToLua.CheckDelegate <System.Action <UnityEngine.Object> >(L, 2);
         CAssetManager.LoadResAsync(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #12
0
 static int GetLuaScript(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         string arg0 = ToLua.CheckString(L, 1);
         byte[] o    = CAssetManager.GetLuaScript(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #13
0
 static int UnloadInsObj(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         string arg0 = ToLua.CheckString(L, 1);
         int    arg1 = (int)LuaDLL.luaL_checknumber(L, 2);
         CAssetManager.UnloadInsObj(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #14
0
 static int InstantiateGameObject(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         string arg1 = ToLua.CheckString(L, 2);
         UnityEngine.GameObject o = CAssetManager.InstantiateGameObject(arg0, arg1);
         ToLua.PushSealed(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #15
0
 static int ExeCoroutineTask(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         CAssetManager          obj  = (CAssetManager)ToLua.CheckObject <CAssetManager>(L, 1);
         System.Action          arg0 = (System.Action)ToLua.CheckDelegate <System.Action>(L, 2);
         System.Action <object> arg1 = (System.Action <object>)ToLua.CheckDelegate <System.Action <object> >(L, 3);
         object arg2 = ToLua.ToVarObject(L, 4);
         obj.ExeCoroutineTask(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #16
0
 static int LoadResAsync(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 4);
         CAssetManager obj  = (CAssetManager)ToLua.CheckObject <CAssetManager>(L, 1);
         string        arg0 = ToLua.CheckString(L, 2);
         System.Action <UnityEngine.Object> arg1 = (System.Action <UnityEngine.Object>)ToLua.CheckDelegate <System.Action <UnityEngine.Object> >(L, 3);
         bool arg2 = LuaDLL.luaL_checkboolean(L, 4);
         obj.LoadResAsync(arg0, arg1, arg2);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
예제 #17
0
    // 语言配置文件加载
    public static void InitLanguageData()
    {
        TextAsset   xmlAsset = CAssetManager.GetAsset("config/language/languagedata.xml", typeof(TextAsset)) as TextAsset; //Resources.Load<TextAsset>("config/language/languagedata");
        XmlDocument xmlDoc1  = new XmlDocument();

        xmlDoc1.LoadXml(xmlAsset.text);

        XmlNode xmlData1 = xmlDoc1.SelectSingleNode("/data");

        if (xmlData1 != null)
        {
            foreach (XmlElement dor in xmlData1.ChildNodes)
            {
                if (!m_languageMap.ContainsKey(dor.Attributes["id"].Value))
                {
                    m_languageMap.Add(dor.Attributes["id"].Value, dor.Attributes["str"].Value);
                }
            }
        }
    }
예제 #18
0
    static int GetAssetSpriteAsync(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2)
            {
                CAssetManager obj  = (CAssetManager)ToLua.CheckObject <CAssetManager>(L, 1);
                string        arg0 = ToLua.CheckString(L, 2);
                obj.GetAssetSpriteAsync(arg0);
                return(0);
            }
            else if (count == 3)
            {
                CAssetManager obj  = (CAssetManager)ToLua.CheckObject <CAssetManager>(L, 1);
                string        arg0 = ToLua.CheckString(L, 2);
                string        arg1 = ToLua.CheckString(L, 3);
                obj.GetAssetSpriteAsync(arg0, arg1);
                return(0);
            }
            else if (count == 4)
            {
                CAssetManager obj  = (CAssetManager)ToLua.CheckObject <CAssetManager>(L, 1);
                string        arg0 = ToLua.CheckString(L, 2);
                string        arg1 = ToLua.CheckString(L, 3);
                System.Action <UnityEngine.Object> arg2 = (System.Action <UnityEngine.Object>)ToLua.CheckDelegate <System.Action <UnityEngine.Object> >(L, 4);
                obj.GetAssetSpriteAsync(arg0, arg1, arg2);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: CAssetManager.GetAssetSpriteAsync"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
예제 #19
0
    /*
     * 卸载实例化的对象
     ** strAssetUrl:预设资源路径
     ** nInstanceID:卸载对象的实体ID
     */
    static public void UnloadInsObj(string strAssetUrl, int nInstanceID)
    {
#if !UNITY_EDITOR || ASSETBUNDLE_ENABLE
        bool bUnload = false;
        Dictionary <int, bool> dicUseList;
        if (m_dicInsObjMap.TryGetValue(strAssetUrl, out dicUseList))
        {
            if (dicUseList.ContainsKey(nInstanceID))
            {
                dicUseList.Remove(nInstanceID);
                if (dicUseList.Count == 0)
                {
                    m_dicInsObjMap.Remove(strAssetUrl);
                    bUnload = true;
                }
            }
        }
        if (!bUnload)
        {
            return;
        }
        CAssetManager.UnloadAsset(strAssetUrl);
#endif
    }
예제 #20
0
    void Awake()
    {
        m_assetManager   = this;
        dictAbName       = new Dictionary <string, string>();
        m_dicAssetBundle = new Dictionary <string, AssetBundleData>();

        AssetBundle mainBundle = null;
        // 获得更新包路径
        string strPersistentDataPath = string.Empty;

        if (Application.isMobilePlatform)
        {
            strPersistentDataPath = Application.persistentDataPath;
        }
        // 获得原始数据路径
        string strRawPath = string.Empty;

        switch (Application.platform)
        {
        case RuntimePlatform.Android:
            strRawPath = Application.streamingAssetsPath;
            break;

        case RuntimePlatform.IPhonePlayer:
            strRawPath = Application.dataPath + "/Raw";
            break;

        default:
            strRawPath = Application.streamingAssetsPath;
            break;
        }
        if (strPersistentDataPath != string.Empty && File.Exists(Application.persistentDataPath + "/StreamingAssets"))
        {
            mainBundle = AssetBundle.LoadFromFile(strPersistentDataPath + "/StreamingAssets");
        }
        else
        {
            // 没有新版的bundle主文件,则加载安装包里的bundle主文件
            mainBundle = AssetBundle.LoadFromFile(strRawPath + "/StreamingAssets");
        }
        // 构建资源依赖关系
        manifest = mainBundle.LoadAsset <AssetBundleManifest>("AssetBundleManifest");

        string strAssetRelateUrl = "";

        if (strPersistentDataPath != string.Empty && File.Exists(Application.persistentDataPath + "/AssetRelateData"))
        {
            strAssetRelateUrl = strPersistentDataPath + "/AssetRelateData";
        }
        else
        {
            // 没有新版的bundle主文件,则加载安装包里的bundle主文件
            strAssetRelateUrl = strRawPath + "/AssetRelateData";
        }

        string content = File.ReadAllText(strAssetRelateUrl);

        string[] strArr = content.Split('\n');
        foreach (string nameData in strArr)
        {
            string[] arr           = nameData.Split('|');
            string[] assetNameList = arr[0].Split(',');
            string   strBundleName = arr[1];

            AssetBundleData assetBundleData = new AssetBundleData();
            if (strPersistentDataPath != string.Empty && File.Exists(Application.persistentDataPath + "/" + strBundleName))
            {
                assetBundleData.strAssetPath = strPersistentDataPath + "/" + strBundleName;
            }
            else
            {
                // 没有新版的bundle主文件,则加载安装包里的bundle主文件
                assetBundleData.strAssetPath = strRawPath + "/" + strBundleName;
            }
            assetBundleData.listUseBundleName = new List <string>();

            foreach (string strAssetName in assetNameList)
            {
                if (string.IsNullOrEmpty(strAssetName))
                {
                    continue;
                }
                dictAbName.Add(strAssetName, strBundleName);
            }
            m_dicAssetBundle.Add(strBundleName, assetBundleData);
        }
        mainBundle.Unload(false);
//#endif
    }
예제 #21
0
 public virtual byte[] ReadFile(string fileName)
 {
     return(CAssetManager.GetLuaScript(fileName));
 }
예제 #22
0
    /// <summary>
    /// Game startup.
    /// </summary>
    public CGame(CUnityInterface Interface, string CommandLineArgs)
    {
        _cmdArgs = CommandLineArgs.Split(' ');
        string[] parms;

#if !UNITY_EDITOR
        DataDirectory           = Application.dataPath + "/Data/";
        PersistentDataDirectory = Application.persistentDataPath + "/";
#else
        DataDirectory           = "Data/";
        PersistentDataDirectory = "SaveData/";
#endif

        Config = new CConfig(PersistentDataDirectory + "config.txt");
        Config.Load();

#if !UNITY_EDITOR
        DataDirectory           = Application.dataPath + "/Data/";
        PersistentDataDirectory = Application.persistentDataPath + "/";

        if (_CheckArg("dev", out parms))
        {
            Screen.SetResolution(1280, 720, false);
        }
        else
        {
            string resType = Config.GetString("ResolutionType");

            if (resType == "default")
            {
                Resolution r = Screen.resolutions[Screen.resolutions.Length - 1];
                Screen.SetResolution(r.width, r.height, true);
            }
            else if (resType == "fullscreen" || resType == "windowed")
            {
                Resolution r    = Screen.resolutions[Screen.resolutions.Length - 1];
                int        resX = (int)Config.GetFloat("ResolutionWidth");
                int        resY = (int)Config.GetFloat("ResolutionHeight");

                Screen.SetResolution(resX, resY, (resType == "fullscreen"));
            }
        }
#endif

        CUtility.MakeDirectory(PersistentDataDirectory + SAVES_DIRECTORY);
        CUtility.MakeDirectory(PersistentDataDirectory + REPLAYS_DIRECTORY);

        PrimaryResources = Interface.GetComponent <CPrimaryResources>();
        WorldResources   = Interface.GetComponent <CWorldResources>();
        UIResources      = Interface.GetComponent <CUIResources>();
        ToolkitUI        = Interface.GetComponent <CToolkitUI>();
        GameUIStyle      = Interface.GetComponent <CGameUIStyle>();

        Console = new CConsole();

        Debug.Log("Save game directory: " + PersistentDataDirectory);
        Debug.Log("Data directory: " + DataDirectory);

        VarShowGrid        = Console.CreateVar("show_grid", false);
        VarShowVisLines    = Console.CreateVar("show_los", false);
        VarShowDDATest     = Console.CreateVar("show_ddatest", false);
        VarShowArcTest     = Console.CreateVar("show_arctest", false);
        VarShowBounds      = Console.CreateVar("show_bounds", false);
        VarShowDebugStats  = Console.CreateVar("show_debugstats", false);
        VarShowMobility    = Console.CreateVar("show_mobility", 0, 0, CWorld.MAX_PLAYERS);
        VarShowSolidity    = Console.CreateVar("show_solidity", 0, 0, CWorld.MAX_PLAYERS + 1);
        VarShowProfiler    = Console.CreateVar("show_profiler", false);
        VarNoFow           = Console.CreateVar("no_fow", false);
        VarPlaceItemDirect = Console.CreateVar("place_item_direct", false);
        VarShowComfort     = Console.CreateVar("show_comfort", false);
        VarShowEfficiency  = Console.CreateVar("show_efficiency", false);

        VarShowPathing   = Console.CreateVar("pathing", false);
        VarShowFlowField = Console.CreateVar("show_flowfield", false);
        VarShowNavMesh   = Console.CreateVar("show_navmesh", false);
        VarShowNavRect   = Console.CreateVar("show_navrect", 0, 0, CWorld.MAX_PLAYERS);
        VarShowProxies   = Console.CreateVar("show_proxies", 0, 0, CWorld.MAX_PLAYERS);

        VarFreePurchases = Console.CreateVar("freebuy", true);
        Console.CreateCommand("gameui", (Params) => { UIManager.ToggleUIActive(); });
        Console.CreateCommand("quit", (Params) => { ExitApplication(); });
        Console.CreateCommand("exit", (Params) => { ExitApplication(); });
        Console.CreateCommand("set_owed", (Params) => { if (_gameSession == null)
                                                        {
                                                            return;
                                                        }
                                                        _gameSession.SetOwed(1000); });
        Console.CreateCommand("set_stamina", (Params) => { if (_gameSession == null)
                                                           {
                                                               return;
                                                           }
                                                           _gameSession.SetStamina(10.0f); });
        Console.CreateCommand("set_hunger", (Params) => { if (_gameSession == null)
                                                          {
                                                              return;
                                                          }
                                                          _gameSession.SetHunger(80); });
        Console.CreateCommand("rebuild_icons", (Params) => { IconBuilder.RebuildItemIcons(true); });

        Game  = this;
        Steam = new CSteam();
        PrimaryThreadProfiler = new CProfiler();
        SimThreadProfiler     = new CProfiler();
        DebugLevels           = new CDebugLevels();
        UniversalRandom       = new CRandomStream();
        AssetManager          = new CAssetManager();
        Net           = new CNet();
        Resources     = new CResources();
        CameraManager = new CCameraManager();
        UIManager     = new CUIManager(ToolkitUI, GameUIStyle);
        CDebug.StaticInit();
        AssetManager.Init();
        ProfilerManager = new CProfilerManager();
        ProfilerManager.Init();
        IconBuilder = new CIconBuilder();
        IconBuilder.Init();
        _inputState = new CInputState();

        Console.Hide();
        Analytics.SetUserId(Steam.mSteamID.ToString());

        // TODO: Backquote is not ~, investigate.
        // TOOD: Allow the same command to have multiple keys associated with it.
        _inputState.RegisterCommand("console", Config.GetString("KeyConsole"), true);

        _inputState.RegisterCommand("escape", Config.GetString("KeyEscape"));

        _inputState.RegisterCommand("focusOnSpawn", Config.GetString("KeyFocusOnSpawn"));

        _inputState.RegisterCommand("camForward", Config.GetString("KeyCamForward"));
        _inputState.RegisterCommand("camLeft", Config.GetString("KeyCamLeft"));
        _inputState.RegisterCommand("camBackward", Config.GetString("KeyCamBackward"));
        _inputState.RegisterCommand("camRight", Config.GetString("KeyCamRight"));
        _inputState.RegisterCommand("camRotateLeft", KeyCode.Delete);
        _inputState.RegisterCommand("camRotateRight", KeyCode.PageDown);

        _inputState.RegisterCommand("itemPlaceRotate", Config.GetString("KeyPlaceRotate"));
        _inputState.RegisterCommand("itemPlaceRepeat", Config.GetString("KeyPlaceRepeat"));

        _inputState.RegisterCommand("action1", Config.GetString("KeyAction1"));
        _inputState.RegisterCommand("action2", Config.GetString("KeyAction2"));
        _inputState.RegisterCommand("action3", Config.GetString("KeyAction3"));
        _inputState.RegisterCommand("action4", Config.GetString("KeyAction4"));

        _inputState.RegisterCommand("openOptions", Config.GetString("KeyOptionsMenu"));

        _inputState.RegisterCommand("reload", KeyCode.F5);
        _inputState.RegisterCommand("space", KeyCode.Space);

        _inputState.RegisterCommand("editorDelete", Config.GetString("KeyEditorDelete"));
        _inputState.RegisterCommand("editorDuplicate", Config.GetString("KeyEditorDuplicate"));
        _inputState.RegisterCommand("editorUndo", Config.GetString("KeyEditorUndo"));
        _inputState.RegisterCommand("editorRedo", Config.GetString("KeyEditorRedo"));
        _inputState.RegisterCommand("editorSave", Config.GetString("KeyEditorSave"));

        // Apply default settings
        //Application.targetFrameRate = 60;
        //QualitySettings.antiAliasing

        // Volume range: 0.0 - -80.0
        // TODO: Volume in DB is exponential, making 0 to 1 range for config ineffective.
        UIResources.MasterMixer.SetFloat("MasterVolume", CMath.MapRangeClamp(Config.GetFloat("MasterVolume"), 0, 1, -80, -12));
        UIResources.MasterMixer.SetFloat("MusicVolume", CMath.MapRangeClamp(Config.GetFloat("MusicVolume"), 0, 1, -80, 0));
        UIResources.MasterMixer.SetFloat("SoundsVolume", CMath.MapRangeClamp(Config.GetFloat("SoundsVolume"), 0, 1, -80, 0));
        UIResources.MasterMixer.SetFloat("UISoundsVolume", CMath.MapRangeClamp(Config.GetFloat("UISoundsVolume"), 0, 1, -80, 0));

        // NOTE: BE SUPER CAREFUL WITH THIS
        // You can corrupt ALL the item assets if not careful.
        // Saves asset to disk, but asset currently in memory won't reflect new version.
        //_resaveAllItemAssetsToLastestVersion();

        // TODO: This bootstraps all model assets on startup.
        // If the model asset is first loaded by the sim thread, then it will crash as it tries to generate the meshes.
        // Should probably only generate meshes when they are pulled in by the main thread.
        _testItemAssetVersion();

        if (_CheckArg("toolkit", out parms))
        {
            StartAssetToolkit();
        }
        else if (_CheckArg("map", out parms))
        {
            if (parms != null && parms.Length > 0)
            {
                CGameSession.CStartParams startParams = new CGameSession.CStartParams();
                startParams.mPlayType        = CGameSession.EPlayType.SINGLE;
                startParams.mUserPlayerIndex = 0;                 // Will be set by the level when loaded.
                startParams.mLevelName       = parms[0];
                StartGameSession(startParams);
            }
        }
        else
        {
            UIManager.AddInterface(new CMainMenuUI());
        }
    }