// Use this for initialization public void Draw(Vector2 panOffset) { if (!noCon) { noCon = LoadResources.GetTexture("DotCircle", knobeColor); } if (!hasCon) { hasCon = LoadResources.GetTexture("Dot", knobeColor); } if (connectionType == ConnectionType.Receive) { Point = new Rect((symbole.NodeSize.position.x - 8) + 2, symbole.NodeSize.y + 19, 10, 10); } if (connectionType == ConnectionType.Call) { Point = new Rect(((symbole.NodeSize.position.x - 8) + (symbole.NodeSize.width + 16)) - 13, symbole.NodeSize.y + 19, 10, 10); } Point.position += panOffset; if (connections != null && connections.Count > 0) { tex = hasCon; } else { tex = noCon; } GUI.DrawTexture(Point, tex); }
public void LoadResources_LoadActivityCache_Success() { //------------------Arrange--------------- const string resourceDirectory = "Resources - ServerTests"; var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); var mockAssemblyLoader = new Mock <IAssemblyLoader>(); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockResourceCatalog.Setup(o => o.CleanUpOldVersionControlStructure()).Verifiable(); mockResourceCatalog.Setup(o => o.LoadServerActivityCache()).Verifiable(); mockWriter.Setup(o => o.Write("Loading resource activity cache... ")).Verifiable(); mockWriter.Setup(o => o.Write("Preloading assemblies... ")).Verifiable(); mockAssemblyLoader.Setup(o => o.AssemblyNames(It.IsAny <Assembly>())).Returns(new AssemblyName[] { new AssemblyName() { Name = "testAssemblyName" } }); //------------------Act------------------- var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.LoadActivityCache(mockAssemblyLoader.Object); //------------------Assert---------------- mockWriter.Verify(o => o.WriteLine("done."), Times.Exactly(2)); mockWriter.Verify(); }
void Start() { int i; List <string> patternsString; gameController = GetComponent <GameController>(); patternsString = LoadResources.LoadTxtAsListString("PatternLore"); manoeuvresLore = new List <Manoeuvre> (); for (i = 0; i < patternsString.Count; ++i) { manoeuvresLore.Add(Manoeuvre.Create(patternsString[i])); } patternsString = LoadResources.LoadTxtAsListString("PatternFoe"); manoeuvresEnemie = new List <Manoeuvre> (); for (i = 0; i < patternsString.Count; ++i) { manoeuvresEnemie.Add(Manoeuvre.Create(patternsString[i])); } patternsString = LoadResources.LoadTxtAsListString("PatternSpecialForce"); manoeuvresSpecialForce = new List <Manoeuvre> (); for (i = 0; i < patternsString.Count; ++i) { manoeuvresSpecialForce.Add(Manoeuvre.Create(patternsString[i])); } }
private void Start() { LoadResources resources = new LoadResources(); resources.Initialize(); //アクターの作成とメンバーの追加 ActorDataModel actorData = ActorDataModel.Instance; MemberDataModel memberData = MemberDataModel.Instance; memberData.Add(ActorLogic.Create("Mandrake", 3)); memberData.Add(ActorLogic.Create("Slime", 3)); memberData.Add(ActorLogic.Create("MechanicSoldier", 3)); memberData.Add(ActorLogic.Create("Kyubi", 3)); //エネミーの作成 EnemyDataModel enemyData = EnemyDataModel.Instance; enemyData.Initialize(); enemyData.Add(EnemyLogic.Create("Goblin", 3)); enemyData.Add(EnemyLogic.Create("GreenDragon", 3)); enemyData.Add(EnemyLogic.Create("Goblin", 4)); //アイテム InventoryDataModel.GetInstance().StartUp(); var manager = gameObject.GetComponent <BattleManager>(); manager.Initialize(); }
public static void BuildPathFileEx() { m_instance = new LoadResources(); m_instance.m_resourcePath = Application.dataPath + "/Resources/"; m_instance.GetFileInfo(new DirectoryInfo(m_instance.m_resourcePath)); m_instance.BuildPathFile(); }
public static void LoadText(string assetName, Action <string> callBack) { if (string.IsNullOrEmpty(assetName) || null == callBack) { return; } LoadResources.LoadText(assetName, callBack); }
public static GameObject GetObject(string path) { ResourceItem item = LoadResources.LoadCore(path, EResType.None); if (item != null) { return(Object.Instantiate(item.MainAsset) as GameObject); } return(null); }
/// <summary> /// 加载UI的prefab并实例化,未完成依赖加载部分,但可以先用 /// </summary> /// <param name="path"></param> /// <param name="callBack"></param> /// <param name="clearAfterLoaded"></param> public static void LoadUI(string path, Action <GameObject> callBack, bool clearAfterLoaded = true) { LoadResources.LoadCore(path, item => { //LoggerHelper.Error("loadui, path: " + path + ", mainasset: " + item.MainAsset); var go = Object.Instantiate(item.MainAsset) as GameObject; go.name = item.MainAsset.name; callBack(go); }, EResType.UI, false, clearAfterLoaded); }
/// <summary> /// 直接从缓存中读取资源引用,不实例化,如果没有预加载,则返回空对象并报错 /// </summary> /// <param name="path"></param> /// <returns></returns> public static RenderTexture LoadRenderTexture(string path) { var item = LoadResources.LoadCore(path, EResType.RenderTexture); if (item != null) { return(item.MainAsset as RenderTexture); } Debug.LogError("【UI】缓存中不存在该资源:\n" + "path:" + path); return(null); }
/// <summary> /// 直接从缓存中读取资源引用,不实例化,如果没有预加载,则返回空对象并报错 /// </summary> /// <param name="path"></param> /// <returns></returns> public static GameObject LoadUIRef(string path) { var item = LoadResources.LoadCore(path, EResType.UI); if (item != null) { return(item.MainAsset as GameObject); } Debug.LogError("【UI】缓存中不存在该资源:\n" + "path:" + path); return(null); }
//-------------------------------------------------------------------------------------------- void Awake() { if (LR != null) { GameObject.Destroy(LR); } else { LR = this; } DontDestroyOnLoad(this); }
/// <summary> /// 加载特效Prefab并实例化 /// </summary> /// <param name="path">相对于Resources路径下的资源路径</param> /// <param name="callBack">回调函数的参数为实例化后的GameObject对象</param> /// <param name="clearAfterLoaded">加载完成后清除自己的缓存</param> public static void LoadEffect(string path, Action <GameObject> callBack, bool clearAfterLoaded = false) { LoadResources.LoadCore(path, item => LoadResources.InstanceAsync(item.MainAsset, go => { //var arr = go.transform.GetComponentsInChildren<Renderer>(); //for (int i = 0; i < arr.Length; i++) //{ // if (arr[i].sharedMaterial != null) // arr[i].material.shader = Shader.Find(arr[i].sharedMaterial.shader.name); //} callBack(go); }), EResType.Effect, false, clearAfterLoaded); }
/// <summary> /// 直接从缓存中读取并实例化,如果没有预加载,则返回空对象并报错 /// </summary> /// <param name="path"></param> /// <returns></returns> public static GameObject LoadUI(string path) { var item = LoadResources.LoadCore(path, EResType.UI); if (item != null) { var go = Object.Instantiate(item.MainAsset) as GameObject; go.name = item.MainAsset.name; return(go); } Debug.LogError("【UI】缓存中不存在该资源:\n" + "path:" + path); return(null); }
//临时使用,后面会改为使用具体的接口 public static void GetGameObject(string path, Action <GameObject> callBack, bool clearAfterLoaded = false) { Action <Object> cb = (obj) => { if (obj == null) { Debug.LogError("get no obj, path: " + path); return; } var clone = Object.Instantiate(obj) as GameObject; clone.name = obj.name; callBack(clone); }; LoadResources.LoadCore(path, item => cb(item.MainAsset), EResType.None, false, clearAfterLoaded); }
public override void Start() { base.Start(); Caching.CleanCache(); string sysInfo = getSystemInfo(); Debug.Log("SystemInfo > " + sysInfo); #if Debug attachFps(); #endif //SceneManager.Instance.PushScene(SceneManager.Instance.CreateScene(SceneNode.Main)); LoadResources.Init(loadResourcesCallback); }
public void LoadResources_CheckExampleResources_DirectoryExists_False() { //------------------Arrange--------------- var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(false); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); //------------------Act------------------- var loadResources = new LoadResources("Resources - ServerTests", mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.CheckExampleResources(); //------------------Assert---------------- mockResourceCatalog.Verify(o => o.LoadExamplesViaBuilder(It.IsAny <string>()), Times.Never); }
public void ResourceCatalog_LoadExamplesViaBuilder_ResourcesDirectoryDoesNotExist() { //------------------Arrange--------------- var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(Path.Combine(EnvironmentVariables.ApplicationPath, "Resources - Release"))).Returns(true); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockResourceCatalog.Setup(o => o.LoadExamplesViaBuilder(Path.Combine(EnvironmentVariables.ApplicationPath, "Resources - Release"))).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources("Resources - Release", new Mock <IWriter>().Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.CheckExampleResources(); //------------------Assert---------------- mockResourceCatalog.Verify(); }
public static TipWindowUI Create(Transform parent, TipWindowType type = TipWindowType.oneButton) { var window = Instantiate(LoadResources .Load <TipWindowUI>(UIName.prefab_tipWindow), parent); if (type == TipWindowType.oneButton) { window.twoButton1.gameObject.SetActive(false); window.twoButton2.gameObject.SetActive(false); } else if (type == TipWindowType.twoButton) { window.oneButton1.gameObject.SetActive(false); } return(window); }
public void LoadResources_ValidateResourceFolder_Success() { //------------------Arrange--------------- const string resourceDirectory = "Resources - ServerTests"; var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(false); mockDirectory.Setup(o => o.CreateDirectory(It.IsAny <string>())).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.ValidateResourceFolder(); //------------------Assert---------------- mockDirectory.Verify(); }
public static GameObject[] GenerateTerrainOld(int width = 100, int height = 100, float scale = 1, int seed = 0, float divide = 100) { List <GameObject> gameObjects = new List <GameObject>(); for (int x = 0; x < width; x++) { for (int z = 0; z < height; z++) { string type = "none"; float y = 0; Modell cube = LoadResources.ReadModell(Directory.GetCurrentDirectory() + @"\Mods\Default\Modells\cube.obj"); GameObject currentBlock = new GameObject(x + "." + z + "." + type, new Vector3(x, y, z), Vector3.Zero, new Vector3(1, 1, 1), cube); //Console.WriteLine(new Vector3(x, y, z)); gameObjects.Add(currentBlock); } } return(gameObjects.ToArray()); }
public static Material LoadMaterial(string name) { Material retMat = LoadResources.LoadCore(name, EResType.Material).MainAsset as Material; if (LoadResources.m_loadMode == ELoadMode.Resources) { retMat = Object.Instantiate(retMat) as Material; // 避免本地文件被修改 } //if (Application.isEditor) //{ // if (retMat.shader != null) // { // retMat.shader = Shader.Find(retMat.shader.name); // //LoggerHelper.Error("-----------------" + mat.shader.name); // } //} return(retMat); }
public void LoadResources_MigrateBinResources_DirectoryExits_True() { //------------------Arrange--------------- const string resourceDirectory = "Resources - ServerTests"; var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(true); //------------------Act------------------- var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.MigrateBinResources(); //------------------Assert---------------- mockDirectory.Verify(o => o.Copy(It.IsAny <string>(), It.IsAny <string>(), true), Times.Never); mockDirectory.Verify(o => o.CleanUp(It.IsAny <string>()), Times.Never); }
public void LoadResources_MethodsToBeDepricated_Success() { //------------------Arrange--------------- const string resourceDirectory = "Resources - ServerTests"; var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockResourceCatalog.Setup(o => o.CleanUpOldVersionControlStructure()).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.MethodsToBeDepricated(); //------------------Assert---------------- mockResourceCatalog.Verify(); }
public void LoadResources_CheckExampleResources_DirectoryExists_True() { //------------------Arrange--------------- var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(It.IsAny <string>())).Returns(true); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockResourceCatalog.Setup(o => o.LoadExamplesViaBuilder(It.IsAny <string>())) .Callback <string>((path) => Assert.IsTrue(path.EndsWith(@"\Resources - ServerTests"))) .Returns(() => null).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources("Resources - ServerTests", mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.CheckExampleResources(); //------------------Assert---------------- mockResourceCatalog.Verify(); }
/// <summary> /// 直接从缓存中读取,如果没有预加载,则返回空对象并报错 /// </summary> /// <param name="atlas"></param> /// <param name="sprite"></param> /// <returns></returns> public static Sprite LoadSprite(string atlas, string sprite) { var path = atlas.ToLower(); var item = LoadResources.GetResourceItem(path); if (item != null) { item.SetType(EResType.Atlas); //if (LoadResources.m_loadMode == ELoadMode.Resources) //{ // if (item.Assets == null) // item.SetAssets((item.MainAsset as GameObject).GetComponent<SpritesHolder>().Sprites); // return item.Load(sprite, typeof(Sprite)) as Sprite; //} //else if (LoadResources.m_loadMode == ELoadMode.AssetBundle) return(item.Load(sprite, typeof(Sprite)) as Sprite); } Debug.LogError("【Atlas】缓存中不存在该资源:\n" + "atlas:" + path + " sprite:" + sprite); return(null); }
private void OnEnable() { GUIScaleUtility.CheckInit(); _gridTex = LoadResources.GetTexture("Grid"); bool loaded = false; if (EditorPrefs.HasKey("VCSU Graph Last ID")) { loaded = Load(EditorPrefs.GetInt("VCSU Graph Last ID")); EditorPrefs.DeleteKey("VCSU Graph Last ID"); } if (!loaded) { if (EditorPrefs.HasKey("VCSU Graph Last")) { Load(EditorPrefs.GetString("VCSU Graph Last")); EditorPrefs.DeleteKey("VCSU Graph Last"); } } }
private void Start() { LoadResources resources = new LoadResources(); resources.Initialize(); //アクターの作成とメンバーの追加 ActorDataModel actorData = ActorDataModel.Instance; MemberDataModel memberData = MemberDataModel.Instance; memberData.Add(ActorLogic.Create("Mandrake", "植物", 1)); memberData.Add(ActorLogic.Create("Slime", "すらりん", 1)); memberData.Add(ActorLogic.Create("MechanicSoldier", "ろぼ兵士", 100)); //memberData.Add(ActorLogic.Create("Kyubi", 1)); //アイテム InventoryDataModel.GetInstance().StartUp(); //ダンジョン DungeonPresenter.GetInstance().Initialize("FirstForest"); }
public void LoadResources_MigrateOldTests_DirecotoryExists_False() { //------------------Arrange--------------- const string resourceDirectory = "Resources - ServerTests"; var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockDirectory.Setup(o => o.Exists(EnvironmentVariables.TestPath)).Returns(false); mockDirectory.Setup(o => o.Exists(Path.Combine(EnvironmentVariables.ApplicationPath, "Tests"))).Returns(true); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); //------------------Act------------------- var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.MigrateOldTests(); //------------------Assert---------------- mockDirectory.Verify(o => o.Copy(It.IsAny <string>(), It.IsAny <string>(), true), Times.Once); mockDirectory.Verify(o => o.CleanUp(It.IsAny <string>()), Times.Once); }
public void LoadResources_LoadServerWorkspace_Success() { //------------------Arrange--------------- const string resourceDirectory = "Resources - ServerTests"; var mockWriter = new Mock <IWriter>(); var mockDirectory = new Mock <IDirectory>(); var mockResourceCatalog = new Mock <IResourceCatalog>(); var mockResourceCatalogFactory = new Mock <IResourceCatalogFactory>(); mockResourceCatalogFactory.Setup(o => o.New()).Returns(mockResourceCatalog.Object); mockWriter.Setup(o => o.Write("Loading server workspace... ")).Verifiable(); mockWriter.Setup(o => o.WriteLine("done.")).Verifiable(); //------------------Act------------------- var loadResources = new LoadResources(resourceDirectory, mockWriter.Object, mockDirectory.Object, mockResourceCatalogFactory.Object); loadResources.LoadServerWorkspace(); //------------------Assert---------------- mockWriter.Verify(); }
void Awake() { DontDestroyOnLoad(this); m_instance = this; AssetCacheMgr.AssetMgr = this; m_instance.m_filesDic.Clear(); //m_instance.LoadPathFile(); if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WindowsPlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.LinuxPlayer) { m_instance.LoadPathFile(); } else { m_instance.m_resourcePath = Application.dataPath + "/Resources/"; m_instance.GetFileInfo(new DirectoryInfo(m_instance.m_resourcePath)); m_instance.BuildPathFile(); } }