public Test001() { const string test001 = "n = 99 + (1 * 10) / 2 - 0.5;\n" + "if n > 10 then return 'Oh, 真的比10还大哦:'..n end\n" + "return n\n"; const string test002 = "return _VERSION"; const string test003 = "return nil"; const bool isLoadLib = true; try { Console.WriteLine("Start test..."); Lua L = new Lua(); if (isLoadLib) { BaseLib.open(L); PackageLib.open(L); MathLib.open(L); OSLib.open(L); StringLib.open(L); TableLib.open(L); } int status = L.doString(test001); if (status != 0) { object errObj = L.value(1); object tostring = L.getGlobal("tostring"); L.push(tostring); L.push(errObj); L.call(1, 1); string errObjStr = L.toString(L.value(-1)); throw new Exception("Error compiling : " + L.value(1)); } else { object result = L.value(1); object tostring_ = L.getGlobal("tostring"); L.push(tostring_); L.push(result); L.call(1, 1); string resultStr = L.toString(L.value(-1)); Console.WriteLine("Result >>> " + resultStr); } } catch (Exception e) { Console.WriteLine(e); } }
public static LuaTable CreateGlobalEnviroment() { LuaTable global = new LuaTable(); BaseLib.RegisterFunctions(global); StringLib.RegisterModule(global); TableLib.RegisterModule(global); IOLib.RegisterModule(global); FileLib.RegisterModule(global); MathLib.RegisterModule(global); OSLib.RegisterModule(global); global.SetNameValue("_G", global); return(global); }
public OSLibObject(int id, string type, string brand, string thumbnail, OSLib library, OSLibModel model, OSLibModules modules, OSLibCategory cat, bool mode2d, bool allowscale, int ScaleGenerale) { _id = id; _type = type; _brand = brand; _thumbnailPath = thumbnail; _library = library; _model = model; _modules = modules; _categorie = cat; _mode2d = mode2d; _allowscale = allowscale; _ScaleGenerale = ScaleGenerale; }
// merge multiple librairies into one to fit the interface public static OSLib MergeLibraries(ICollection<OSLib> libraries) { OSLib mergedLibrary = new OSLib (-1, -1, "", "Merge", ""); foreach (OSLib library in libraries) { foreach (OSLibCategory catLvl1 in library.GetCategoryList ()) { _searchedId = catLvl1.GetBrandId(); if(_searchedId==-1) _searchedId = catLvl1.GetId (); OSLibCategory libraryCatLvl1 = mergedLibrary.GetCategoryList ().Find (IsCategoryWithId); if (libraryCatLvl1 == null) { libraryCatLvl1 = new OSLibCategory (catLvl1.GetId (), null, catLvl1, catLvl1.GetBrandId()); mergedLibrary.AddCategory (libraryCatLvl1); } foreach (OSLibCategory catLvl2 in catLvl1.GetCategoryList ()) { _searchedId = catLvl2.GetBrandId(); if(_searchedId==-1) _searchedId = catLvl2.GetId (); OSLibCategory libraryCatLvl2 = libraryCatLvl1.GetCategoryList ().Find (IsCategoryWithId); if (libraryCatLvl2 == null) { libraryCatLvl2 = new OSLibCategory (catLvl2.GetId (), libraryCatLvl1, catLvl2, catLvl2.GetBrandId()); libraryCatLvl1.AddChildCategory (libraryCatLvl2); } foreach (OSLibObject obj in catLvl2.GetObjectList ()) { libraryCatLvl2.AddObject (obj); } } foreach (OSLibObject obj in catLvl1.GetObjectList ()) { libraryCatLvl1.AddObject (obj); } } foreach (OSLibStairs stairs in library.GetStairsList ()) { _searchedId = stairs.GetId (); OSLibStairs mergedStairs = mergedLibrary.GetStairsList ().Find (IsStairsWithId); if (mergedStairs == null) { mergedStairs = new OSLibStairs (stairs.GetId (), stairs.GetDependency ()); mergedLibrary.AddStairs (mergedStairs); } foreach (OSLibStair stair in stairs.GetStairList ()) { _searchedId = stair.GetId (); OSLibStair mergedStair = mergedStairs.GetStairList ().Find (IsStairWithId); if (mergedStair == null) { mergedStair = new OSLibStair (stair.GetId (), stair.GetStairType (), stair.GetBrand (), stair.GetThumbnailPath ()); mergedStairs.AddStair (mergedStair); } } } } /* //Debug foreach (OSLibCategory catLvl1 in mergedLibrary.GetCategoryList ()) { Debug.Log("Catégorie niveau 1 : "+catLvl1.GetDefaultText()+" id "+catLvl1.GetId()+" brandid "+catLvl1.GetBrandId()); foreach (OSLibCategory catLvl2 in catLvl1.GetCategoryList ()) { Debug.Log("--------------- Catégorie niveau 2 : "+catLvl2.GetDefaultText()+" id "+catLvl2.GetId()+" brandid "+catLvl2.GetBrandId()); foreach (OSLibObject obj in catLvl2.GetObjectList()) { Debug.Log("---------------- -------------- Objets : "+obj.GetDefaultText()+", cat 1 : "+obj.getCategory().GetParentCategory().GetId()+", cat2 : "+obj.getCategory().GetId()); } } }*/ OSLib mergedAndOrderedLibrary = new OSLib (-1, -1, "", "mergedAndOrdered", ""); //Debug foreach (OSLibCategory catLvl1 in mergedLibrary.GetCategoryList ()) { //OSLibCategory catLvl1Ordered = catLvl1; OSLibCategory catLvl1Ordered = new OSLibCategory( catLvl1.GetId(), catLvl1.GetParentCategory(), catLvl1.isPrimaryType(), catLvl1.GetBrandId()); catLvl1Ordered.SetLanguagesDictionary(catLvl1.GetLanguagesDictionary()); catLvl1Ordered.SetDefaultLanguage(catLvl1.GetDefaultLanguage()); foreach (OSLibCategory catLvl2 in catLvl1.GetCategoryList ()) { //catLvl1Ordered.AddChildCategory(catLvl2); if(catLvl1Ordered.GetCategoryList().Count==0) catLvl1Ordered.AddChildCategory(catLvl2); else { bool max = true; for (int countCat=0; countCat < catLvl1Ordered.GetCategoryList().Count; countCat++) { OSLibCategory catLvl2ReOrdered = catLvl1Ordered.GetCategoryList()[countCat]; if(catLvl2ReOrdered.GetBrandId()>catLvl2.GetBrandId()) { catLvl1Ordered.AddChildCategoryAtPosition(catLvl2,countCat); max = false; break; } } if(max) { catLvl1Ordered.AddChildCategory(catLvl2); } } } if(mergedAndOrderedLibrary.GetCategoryList().Count==0) mergedAndOrderedLibrary.AddCategory (catLvl1Ordered); else { bool max = true; for (int countCat=0; countCat<mergedAndOrderedLibrary.GetCategoryList().Count;countCat++) { OSLibCategory catLvl1ReOrdered = mergedAndOrderedLibrary.GetCategoryList()[countCat]; if(catLvl1ReOrdered.GetBrandId()>catLvl1Ordered.GetBrandId()) { mergedAndOrderedLibrary.AddCategoryAtPosition(catLvl1Ordered,countCat); max = false; break; } } if(max) { mergedAndOrderedLibrary.AddCategory(catLvl1Ordered); } } } /* //Debug Debug.Log("----------------------------------------------------------"); Debug.Log("----------------------------------------------------------"); foreach (OSLibCategory catLvl1 in mergedAndOrderedLibrary.GetCategoryList ()) { Debug.Log("Catégorie niveau 1 : "+catLvl1.GetDefaultText()+" id "+catLvl1.GetId()+" brandid "+catLvl1.GetBrandId()); foreach (OSLibCategory catLvl2 in catLvl1.GetCategoryList ()) { Debug.Log("--------------- Catégorie niveau 2 : "+catLvl2.GetDefaultText()+" id "+catLvl2.GetId()+" brandid "+catLvl2.GetBrandId()); foreach (OSLibObject obj in catLvl2.GetObjectList()) { Debug.Log("---------------- -------------- Objets : "+obj.GetDefaultText()+" isMode 2D : "+obj.IsMode2D().ToString()+", cat 1 : "+obj.getCategory().GetParentCategory().GetId()+", cat2 : "+obj.getCategory().GetId()); } } } */ return mergedAndOrderedLibrary; // return mergedLibrary; }
/// <summary> /// Creates a global environment with all the base modules registered and /// some default values set. /// </summary> /// <returns></returns> public static LuaTable CreateGlobalEnviroment(bool createBaseLib = true, bool createStringLib = true, bool createTableLib = true, bool createOSLib = true, bool createIOLib = true, bool createFileLib = true, bool createMathLib = true, bool createScriptLib = true, bool createWinFormsLib = true, bool createConsoleLib = true, bool createCoroutineLib = true, bool createPackageLib = true, bool createClassLib = true, bool createFileSystemLib = true) { LuaTable global = new LuaTable(); // Register Lua Modules if (createBaseLib) { BaseLib.RegisterFunctions(global); } if (createStringLib) { StringLib.RegisterModule(global); } if (createTableLib) { TableLib.RegisterModule(global); } if (createIOLib) { IOLib.RegisterModule(global); } if (createFileLib) { FileLib.RegisterModule(global); } if (createMathLib) { MathLib.RegisterModule(global); } if (createOSLib) { OSLib.RegisterModule(global); } if (createScriptLib) { ScriptLib.RegisterModule(global); } //if (createWinFormsLib) // WinFormLib.RegisterModule(global); if (createConsoleLib) { ConsoleLib.RegisterModule(global); } if (createCoroutineLib) { CoroutineLib.RegisterModule(global); } if (createPackageLib) { PackageLib.RegisterModule(global); } if (createClassLib) { ClassLib.RegisterModule(global); } if (createFileSystemLib) { FileSystemLib.RegisterModule(global); } //global.SetNameValue("_WORKDIR", new LuaString(Application.StartupPath + "\\")); global.SetNameValue("_VERSION", new LuaString("Sharp Lua 1.1")); global.SetNameValue("_G", global); if (createPackageLib) { // set package.preload table LuaTable preload = (LuaTable)(global.GetValue("package") as LuaTable).GetValue("preload"); if (createStringLib) { preload.SetNameValue("string", (LuaTable)global.GetValue("string")); } if (createTableLib) { preload.SetNameValue("table", (LuaTable)global.GetValue("table")); } if (createIOLib) { preload.SetNameValue("io", (LuaTable)global.GetValue("io")); } if (createFileLib) { preload.SetNameValue("file", (LuaTable)global.GetValue("file")); } if (createMathLib) { preload.SetNameValue("math", (LuaTable)global.GetValue("math")); } if (createOSLib) { preload.SetNameValue("os", (LuaTable)global.GetValue("os")); } if (createScriptLib) { preload.SetNameValue("script", (LuaTable)global.GetValue("script")); } //if (createWinFormsLib) // preload.SetNameValue("WinForms", (LuaTable) global.GetValue("WinForms")); if (createConsoleLib) { preload.SetNameValue("console", (LuaTable)global.GetValue("console")); } if (createCoroutineLib) { preload.SetNameValue("coroutine", (LuaTable)global.GetValue("coroutine")); } if (createPackageLib) // wait a second... { preload.SetNameValue("package", (LuaTable)global.GetValue("package")); } if (createClassLib) { preload.SetNameValue("class", (LuaTable)global.GetValue("class")); } if (createFileSystemLib) { preload.SetNameValue("filesystem", (LuaTable)global.GetValue("filesystem")); } } if (createFileSystemLib) { FileSystemLib.currentDir = global.GetValue("_WORKDIR").ToString(); } GlobalEnvironment = global; return(global); }
private IEnumerator ApplyTexture2(Transform target, OSLibTexture textureData, OSLib library) { while(_assetBundleIsOpen) yield return new WaitForEndOfFrame(); _assetBundleIsOpen = true; WWW www = WWW.LoadFromCacheOrDownload (library.GetAssetBundlePath (), library.GetVersion ()); yield return www; AssetBundle assets = www.assetBundle; Texture2D texture = assets.LoadAsset (textureData.GetFilePath2 (), typeof (Texture2D)) as Texture2D; assets.Unload (false); target.GetComponent<Renderer>().material.mainTexture = texture; _assetBundleIsOpen=false; }
private IEnumerator ApplyTexture(Transform target, OSLibTexture textureData, OSLib library) { while(_assetBundleIsOpen) yield return new WaitForEndOfFrame(); _assetBundleIsOpen = true; WWW www = WWW.LoadFromCacheOrDownload (library.GetAssetBundlePath (), library.GetVersion ()); yield return www; AssetBundle assets = www.assetBundle; Texture2D texture = assets.LoadAsset (textureData.GetFilePath (), typeof (Texture2D)) as Texture2D; Texture2D normalMap = null; if (textureData.GetNormalPath () != "") normalMap = assets.LoadAsset (textureData.GetNormalPath (), typeof (Texture2D)) as Texture2D; Texture2D hueMask = null; if (textureData.GetHueMaskPath () != "") hueMask = assets.LoadAsset (textureData.GetHueMaskPath (), typeof (Texture2D)) as Texture2D; Texture2D specularMask = null; if (textureData.GetSpecularMaskPath () != "") specularMask = assets.LoadAsset (textureData.GetSpecularMaskPath (), typeof (Texture2D)) as Texture2D; assets.Unload (false); target.GetComponent<Renderer>().material.mainTexture = texture; float scale = textureData.GetScale(); /*if (target.name.CompareTo("plage")==0) scale/=2.0f;*/ if (target.name.CompareTo("sol")==0) scale/=2.0f; if(target.GetComponent<Renderer>().material.shader.name == "Pointcube/StandardObjet") { target.GetComponent<Renderer>().material.SetTextureScale("_Diffuse",new Vector2(scale,scale)); target.GetComponent<Renderer> ().material.SetTexture ("_Normal", normalMap); target.GetComponent<Renderer> ().material.SetTexture ("_Diffuse", texture); target.GetComponent<Renderer> ().material.SetTexture ("_HueMask", hueMask); target.GetComponent<Renderer> ().material.SetTexture ("_SpecMask", specularMask); Dictionary<string,float> preset; if(target.name == "plage" || target.name == "Plage") { preset = GameObject.Find ("MainScene").GetComponent<LoadShaderPresets>().getConfigPlage(texture.name); } else if(target.name == "margelle" || target.name == "Margelle") { preset = GameObject.Find ("MainScene").GetComponent<LoadShaderPresets>().getConfigMargelle(texture.name); } else if(target.name == "muret" || target.name == "Muret") { preset = GameObject.Find ("MainScene").GetComponent<LoadShaderPresets>().getConfigMuret(texture.name); } else { preset = null; } if(preset != null) { string[] keys = preset.Keys.ToArray(); float red = 0; float green = 0; float blue = 0; foreach (string key in keys) { switch(key) { case "Normallevel ": target.GetComponent<Renderer> ().material.SetFloat("_Normallevel",preset[key]); break ; case "UVtranslation ": target.GetComponent<Renderer> ().material.SetFloat("_UVtranslation",preset[key]); break ; case "UVRotation ": target.GetComponent<AABBOutlineResizer>().setOffsetRotationUV(preset[key]); //target.GetComponent<Renderer> ().material.SetFloat("_UVRotation",preset[key]); break ; case "UVTile ": target.GetComponent<AABBOutlineResizer>().setOffsetTileUV(preset[key]); //target.GetComponent<Renderer> ().material.SetFloat("_UVTile",preset[key]); break ; case "Blur ": target.GetComponent<Renderer> ().material.SetFloat("_Blur",preset[key]); break ; case "gloss ": target.GetComponent<Renderer> ().material.SetFloat("_gloss",preset[key]); break ; case "Specularlevel ": target.GetComponent<Renderer> ().material.SetFloat("_Specularlevel",preset[key]); break ; case "Lightness ": target.GetComponent<Renderer> ().material.SetFloat("_Ligntness",preset[key]); break ; case "HueMaskIntensity ": target.GetComponent<Renderer> ().material.SetFloat("_HueMaskIntensity",preset[key]); break ; case "HuecolorR ": red = preset[key]; break ; case "HuecolorG ": green = preset[key]; break ; case "HuecolorB ": blue = preset[key]; break ; case "Huelevel ": target.GetComponent<AABBOutlineResizer>().setHueLevel(preset[key]);; break ; case "Saturation ": target.GetComponent<AABBOutlineResizer>().setSaturation(preset[key]); break ; case "Bulb ": target.GetComponent<Renderer> ().material.SetFloat("_Bulb",preset[key]); break ; case "Reflexion ": target.GetComponent<Renderer> ().material.SetFloat("_Reflexion",preset[key]); if(preset[key] !=0) { Cubemap temp = Resources.Load("shaders/configs/Chrome 1") as Cubemap; Debug.Log(temp.name + " Reflexion"); target.GetComponent<Renderer> ().material.SetTexture("_CubeMap",temp); } break ; case "Reflexionintensity ": target.GetComponent<Renderer> ().material.SetFloat("_Reflexionintensity",preset[key]); break ; case "ReflexionBlur ": target.GetComponent<Renderer> ().material.SetFloat("_ReflexionBlur",preset[key]); break ; } } Vector3 hue = new Vector3(red,green,blue); Color hueColor = new Color(red,green,blue,1.0f); if(target.name == "plage" || target.name == "Plage") { target.GetComponent<AABBOutlineResizer>().setColorPlage(hue); } else if(target.name == "margelle" || target.name == "Margelle") { target.GetComponent<AABBOutlineResizer>().setColorMargelle(hue); } else if(target.name == "muret" || target.name == "Muret") { target.GetComponent<AABBOutlineResizer>().setColorMuret(hue); } //target.GetComponent<Renderer> ().material.SetColor("_Huecolor",hue); picker.GetComponent<HSVPicker>().currentColor = hueColor; } } else { target.GetComponent<Renderer>().material.SetTextureScale("_MainTex",new Vector2(scale,scale)); target.GetComponent<Renderer> ().material.SetTexture ("_BumpMap", normalMap); } _assetBundleIsOpen=false; }
public void setLibrary(OSLib lib) { m_library = lib; }
//--------------COROUTINES----------------------------------- /* LoadConf() * Chargement de la configuration d'abri par défaut **/ private IEnumerator LoadConf() { _isBuilding = true; Montage.assetBundleLock = true; //Attend que le objdata soit configuré while(gameObject.GetComponent<ObjData>()==null) { yield return new WaitForEndOfFrame(); } while(gameObject.GetComponent<ObjData>().GetObjectModel() == null) { yield return new WaitForEndOfFrame(); } _lib = GetComponent<ObjData>().GetObjectModel().GetLibrary(); //Récupération de l'assetbundle // OSLib libObj = GetComponent<ObjData>().GetObjectModel().GetLibrary(); WWW www = WWW.LoadFromCacheOrDownload (_lib.GetAssetBundlePath (), _lib.GetVersion ()); yield return www; if (www.error != null) { Debug.Log ("AssetBundle ERROR" + www.error); } else { _assetBundle = www.assetBundle; if (_assetBundle != null) { //Chargement de la config TextAsset confXml = _assetBundle.LoadAsset (modelName+"_conf", typeof (TextAsset)) as TextAsset; if (confXml != null) { _dsMdl.ParseConfFile(confXml); } } _assetBundle.Unload (false); } www.Dispose(); //Création de l'abri par default ArrayList stConf= _dsMdl.GetdefaultConf(); _currentColor = _dsMdl.GetColor(_currentColorIndex); if(stConf.Count > 0) { // SaveTransform(); _hasFacadeInDefaultBegin = false; _hasFacadeInDefaultEnd = false; for(int i=0;i<stConf.Count;i=i+3) { ModuleType typ = ModuleType.bloc; switch ((string)stConf[i]) { case "facade": typ = ModuleType.facade; break; case "bloc": typ = ModuleType.bloc; if(IsAbrifixe()) { typ = ModuleType.multiBloc; } break; case "extremite": typ = ModuleType.extremite; break; case "multibloc": typ = ModuleType.multiBloc; break; } if((typ == ModuleType.facade) && (i==0)) { _hasFacadeInDefaultBegin = true; _saveTailleBegin = (int) stConf[i+1]; _saveStyleBegin = (string) stConf[i+2]; continue; } if((typ == ModuleType.facade) && (i>0)) { _hasFacadeInDefaultEnd = true; _saveTailleEnd = (int) stConf[i+1]; _saveStyleEnd = (string) stConf[i+2]; continue; } int t = (int) stConf[i+1]; string styl = (string) stConf[i+2]; _nextInsertion = true; _decalZ = 0.0f; yield return StartCoroutine(AddModule(t,styl,typ,/*_dsMdl.GetColor(0)*/_currentColor,true)); } _isBuilding = false; } if(!_hasFacadeInDefaultEnd) { _selectedIndex = 0; if(IsAbrifixe()) _selectedIndex = Mathf.Clamp(_selectedIndex,1,_modules.Count-2); } UpdateCurrentModule(); UpdateModules(); UpdateBoxCollider(); ChangeModuleColor(_currentColor); // www.Dispose(); Montage.assetBundleLock = false; enabled = false; if(_hasFacadeInDefaultEnd) { yield return StartCoroutine(AddModule(_saveTailleEnd,_saveStyleEnd,ModuleType.facade,_currentColor,true)); _hasFacadeInDefaultEnd = false; _selectedIndex = 0; if(IsAbrifixe()) _selectedIndex = Mathf.Clamp(_selectedIndex,1,_modules.Count-2); } if(_hasFacadeInDefaultBegin) { _selectedIndex = 0; UpdateCurrentModule(); _nextInsertion = false; yield return StartCoroutine(AddModule(_saveTailleBegin,_saveStyleBegin,ModuleType.facade,_currentColor,true)); _hasFacadeInDefaultBegin = false; if(IsAbrifixe()) _selectedIndex = Mathf.Clamp(_selectedIndex,1,_modules.Count-2); UpdateCurrentModule(); UpdateModules(); UpdateBoxCollider(); } //CenterDeployAndFeetLimit(); yield return null; }
public void CreateMenu(OSLib library) { _library = library; Montage.om.setLibrary(library); // < temporaire, mettre cette ligne ailleur //Menu ajout objets //GUIItemV2 originalsObj = new GUIItemV2(0,0,TextManager.GetText("GUIMenuLeft.Add"),"menuAddOn","menuAddOff",this); int x = 0; foreach(OSLibCategory catLvl1 in library.GetCategoryList ()) { if (catLvl1.GetCategoryList ().Count > 0) { GUIItemV2 typToAdd; if(catLvl1.GetText (PlayerPrefs.GetString("language")) == "OneShot 3d") { typToAdd = new GUIItemV2(0,x, catLvl1.GetText (PlayerPrefs.GetString("language")), "menuOSOn", "menuOSOff", this); } else { typToAdd = new GUIItemV2(0,x, catLvl1.GetText (PlayerPrefs.GetString("language")), "menuAddOn", "menuAddOff", this); } _firstCategory[catLvl1.GetBrandId()]=x; x++; int y = 0; foreach(OSLibCategory catLvl2 in catLvl1.GetCategoryList ()) { _secondCategory[catLvl2.GetBrandId()]=y; GUIUpperList fabToAdd = null; string szparentCategory = catLvl2.GetText (PlayerPrefs.GetString("language") + "_parent"); if(szparentCategory != "") { foreach(GUIItemV2 guiItemV2 in listParentCategory) { if(szparentCategory == guiItemV2.m_text) { fabToAdd = new GUIUpperList(1,/*guiItemV2.getSubItemsCount()*/y, catLvl2.GetText (PlayerPrefs.GetString("language")), "sousMenuOn2", "sousMenuOff2", this); guiItemV2.addSubItem(fabToAdd); break; } } if(fabToAdd == null) { GUIItemV2 parent = new GUIItemV2(1,listParentCategory.Count, szparentCategory, "sousMenuOn", "sousMenuOff", this); fabToAdd = new GUIUpperList(1,y, catLvl2.GetText (PlayerPrefs.GetString("language")), "sousMenuOn2", "sousMenuOff2", this); parent.addSubItem(fabToAdd); typToAdd.addSubItem(parent); listParentCategory.Add(parent); } } else { fabToAdd = new GUIUpperList(1,y, catLvl2.GetText (PlayerPrefs.GetString("language")), "sousMenuOn2", "sousMenuOff2", this); typToAdd.addSubItem(fabToAdd); } y++; int size = catLvl2.GetObjectList ().Count; int numberPerPage = 24; //Screen.currentResolution; #if UNITY_IPHONE numberPerPage = 9; #else if(Screen.currentResolution.width/Screen.currentResolution.height == 1.25f) numberPerPage = 25; else if(Screen.currentResolution.width/Screen.currentResolution.height == 1.6f) numberPerPage = 24; else numberPerPage = 24; #endif if( size % numberPerPage != 0) { size = (catLvl2.GetObjectList ().Count/numberPerPage)*numberPerPage + numberPerPage; } Texture2D[] tmpTexs = new Texture2D[size]; string[] tmpTexts = new string[size]; bool[] tmpCustomizables = new bool[size]; bool[] tmpBrands = new bool[size]; int i = 0; foreach(OSLibObject obj in catLvl2.GetObjectList ()) { // load texture Texture2D tmp = obj.GetThumbnail ();//Resources.Load (obj.GetThumbnailPath ()); if(tmp == null) tmp = Resources.Load ("thumbnails/noThumbs", typeof(Texture2D)) as Texture2D; if(obj==null) Debug.Log("Obj null"); if (obj.GetDefaultText ()==null) Debug.Log("Obj null"); // tmp.name = obj.GetDefaultText (); tmpTexts[i] = obj.GetText(PlayerPrefs.GetString("language")); tmpTexs[i] = tmp; tmpCustomizables[i] = obj.GetModules().GetStandardModuleList().Count > 0; tmpBrands[i] = obj.IsBrandObject(); //print (tmpTexts[i]); ++i; } fabToAdd.m_ctxPanelConfig = m_ctxPanelID_1; fabToAdd.m_ctxPanelBrand = m_ctxPanelID_2; fabToAdd.setImgContent(tmpTexs,tmpTexts, tmpCustomizables, tmpBrands); } Root.addSubItem(typToAdd); } if (catLvl1.GetObjectList ().Count > 0) { GUIUpperList fabToAdd = new GUIUpperList(0,x, catLvl1.GetDefaultText (), "sousMenuOn", "sousMenuOff", this); x++; Texture2D[] tmpTexs = new Texture2D[catLvl1.GetObjectList ().Count]; int i = 0; foreach(OSLibObject obj in catLvl1.GetObjectList ()) { // load texture Texture2D tmp = obj.GetThumbnail (); if(tmp == null) tmp = Resources.Load ("thumbnails/noThumbs",typeof(Texture2D)) as Texture2D; tmp.name = obj.GetText(PlayerPrefs.GetString("language"));// obj.GetDefaultText (); tmpTexs[i] = (Texture2D)tmp; ++i; } fabToAdd.setImgContent(tmpTexs); Root.addSubItem(fabToAdd); } } //Root.addSubItem(originalsObj); //print (x); if(usefullData._edition != usefullData.OSedition.Lite) { //Menu objets present dans la scene (sauf en édition lite) sceneObjs = new GUIItemV2(0,++x,TextManager.GetText("GUIMenuLeft.Select"),"menuSceneOn","menuSceneOff",this); Root.addSubItem(sceneObjs); } sceneObjs.SetEnableUI(GameObject.Find("MainNode").GetComponent<ObjBehavGlobal>().getNumberObjects() > 0); ResetMenu(); }
public Runner(string[] args, string filename) { if (args.Length > 0) { string path = args[0]; StreamReader sr = new StreamReader(path, Encoding.Default); String line; string content = ""; while ((line = sr.ReadLine()) != null) { content += line.ToString() + "\n"; } const bool isLoadLib = true; const bool useArg = true; // try { Lua L = new Lua(); if (isLoadLib) { BaseLib.open(L); PackageLib.open(L); MathLib.open(L); OSLib.open(L); StringLib.open(L); TableLib.open(L); } if (useArg) { //FIXME: index may be minus (for example, arg[-1], before script file name) //@see http://www.ttlsa.com/lua/lua-install-and-lua-variable-ttlsa/ int narg = args.Length; LuaTable tbl = L.createTable(narg, narg); for (int i = 0; i < narg; i++) { L.rawSetI(tbl, i, args[i]); } L.setGlobal("arg", tbl); } int status = L.doString(content); if (status != 0) { object errObj = L.value(1); object tostring = L.getGlobal("tostring"); L.push(tostring); L.push(errObj); L.call(1, 1); string errObjStr = L.toString(L.value(-1)); throw new Exception("Error compiling : " + L.value(1)); } else { object result = L.value(1); object tostring_ = L.getGlobal("tostring"); L.push(tostring_); L.push(result); L.call(1, 1); string resultStr = L.toString(L.value(-1)); Console.WriteLine("Result >>> " + resultStr); } } // catch (Exception e) // { // Console.WriteLine(e); // } } else { Console.WriteLine("usage: {0} <filename>", filename); } }