private void clickSelf(HeroModelShow model) { if (_3DModel == null) { return; } int[] actionArray = new int[] { 301, 302, 401, 402, 403, 410, 701 }; int action = actionArray[Random.Range(0, actionArray.Length)]; _3DModel.playAnimationsAndReset(new int[] { action }); }
public void SetModel(string shaping, HeroModelShow.CreateModelCallBack callBack, Vector3 camera_pos, Quaternion camera_rotation, bool need_taizi = false, float outLine = 0, bool playAnimation = true) { cameraPos = camera_pos; cameraRotation = camera_rotation; bNeedTaiZi = need_taizi; Init(); _callBack = callBack; if (_heroModel == null) { //创建模型管理器 _heroModel = HeroModelBox.AddComponent <HeroModelShow>(); _heroModel.ClickCallback = onClickModel; _heroModel.dragCallBack = onDragModel; _heroModel._fScale = 0.92f; _heroModel.needAutoRenderQueue = false; } _heroModel.SetRole(shaping, callBack, outLine, playAnimation); }
public void Destroy3DModel() { Init(); if (_heroModel != null) { _heroModel.Destroy3DModel(); _heroModel = null; } // if (mat != null && mat.mainTexture != null) // { // Destroy(mat.mainTexture); // mat.mainTexture = null; // } // if (mat != null) // { // Destroy(mat); // mat = null; // } if (mTex != null) { Destroy(mTex); mTex = null; } }
void Init() { if (bInited) { return; } bInited = true; Vector2 screen; if (Screen.width > Screen.height) { screen = new Vector2(Screen.width, Screen.height); } else { screen = new Vector2(Screen.height, Screen.width); } //创建renderTexture给镜头用 uiTexture = gameObject.GetComponent <UITexture>(); mTex = new RenderTexture((int)screen.x, (int)screen.y, 16);//16或24 //mTex = RenderTexture.GetTemporary(Screen.width, Screen.height, 0, RenderTextureFormat.ARGB32); mTex.name = transform.name + GetInstanceID(); mTex.anisoLevel = AntiAliasing; Utils.LogSys.Log("ModelToUITexture: RenderTexure format:" + mTex.format.ToString()); //创建材质球给uiTexture用。 Shader shader = Shader.Find("Unlit/Transparent Colored");//Shader.Find("Custom/FuckOutline");// mat = new Material(shader); uiTexture.material = mat; //创建放模型和镜头的父结点 HeroModelBox = new GameObject("HeroModelBox"); HeroModelBox.transform.parent = gameObject.transform; HeroModelBox.transform.localPosition = new Vector3((float)nCount * 100000f, 0f, 0f); if (nCount > 100) { nCount = 1; } else { nCount++; } //创建镜头 pCamera = new GameObject("ModelCamera"); Camera mCamera = pCamera.AddComponent <Camera>(); mCamera.clearFlags = CameraClearFlags.SolidColor;// CameraClearFlags.Depth;// mCamera.backgroundColor = new Color(0f, 0f, 0f, 0f); mCamera.cullingMask = (1 << LayerMask.NameToLayer("UI")); mCamera.targetTexture = mTex; pCamera.transform.parent = HeroModelBox.transform; pCamera.transform.localPosition = cameraPos; pCamera.transform.localRotation = cameraRotation; //cameraAjustor = pCamera.AddComponent<CameraAjustor>(); float adjust_width = (float)uiTexture.height * screen.x / screen.y; uiTexture.width = (int)adjust_width; //创建底座 TaiZi = new GameObject();// (GameObject)Instantiate(taizi); TaiZi.transform.name = "TaiZi"; TaiZi.transform.parent = HeroModelBox.transform; TaiZi.transform.localPosition = Vector3.zero; //创建模型管理器 _heroModel = HeroModelBox.AddComponent <HeroModelShow>(); _heroModel.ClickCallback = onClickModel; _heroModel.dragCallBack = onDragModel; _heroModel._fScale = 0.92f; _heroModel.needAutoRenderQueue = false; }
private void onClickModel(HeroModelShow heroModelShow) { Init(); _heroModel.playAnimationsAndReset(new int[] { 701 }); }