/// <summary> /// Sets the components. /// </summary> /// <param name='_sprite'> /// _sprite. /// </param> /// <param name='_stretch'> /// _stretch. /// </param> public void SetComponents(UITexture _texture, UIStretch _stretch) { texture = _texture; transform = texture.transform; stretch = _stretch; }
public void setNextHouseIcon(STowerID id) { if (isLock) { lockUpgrade(false); isLock = false; } string s = GameConfig.PathHouseIcon + id.Level; upgradeIcon.mainTexture = Resources.Load <Texture>(s); UITexture texture = upgradeIcon.GetComponent <UITexture>(); texture.keepAspectRatio = UIWidget.AspectRatioSource.Free; Vector2 localSize = new Vector2(texture.mainTexture.width, texture.mainTexture.height); texture.SetDimensions((int)localSize.x, (int)localSize.y); texture.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight; UIStretch uiStretch = upgradeIcon.GetComponent <UIStretch>(); //uiStretch.container = panelTowerBuild.gameObject; uiStretch.enabled = true; }
UIPanel CreateFullScreenCollider() { Transform parentTrans = transform; Transform panelTrans = new GameObject("PanelBlock").transform; panelTrans.parent = parentTrans; panelTrans.localPosition = Vector3.zero; panelTrans.localRotation = Quaternion.identity; panelTrans.localScale = Vector3.one; panelTrans.gameObject.layer = parentTrans.gameObject.layer; UIPanel uiPanel = panelTrans.gameObject.AddComponent <UIPanel>(); Transform trans = new GameObject("ModalCollider").transform; trans.parent = panelTrans; trans.localPosition = Vector3.zero; trans.localRotation = Quaternion.identity; trans.localScale = Vector3.one; trans.gameObject.layer = panelTrans.gameObject.layer; UIWidget widget = trans.gameObject.AddComponent <UIWidget>(); widget.autoResizeBoxCollider = true; BoxCollider2D bc = trans.gameObject.AddComponent <BoxCollider2D>(); bc.isTrigger = true; bc.center = Vector3.zero; bc.size = new Vector3(1, 1); UIStretch stretch = trans.gameObject.AddComponent <UIStretch>(); stretch.uiCamera = UICamera.FindCameraForLayer(LayerMask.NameToLayer("UI")).camera; stretch.style = UIStretch.Style.Both; return(uiPanel); }
public static void EnsureScreenFillingComponent(GameObject gameObject, int depth, float uxCameraScale, bool bScreenSizeOverride = false, int w = 0, int h = 0) { UIStretch component = gameObject.GetComponent <UIStretch>(); if (component != null) { UnityEngine.Object.Destroy(component); } UIWidget uIWidget = gameObject.GetComponent <UIWidget>(); if (uIWidget == null) { uIWidget = gameObject.AddComponent <UIWidget>(); } uIWidget.depth = depth; uIWidget.autoResizeBoxCollider = true; if (bScreenSizeOverride) { uIWidget.width = (int)((float)w / uxCameraScale) + 5; uIWidget.height = (int)((float)h / uxCameraScale) + 5; return; } uIWidget.width = (int)((float)Screen.width / uxCameraScale) + 2; uIWidget.height = (int)((float)Screen.height / uxCameraScale) + 2; }
public void updateListItem(GameObject destroyObject) { if (destroyObject.GetComponent <UIAnchor>().side == UIAnchor.Side.TopLeft) // item dau { GameObject deleteItem = tempListDragonItem.transform.GetChild(0).gameObject; UIAnchor uiAnchorDeleteItem = deleteItem.GetComponent <UIAnchor>(); UIStretch uiStretchDeleteItem = deleteItem.GetComponent <UIStretch>(); if (tempListDragonItem.transform.childCount > 1) { GameObject secondItem = tempListDragonItem.transform.GetChild(1).gameObject; UIAnchor uiAnchorSecondItem = secondItem.GetComponent <UIAnchor>(); UIStretch uiStretchSecondItem = secondItem.GetComponent <UIStretch>(); uiAnchorSecondItem.container = uiAnchorDeleteItem.container; uiAnchorSecondItem.side = uiAnchorDeleteItem.side; uiAnchorSecondItem.relativeOffset = uiAnchorDeleteItem.relativeOffset; uiStretchSecondItem.container = uiStretchDeleteItem.container; secondItem.transform.localPosition = deleteItem.transform.localPosition; secondItem.GetComponent <UIWidget>().pivot = UIWidget.Pivot.TopLeft; } AutoDestroy.Destroy(destroyObject); } else { } }
void OnMapBackgroundScrolled(GameObject go, float delta) { UIStretch theStretch = background.GetComponent <UIStretch>(); if (delta > 0) { if (zoomLevel > -numZoomLevels && !isZooming) { zoomLevel--; isZooming = true; float orthoSize = Mathf.Pow(zoomFactor, zoomLevel); TweenOrthoSize tos = TweenOrthoSize.Begin(UICamera.currentCamera.gameObject, zoomSpeed, orthoSize); theStretch.relativeSize.x = orthoSize; theStretch.relativeSize.y = orthoSize; tos.callWhenFinished = "endZooming"; tos.eventReceiver = this.gameObject; } } else { if (zoomLevel < numZoomLevels && !isZooming) { zoomLevel++; isZooming = true; float orthoSize = Mathf.Pow(zoomFactor, zoomLevel); TweenOrthoSize tos = TweenOrthoSize.Begin(UICamera.currentCamera.gameObject, zoomSpeed, orthoSize); tos.callWhenFinished = "endZoomUpdateBackground"; tos.eventReceiver = this.gameObject; } } }
/// <summary> /// Sets the components. /// </summary> /// <param name='_sprite'> /// _sprite. /// </param> /// <param name='_stretch'> /// _stretch. /// </param> public void SetComponents(UISprite _sprite, UIStretch _stretch) { sprite = _sprite; transform = sprite.transform; stretch = _stretch; }
public void setValueInfo(STowerID ID, string strDescribe) { //Icon object[] value = PlayConfig.getBulletBuild(ID); SAnchor b = (SAnchor)value[1]; object[] bulletData = PlayConfig.getBulletShop(ID); goldIcon.mainTexture = Resources.Load <Texture>(GameConfig.PathBulletIcon + bulletData[0]); goldIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free; goldIcon.SetDimensions(goldIcon.mainTexture.width, goldIcon.mainTexture.height); goldIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight; UIAnchor anchor = goldIcon.GetComponent <UIAnchor>(); anchor.relativeOffset = b.Anchor; anchor.enabled = true; UIStretch stretch = goldIcon.GetComponent <UIStretch>(); stretch.relativeSize.y = b.Stretch; stretch.enabled = true; // //Label //string[] str = PlayConfig.getBulletType(s); goldAbility.text = strDescribe; goldEffect.gameObject.SetActive(false); }
void endZoomUpdateBackground() { isZooming = false; UIStretch theStretch = background.GetComponent <UIStretch>(); theStretch.relativeSize.x = UICamera.currentCamera.orthographicSize; theStretch.relativeSize.y = UICamera.currentCamera.orthographicSize; }
void setTargetTower(PlayManager playManager) { if (playManager.objectBuild.Tower) { playManager.objectBuild.PreTower = playManager.objectBuild.Tower; } playManager.objectBuild.Tower = rootTowerBuild; isChoosed = true; if (rootTowerBuild.GetComponent <TowerBuildController>().ID.Type != ETower.DRAGON) //is tower { playManager.selectedTowerBuild.GetComponent <UISprite>().color = Color.yellow; playManager.checkOK.GetComponent <UISprite>().color = Color.white; playManager.selectedTowerBuild.GetComponent <UIStretch>().relativeSize = new Vector2(1.1f, 1.0f); } else { playManager.selectedTowerBuild.GetComponent <UISprite>().color = Color.red; playManager.checkOK.GetComponent <UISprite>().color = Color.red; playManager.selectedTowerBuild.GetComponent <UIStretch>().relativeSize = new Vector2(1.4f, 1.2f); } //selected tower build playManager.selectedTowerBuild.transform.localPosition = rootTowerBuild.transform.localPosition; playManager.selectedTowerBuild.GetComponent <UIStretch>().container = rootTowerBuild; //check ok if (!playManager.checkOK.activeSelf) { playManager.checkOK.SetActive(true); } playManager.checkOK.transform.parent = playManager.panelTowerBuild.transform; playManager.checkOK.transform.position = rootTowerBuild.transform.position; UIStretch stretch = playManager.checkOK.GetComponent <UIStretch>(); stretch.container = PlayManager.Instance.panelTowerBuild; stretch.relativeSize.y = PlayConfig.AnchorTowerBuildCheckOK; // set range for tower when build tower (first) playManager.setRangeTower(range, playManager.objectBuild.Target); if (ItemManager.Instance.listItemState.Contains(EItemState.RANGE)) { playManager.rangeTowerBonus.transform.position = playManager.rangeTower.transform.position; float scale = (float)(range + (int)(range * ItemManager.Instance.BonusRange)) / 100f; playManager.rangeTowerBonus.transform.localScale = new Vector3(scale, scale, 0); playManager.rangeTowerBonus.SetActive(true); } if (!playManager.selectedTowerBuild.activeInHierarchy) { NGUITools.SetActive(playManager.selectedTowerBuild, true); } }
public virtual void Start() { anchor = this.GetComponent <UIAnchor>(); stretch = this.GetComponent <UIStretch>(); CursorPosition = new Rect( 0.0f, 0.0f, cursorSizeX, cursorSizeY); }
// <summary> /// 给目标添加Collider背景 /// Add Collider Background for target /// </summary> public static GameObject AddColliderBgToTarget(GameObject target, string maskName, UIAtlas altas, bool isTransparent) { // 添加UIPaneldepth最小上面 // 保证添加的Collider放置在屏幕中间 Transform windowBg = FindDeepChild(target, "WindowBg"); if (windowBg == null) { GameObject targetParent = GetPanelDepthMaxMin(target, false, true); if (targetParent == null) { targetParent = target; } windowBg = (new GameObject("WindowBg")).transform; AddChildToTarget(targetParent.transform, windowBg); } Transform bg = FindDeepChild(target, "WindowColliderBg(Cool)"); if (bg == null) { // add sprite or widget to ColliderBg UIWidget widget = null; if (!isTransparent) { widget = NGUITools.AddSprite(windowBg.gameObject, altas, maskName); } else { widget = NGUITools.AddWidget <UIWidget>(windowBg.gameObject); } widget.name = "WindowColliderBg(Cool)"; bg = widget.transform; // fill the screen // You can use the new Anchor system UIStretch stretch = bg.gameObject.AddComponent <UIStretch>(); stretch.style = UIStretch.Style.Both; // set relative size bigger stretch.relativeSize = new Vector2(1.5f, 1.5f); // set a lower depth widget.depth = -5; // set alpha widget.alpha = 0.6f; // add collider NGUITools.AddWidgetCollider(bg.gameObject); } return(bg.gameObject); }
/// <summary> /// Legacy support. /// </summary> void Start() { if (stretchToFill) { stretchToFill = false; UIStretch stretch = gameObject.AddComponent <UIStretch>(); stretch.style = UIStretch.Style.Both; stretch.uiCamera = uiCamera; } }
static public int get_borderPadding(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); pushValue(l, true); pushValue(l, self.borderPadding); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_runOnlyOnce(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); pushValue(l, true); pushValue(l, self.runOnlyOnce); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_container(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); pushValue(l, true); pushValue(l, self.container); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int get_style(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); pushValue(l, true); pushEnum(l, (int)self.style); return(2); } catch (Exception e) { return(error(l, e)); } }
static public int set_runOnlyOnce(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); System.Boolean v; checkType(l, 2, out v); self.runOnlyOnce = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_borderPadding(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); UnityEngine.Vector2 v; checkType(l, 2, out v); self.borderPadding = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_container(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); UnityEngine.GameObject v; checkType(l, 2, out v); self.container = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_uiCamera(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); UnityEngine.Camera v; checkType(l, 2, out v); self.uiCamera = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
static public int set_style(IntPtr l) { try { UIStretch self = (UIStretch)checkSelf(l); UIStretch.Style v; checkEnum(l, 2, out v); self.style = v; pushValue(l, true); return(1); } catch (Exception e) { return(error(l, e)); } }
public static float $Get5(object instance, int index) { UIStretch expr_06_cp_0 = (UIStretch)instance; switch (index) { case 0: return(expr_06_cp_0.borderPadding.x); case 1: return(expr_06_cp_0.borderPadding.y); default: throw new ArgumentOutOfRangeException("index"); } }
public static int get_uiCamera(IntPtr l) { int result; try { UIStretch uIStretch = (UIStretch)LuaObject.checkSelf(l); LuaObject.pushValue(l, true); LuaObject.pushValue(l, uIStretch.uiCamera); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int get_style(IntPtr l) { int result; try { UIStretch uIStretch = (UIStretch)LuaObject.checkSelf(l); LuaObject.pushValue(l, true); LuaObject.pushEnum(l, (int)uIStretch.style); result = 2; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static void $Set5(object instance, float value, int index) { UIStretch expr_06_cp_0 = (UIStretch)instance; switch (index) { case 0: expr_06_cp_0.borderPadding.x = value; return; case 1: expr_06_cp_0.borderPadding.y = value; return; default: throw new ArgumentOutOfRangeException("index"); } }
public static int set_uiCamera(IntPtr l) { int result; try { UIStretch uIStretch = (UIStretch)LuaObject.checkSelf(l); Camera uiCamera; LuaObject.checkType <Camera>(l, 2, out uiCamera); uIStretch.uiCamera = uiCamera; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_container(IntPtr l) { int result; try { UIStretch uIStretch = (UIStretch)LuaObject.checkSelf(l); GameObject container; LuaObject.checkType <GameObject>(l, 2, out container); uIStretch.container = container; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_borderPadding(IntPtr l) { int result; try { UIStretch uIStretch = (UIStretch)LuaObject.checkSelf(l); Vector2 borderPadding; LuaObject.checkType(l, 2, out borderPadding); uIStretch.borderPadding = borderPadding; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
public static int set_initialSize(IntPtr l) { int result; try { UIStretch uIStretch = (UIStretch)LuaObject.checkSelf(l); Vector2 initialSize; LuaObject.checkType(l, 2, out initialSize); uIStretch.initialSize = initialSize; LuaObject.pushValue(l, true); result = 1; } catch (Exception e) { result = LuaObject.error(l, e); } return(result); }
//public Texture cow1; //public Texture cow2; void Start() { //cowAnim = cow.GetComponent<UITextureAnimation>(); //cowAnimation = cow.GetComponent<NPCDialogueAnimation>(); cowAnimation = this.gameObject.GetComponent<NPCDialogueAnimation>(); shakeIt = this.gameObject.GetComponent<BalkiShake>(); walk = this.gameObject.GetComponent<DuckWalk>(); zMov = transform.gameObject.GetComponent<MoveTowardTrain>(); //Squash and stretch myStretch = GetComponent<UIStretch>(); initialStretchY = myStretch.relativeSize.y; currStretchY = initialStretchY; bouncing = false; currPos = new Vector3(0, 0, 0); //InvokeRepeating("startBounce", 0f, 5f); }
/// <summary> /// 给目标添加Collider背景 /// </summary> public static void AddColliderBgTotarget(GameObject target, string maskName, UIAtlas altas, bool isTransparent) { Transform uiBg = GameUtility.FindDeepChild(target, "UIBg"); if (uiBg == null) { GameObject targetParent = GetPanelDepthMaxMin(target, false, true); if (targetParent == null) { targetParent = target; } uiBg = (new GameObject("UIBg")).transform; AddChildToTarget(targetParent.transform, uiBg); } Transform bg = GameUtility.FindDeepChild(target, "UIColliderBg"); if (bg == null) { UIWidget widget = null; if (!isTransparent) { widget = NGUITools.AddSprite(uiBg.gameObject, altas, maskName); } else { widget = NGUITools.AddWidget <UIWidget>(uiBg.gameObject); } widget.name = "UIColliderBg"; bg = widget.transform; UIStretch stretch = bg.gameObject.AddComponent <UIStretch>(); stretch.style = UIStretch.Style.Both; stretch.relativeSize = new Vector2(1.5f, 1.5f); widget.depth = -5; widget.alpha = 0.6f; NGUITools.AddWidgetCollider(bg.gameObject); } }
public void setBulletInfo(STowerID ID, string s, GameObject bullet) { //Icon object[] value = PlayConfig.getBulletBuild(ID); SAnchor b = (SAnchor)value[1]; bulletIcon.mainTexture = Resources.Load <Texture>(GameConfig.PathBulletIcon + value[0].ToString()); bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.Free; bulletIcon.SetDimensions(bulletIcon.mainTexture.width, bulletIcon.mainTexture.height); bulletIcon.keepAspectRatio = UIWidget.AspectRatioSource.BasedOnHeight; UIAnchor anchor = bulletIcon.GetComponent <UIAnchor>(); anchor.relativeOffset = b.Anchor; anchor.enabled = true; UIStretch stretch = bulletIcon.GetComponent <UIStretch>(); stretch.relativeSize.y = b.Stretch; stretch.enabled = true; //Label string[] str = PlayConfig.getBulletType(s); bulletAbility.text = str[0] + " TARGET"; bulletRegion.text = str[1]; //Bullet effect if (bullet != null) { BulletController bulletController = bullet.GetComponent <BulletController>(); if (bulletController.effect == EBulletEffect.NONE) { bulletEffect.gameObject.SetActive(false); } else { bulletEffect.gameObject.SetActive(true); bulletEffect.GetComponent <UIPlay>().bulletEffect = bullet; bulletEffect.spriteName = "icon-effect-" + bullet.GetComponent <BulletController>().effect.ToString().ToLower(); } bulletEffect.GetComponent <UIPlay>().bulletEffect = bullet; } }
//Find respective components and set to default state void Start() { myIcon = transform.FindChild("Icon").GetComponent<UISprite>(); myStretch = transform.FindChild("Icon").GetComponent<UIStretch>(); myBackground = transform.FindChild("Background").GetComponent<UISprite>(); cancelSprite = transform.FindChild("Cancel_button").GetComponent<UISprite>(); nameLabel = transform.FindChild("Label").GetComponent<UILabel>(); backgroundLabel = transform.FindChild("BackgroundLabel").GetComponent<UILabel>(); myIcon.enabled = false; nameLabel.enabled = false; myBorder.enabled = false; cancelSprite.enabled = false; backgroundSpriteName = myBackground.spriteName; }
// Use this for initialization void Start() { uiStretch = GetComponent<UIStretch>(); uiSprite = GetComponent<UISprite>(); }
// Use this for initialization void Start() { characterBubbleSprite.spriteName = characterBubbleSpriteName; descriptionBubbleSprite.spriteName = descriptionBubbleBlank; descriptionToySprite.enabled = false; descriptionToyStretch = descriptionToySprite.gameObject.GetComponent<UIStretch> (); characterNameLabel.text = ""; characterStarLabel.text = ""; characterMinigameNameLabel.text = ""; characterMinigameDescriptionLabel.text = ""; characterLessonLabel.text = ""; for (int i = 0; i < scoreLabelsList.Count; i++) scoreLabelsList [i].text = ""; createButton.SetActive(false); //this.gameObject.SetActive(false); setInactiveWithButtonSound(); }
void Awake() { // Set static instance to this object instance = this; initialRotation = transform.rotation; if (GameManager.WasInitialized () && GameManager.Instance.playerPosition != null) { this.transform.position = GameManager.Instance.playerPosition.position; } // Find the navigation mesh agent in the gameobject (3D) playerNavigation = GameObject.FindObjectOfType(typeof(NavMeshAgent)) as NavMeshAgent; // Find the main camera (3D) sceneCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent<Camera>(); if(!GameObject.Find("FarDistance_Pos")){ farDistance = Vector3.Distance(sceneCamera.transform.position, transform.position); } else{ //Debug.Log("Found Far Distance Pos"); Vector3 farDistancePos = GameObject.Find("FarDistance_Pos").transform.position; farDistance = Vector3.Distance(sceneCamera.transform.position, farDistancePos); } scaleCameraRatio = farDistance - nearDistance; GameObject spritePrefab = ResourceManager.LoadObject ("Player/" + ApplicationState.Instance.selectedCharacter + "Sprite"); GameObject spriteInstance = Instantiate (spritePrefab) as GameObject; spriteInstance.transform.parent = transform; spriteInstance.transform.localPosition = new Vector3(0,0.76f,0); animationsList = spriteInstance.GetComponent<NPCAnimations> (); animationControl = spriteInstance.GetComponent<NPCDialogueAnimation> (); animationFlip = spriteInstance.GetComponent<FlipTexture> (); animationStretch = GetComponentInChildren<UIStretch>(); spriteScale = spriteInstance.transform; scalePlayerRatio = farScale - nearScale; spritePrefab = null; Resources.UnloadUnusedAssets (); }
void Start() { if (!anchor) { anchor = gameObject.GetComponent<UIAnchor>(); } if (bar1 && !barStretch1) { barStretch1 = bar1.gameObject.GetComponent<UIStretch>(); } if (bar2 && !barStretch2) { barStretch2 = bar2.gameObject.GetComponent<UIStretch>(); } }