public void Init(string puzzleName, bool[] finished = null) { this.puzzleName = puzzleName; var prefab = PrefabLoader.Load(string.Format("{0}/{1}/{1}", Paths.Artworks, puzzleName)); var go = prefab.Instantiate <GameObject>(transform); InternalInit(go.GetComponent <PolyGraph>(), finished); }
public GameObject Load(string prefabName, string path = "") { if (pl == null) { Init(); } return(pl.Load(prefabName, path)); }
void SyncAdd() { int index = dropdown.value; var r = resourceInfo[index]; var handle = PrefabLoader.Load(r.path); r.gameObjects.Add(handle.Instantiate <GameObject>()); UpdateInstanceCount(); }
void LoadWireframe() { var prefab = PrefabLoader.Load(string.Format("{0}/{1}/{1}_{2}", Paths.Artworks, Data.puzzleName, Paths.Wireframe)); var go = prefab.Instantiate <GameObject>(Data.transform); go.transform.position = new Vector3(0f, 0f, Config.Instance.zorder.wireframe); go.name = prefab.Name; Data.wireframeObject = go.GetComponent <PuzzleWireframe>(); }
public static GameObject Create(PolyGraph graph, Bounds bounds, bool circularShape = false, bool grey = false) { var prefab = PrefabLoader.Load(Prefabs.Background); var go = prefab.Instantiate <GameObject>(); bounds = CalculateBounds(bounds); go.transform.localPosition = new Vector3(bounds.center.x, bounds.center.y, Config.Instance.zorder.background); var renderer = go.GetComponent <MeshRenderer>(); Material mat; if (Application.isPlaying) { mat = renderer.material; } else { mat = GameObject.Instantiate(renderer.sharedMaterial); renderer.sharedMaterial = mat; } if (null != graph.background) { float boundsAspect = bounds.size.x / bounds.size.y; float aspect = (float)graph.background.width / graph.background.height; if (aspect >= boundsAspect) { go.transform.localScale = new Vector3(aspect * bounds.size.y, bounds.size.y, 1f); } else { go.transform.localScale = new Vector3(bounds.size.x, bounds.size.x / aspect, 1f); } mat.EnableKeyword(ShaderFeatures._TEXTURE_BG); mat.SetTexture("_MainTex", graph.background); } else { go.transform.localScale = new Vector3(bounds.size.x, bounds.size.y, 1f); if (circularShape) { mat.EnableKeyword(ShaderFeatures._USE_CIRCLE_ALPHA); } mat.SetColor("_Color", BackgroundColor(graph)); mat.SetVector("_Bounds", new Vector4(bounds.extents.x, bounds.extents.y)); } if (grey) { mat.EnableKeyword(ShaderFeatures._GREYSCALE); } return(go); }
public void Load() { if (showAllCtrl.selectedIndex == 1) { return; } string path = Paths.SnapshotSave(graphName); if (File.Exists(path)) { byte[] bytes = File.ReadAllBytes(path); if (null == tex2d) { tex2d = new Texture2D(2, 2); } tex2d.LoadImage(bytes); loader.texture = new NTexture(tex2d); } else { if (null == snapshotPrefab) { snapshotPrefab = PrefabLoader.Load(string.Format( "{0}/{1}/{1}_{2}", Paths.Artworks, graphName, Paths.Snapshot)); if (null != snapshotPrefab) { snapshotPrefab.KeepReference(); } } if (null != snapshotPrefab) { var prefabObject = (GameObject)snapshotPrefab.Object; var holder = prefabObject.GetComponent <PuzzleSnapshotHolder>(); if (null != holder && null != holder.texture) { loader.texture = new NTexture(holder.texture); } else { GameLog.LogError("PuzzleSnapshotHolder missing or texture missing: " + graphName); } } } }
void Awake() { var size = Config.Instance.snapshotSize; renderTexture = new RenderTexture(size.x, size.y, 0, RenderTextureFormat.ARGB32); renderTexture.antiAliasing = 8; renderTexture.name = "PuzzleSnapshotRT"; renderTexture.Create(); var camPrefab = PrefabLoader.Load(Prefabs.PuzzleCamera); var camGo = camPrefab.Instantiate <GameObject>(transform, true); ssCamera = camGo.GetComponent <Camera>(); ssCamera.cullingMask = (1 << Layers.Snapshot); ssCamera.targetTexture = renderTexture; ssCamera.backgroundColor = Color.white; camGo.SetActive(false); }
void LoadPuzzleObject() { var prefab = PrefabLoader.Load(string.Format("{0}/{1}/{1}", Paths.Artworks, Data.puzzleName)); var go = prefab.Instantiate <GameObject>(Data.transform); go.name = Data.puzzleName; for (int i = 0; i < go.transform.childCount; ++i) { var child = go.transform.GetChild(i); Vector3 pos = child.localPosition; var info = new Puzzle.DebrisInfo() { index = i, position = pos }; Data.debrisMap.Add(child.gameObject, info); child.localPosition = ArrangeDepth(i, pos); } Data.puzzleObject = go.GetComponent <PolyGraph>(); }
public GameObject Get() { if (_currentState == State.Completed) { return(_prefab); } if (_currentState == State.Loading) { throw new InvalidOperationException(); } _currentState = State.Loading; _loader = PrefabLoader.Create(); _prefab = _loader.Load(_path); _currentState = State.Completed; return(_prefab); }
async Task TestLoad() { List <GameObject> instances = new List <GameObject>(); var prefabResource = PrefabLoader.Load("Prefabs/CompleteLevelArt"); instances.Add(prefabResource.Instantiate <GameObject>()); instances.Add(prefabResource.Instantiate <GameObject>()); AssetSystem.Instance.GarbageCollect(); ResLog.Log("Instantiate Finish"); await Awaiters.Seconds(5f); instances.ForEach(go => GameObject.Destroy(go)); instances.Clear(); ResLog.Log("Destroy Instances"); await Awaiters.Seconds(3f); AssetSystem.Instance.GarbageCollect(); ResLog.Log("Garbage Collect"); await Awaiters.Seconds(5f); ResLog.Log("TestLoad Finish"); }