//**************************************************************************************************** // //**************************************************************************************************** public void Awake() { if (m_instance == null) { m_instance = this; } m_group = GetComponent <CanvasGroup>(); GameObject text = CORE.HIERARCHY.Find(gameObject, "HUDDLoadText"); GameObject bar = CORE.HIERARCHY.Find(gameObject, "HUDDLoadBar"); if (text != null) { m_text = text.GetComponent <UnityEngine.UI.Text>(); } if (bar != null) { m_bar = bar.GetComponent <UnityEngine.UI.RawImage>(); } if (m_bar != null) { m_barTransform = m_bar.GetComponent <RectTransform>(); } m_fade.Begin(FADE_TYPE.FADE_OUT, FADE_OUT_DURATION); }
//**************************************************************************************************** // //**************************************************************************************************** public void Awake() { if (m_instance == null) { m_instance = this; HTTPReq.defaultTimeoutIndicator = this; HTTPReq.delaySimulation = 0.0f; } m_group = GetComponent <CanvasGroup>(); GameObject text = CORE.HIERARCHY.Find(gameObject, "Text"); GameObject bar = CORE.HIERARCHY.Find(gameObject, "Bar"); if (text != null) { m_text = text.GetComponent <UnityEngine.UI.Text>(); } if (bar != null) { m_bar = bar.GetComponent <UnityEngine.UI.RawImage>(); } if (m_bar != null) { m_barTransform = m_bar.GetComponent <RectTransform>(); } m_fade.Begin(FADE_TYPE.FADE_OUT, FADE_OUT_DURATION); }
void SetupImages() { //MyPlayer1.GetComponent<CustomController>().m_Camera = MyPlayer1.gameObject.transform.GetChild(0).GetComponent<Camera>(); //MyPlayer2.GetComponent<CustomController>().m_Camera = MyPlayer2.gameObject.transform.GetChild(0).GetComponent<Camera>(); GameObject MyImage1Object = new GameObject (); MyImage1Object.AddComponent<RawImage> (); MyImage1 = MyImage1Object.GetComponent<RawImage>(); MyImage1.GetComponent<RawImage> ().texture = MyRenderTexture1; RectTransform MyRectTransform1 = MyImage1Object.GetComponent<RectTransform> (); MyRectTransform1.anchorMin = new Vector2 (0, 0); MyRectTransform1.anchorMax = new Vector2 (1, 1); MyRectTransform1.sizeDelta = new Vector2(0, 0); MyRectTransform1.localPosition = new Vector2 (0, 0); MyImage1Object.layer = MyUILayer; MyImage1Object.name = "MyImage1"; MyImage1Object.transform.SetParent (MyCanvas.transform, false); GameObject MyImage2Object = new GameObject (); MyImage2Object.AddComponent<RawImage> (); MyImage2 = MyImage2Object.GetComponent<RawImage>(); MyImage2.GetComponent<RawImage> ().texture = MyRenderTexture2; RectTransform MyRectTransform2 = MyImage2Object.GetComponent<RectTransform> (); MyRectTransform2.anchorMin = new Vector2 (0, 0); MyRectTransform2.anchorMax = new Vector2 (1, 1); MyImage2Object.transform.SetParent (MyCanvas.transform, false); MyImage2Object.name = "MyImage2"; MyImage2Object.layer = MyUILayer; MyImage1Object.SetActive (false); MyImage2Object.SetActive (false); SpawnedMainCamera = new GameObject (); SpawnedMainCamera.AddComponent<Camera> (); SpawnedMainCamera.tag = "MainCamera"; SpawnedMainCamera.SetActive (false); }
public void Initialize() { GameObject ob = GameObject.Find("COLLECT_PLACE"); if (ob != null) { RawImage rawimage = ob.transform.GetChild(0).GetComponent<RawImage>(); rawimage.gameObject.SetActive(true); Image = Instantiate<RawImage>(rawimage); Image.transform.parent = ob.gameObject.transform; Image.name += "-" + gameObject.name; Image.transform.localScale = new Vector3(1, 1, 1); RectTransform rect = Image.GetComponent<RectTransform>(); RectTransform rectorgi = rawimage.GetComponent<RectTransform>(); this.rect = rect; rect.offsetMin = new Vector2(rectorgi.offsetMin.x, rectorgi.offsetMin.y); rect.offsetMax = new Vector2(rectorgi.offsetMax.x, rectorgi.offsetMax.y); Image.texture = GetComponent<Building>().ResourceProduction.getSprite().texture; rawimage.gameObject.SetActive(false); } else Debug.LogError("Cant Find TIMER_TEXT"); }
// set the texture in display, scaling it to fit the cell void SetTexture(Texture texture) { if (cellH < 0 || cellW < 0) { computeCellSize(); } //Debug.Log(cellW + " " + cellH); float h = texture.height, w = texture.width; int finalH, finalW; if ((h / cellH) < (w / cellW)) { finalW = cellW; finalH = Mathf.CeilToInt((h / w) * finalW); } else { finalH = cellH; finalW = Mathf.CeilToInt((w / h) * finalH); } rawImageComp.GetComponent <RectTransform>().sizeDelta = new Vector2(finalW, finalH); StartCoroutine(FadeInTexture(texture)); }
private UGUINode DrawRawImage(ImgNode image, UGUINode parent) { UGUINode node = PSDImportUtility.InstantiateItem(GroupType.RawIMAGE, image.sprite.name, parent); UnityEngine.UI.RawImage pic = node.InitComponent <UnityEngine.UI.RawImage>(); PSDImportUtility.SetPictureOrLoadColor(image, pic); PSDImportUtility.SetRectTransform(image, pic.GetComponent <RectTransform>()); return(node); }
private UINode DrawRawImage(Image image, UINode parent) { UINode node = PSDImportUtility.InstantiateItem(PSDImporterConst.PREFAB_PATH_RawIMAGE, image.name, parent); UnityEngine.UI.RawImage pic = node.GetComponent <UnityEngine.UI.RawImage>(); PSDImportUtility.SetPictureOrLoadColor(image, pic); PSDImportUtility.SetRectTransform(image, pic.GetComponent <RectTransform>()); return(node); }
void Update() { KinectManager manager = KinectManager.Instance; if (manager && manager.IsInitialized()) { if (backgroundImage && (backgroundImage.texture == null)) { backgroundImage.texture = !useTexture2D?manager.GetUsersLblTex() : manager.GetUsersLblTex2D(); backgroundImage.color = Color.white; KinectInterop.SensorData sensorData = manager.GetSensorData(); if (sensorData != null && sensorData.sensorInterface != null && backgroundCamera != null) { // get depth image size int depthImageWidth = sensorData.depthImageWidth; int depthImageHeight = sensorData.depthImageHeight; // calculate insets Rect cameraRect = backgroundCamera.pixelRect; float rectWidth = cameraRect.width; float rectHeight = cameraRect.height; if (rectWidth > rectHeight) { rectWidth = rectHeight * depthImageWidth / depthImageHeight; } else { rectHeight = rectWidth * depthImageHeight / depthImageWidth; } float deltaWidth = cameraRect.width - rectWidth; float deltaHeight = cameraRect.height - rectHeight; // float leftX = deltaWidth / 2; // float rightX = -deltaWidth; // float bottomY = -deltaHeight / 2; // float topY = deltaHeight; // // backgroundImage.pixelInset = new Rect(leftX, bottomY, rightX, topY); RectTransform rectImage = backgroundImage.GetComponent <RectTransform>(); if (rectImage) { rectImage.sizeDelta = new Vector2(-deltaWidth, -deltaHeight); } } } } }
private void cloneBlockId (RawImage rawImage) { DrawingCell cell = rawImage.GetComponent<DrawingCell> (); if (cell.blockIdTop > 0) { Global.selectedBlockId = cell.blockIdTop; Global.showNotyMessage ("Block copied."); ToolsController.deactivateCloneBucket (); }else if(cell.blockIdBottom > 0){ Global.selectedBlockId = cell.blockIdBottom; Global.showNotyMessage ("Block copied."); ToolsController.deactivateCloneBucket (); }else{ // Ignore. Do nothing. } }
// If the clicked cell is empty then place the selected block in it. private void placeSelectedBlock (RawImage rawImage){ DrawingCell cell = rawImage.GetComponent<DrawingCell> (); cell.placeBlockOnCell (rawImage); }
private void clearCellBlock (RawImage rawImage) { DrawingCell cell = rawImage.GetComponent<DrawingCell> (); cell.removeBlockOnCell (rawImage); }
IEnumerator Load()//图片读取携程 { WWW www = new WWW(path); yield return(www); texture = www.texture; image.GetComponent <RectTransform>().sizeDelta = new Vector2(texture.width, texture.height); //image.GetComponent<Image>().material.SetTexture("_MainTex", texture); //Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f)); //image.sprite = sprite; image.GetComponent <RawImage>().texture = texture; Gamevars.textureisable = true; Gamevars.imagewidth = texture.width; Gamevars.imageheight = texture.height; resolution.text = Gamevars.imagewidth.ToString() + " x " + Gamevars.imageheight.ToString(); image.color = new Color32(255, 255, 255, 255); RenderTexture Disttexture = RenderTexture.GetTemporary(texture.width, texture.height, 0); Graphics.Blit(texture, Disttexture, material); RTpic.Insert(0, Disttexture); }