public override void Recycle() { if (currentObj != null) { FreeUrl url = FreeResourceUtil.Convert(_particleName); currentObj.SetActive(false); FreePrefabLoader.ReturnGameObject(currentObj, new AssetInfo(url.BuddleName, url.AssetName)); } }
public void load() { var mat = new Material(Shader.Find("ProBuilder/Diffuse Vertex Color")); if (depthMode == 0 || depthMode == 1) { mat.SetInt("_ZTest", (int)CompareFunction.LessEqual); } else { mat.SetInt("_ZTest", (int)CompareFunction.Always); } if (depthMode == 0 || depthMode == 2) { mat.SetInt("_ZWrite", 1); } else { mat.SetInt("_ZWrite", 0); } material = mat; if (!string.IsNullOrEmpty(_modelName)) { FreeUrl url = FreeResourceUtil.Convert(_modelName); FreeGlobalVars.Loader.LoadAsync(url.BuddleName, url.AssetName, (sprite) => { var meshObj = (GameObject)sprite; meshObj.transform.parent = gameObject.transform; meshObj.transform.localPosition = Vector3.zero; meshObj.transform.localScale = new Vector3(1, 1, 1); meshObj.transform.localEulerAngles = new Vector3(0, 0, 0); var meshRender = meshObj.GetComponentInChildren <MeshRenderer>(); meshRender.shadowCastingMode = ShadowCastingMode.Off; this.meshRender = meshRender; this.meshRender.material = mat; url = FreeResourceUtil.Convert(_textureName); FreeGlobalVars.Loader.LoadAsync(url.BuddleName, url.AssetName, (modelTexture) => { Texture2D texture = (Texture2D)modelTexture; this.meshRender.material.mainTexture = texture; }); }); } else { var go = gameObject; var spriteObj = new GameObject("Sprite"); spriteObj.transform.parent = go.transform; spriteObj.transform.localPosition = Vector3.zero; spriteObj.transform.localScale = new Vector3(1, -1, 1); spriteObj.transform.localEulerAngles = new Vector3(90, 270, 0); var spriteRender = spriteObj.AddComponent <SpriteRenderer>(); meshRender = spriteRender; FreeUrl url = FreeResourceUtil.Convert(_textureName); FreeGlobalVars.Loader.LoadAsync(url.BuddleName, url.AssetName, (sprite) => { Texture2D texture = (Texture2D)sprite; var width = texture.width; var height = texture.height; (meshRender as SpriteRenderer).sprite = Sprite.Create(texture, new Rect(0, 0, width, height), new Vector2(0.5f, 0.5f), 100f, 0, SpriteMeshType.FullRect); if (width > height) { var scale = meshRender.transform.localScale; scale.x = ((float)(height) / width); meshRender.transform.localScale = scale; } else { var scale = meshRender.transform.localScale; scale.y = -((float)(width) / height); meshRender.transform.localScale = scale; } }); } }