/// <summary> /// Fade out panel /// </summary> /// <param name="panel">Panel to fade out</param> /// <returns></returns> public IEnumerator FadeOutPanel(RectTransform panel) { FadingOutPanel = panel; ActivePanel = null; while (panel.GetComponent<CanvasGroup>().alpha > 0) { panel.GetComponent<CanvasGroup>().alpha -= Time.deltaTime / FadeTime; yield return null; } FadingOutPanel.gameObject.SetActive(false); FadingOutPanel = null; }
public RectTransform FadingOutPanel; //Reference to panel that is currently fading out #endregion Fields #region Methods /// <summary> /// Fade in panel /// </summary> /// <param name="panel">Panel to fade in</param> /// <returns></returns> public IEnumerator FadeInPanel(RectTransform panel) { FadingInPanel = panel; FadingInPanel.gameObject.SetActive(true); while(panel.GetComponent<CanvasGroup>().alpha < 1) { panel.GetComponent<CanvasGroup>().alpha += Time.deltaTime / FadeTime; yield return null; } ActivePanel = panel; FadingInPanel = null; }
public override void Initialize() { battleSelection = transform.root.GetComponent<BattleSelection> (); Canvas canvas = transform.FindChild ("BattleCanvas").GetComponent<Canvas>(); foreach(GameObject g in GameObject.FindGameObjectsWithTag("Canvas")){ g.SetActive(false); //set all other canvases inactive to be sure } canvas.gameObject.SetActive (true); //activate the canvas we want if (!initialized) { if (canvas != null) { //is this nessisary? probs not because I think that setactive call above will throw an exception leftPanel = canvas.transform.FindChild ("Left Panel").GetComponent<RectTransform> (); mothershipLeftPanel = canvas.transform.FindChild ("Mothership Left Panel").GetComponent<RectTransform> (); mothershipPanel = mothershipLeftPanel.GetComponent<BattleMothershipPanel> (); infoPanel = leftPanel.GetComponent<BattleInfoPanel> (); infoPanel.Initialize (); mothershipPanel.Initialize (); timer = GetComponent<Timer> (); jumpbutton = GameObject.Find ("BattleCanvas/Top Panel/JumpButton"); jumpbutton.SetActive (false); initialized = true; } else { Debug.Log ("Null canvas for Battle?"); } } }
public void SwitchTo(RectTransform new_panel) { if (ActivePanel) { if (ActivePanel == new_panel) return; if (ActivePanel.GetComponent<CanvasGroup>()) PanelUtilities.DeactivatePanel(ActivePanel.GetComponent<CanvasGroup>()); } ActivePanel = new_panel; if (ActivePanel.GetComponent<CanvasGroup>()) PanelUtilities.ActivatePanel(ActivePanel.GetComponent<CanvasGroup>()); }
// Use this for initialization void Start () { penX.onValueChange.AddListener(ChangePenX); penY.onValueChange.AddListener(ChangePenY); brushX.onValueChange.AddListener(ChangeBrushX); brushY.onValueChange.AddListener(ChangeBrushY); bSize.onValueChange.AddListener(ChangeBSize); penX.text = PlayerPrefs.GetInt("penOffsetX", 0).ToString(); penY.text = PlayerPrefs.GetInt("penOffsetY", 0).ToString(); brushX.text = PlayerPrefs.GetInt("brushOffsetX", 0).ToString(); brushY.text = PlayerPrefs.GetInt("brushOffsetY", 0).ToString(); bSize.text = PlayerPrefs.GetInt("bSize", 10).ToString(); var detector = DrawUtility.CreateDetector(prefab); detector.OnStartPaint += new PaintingDetector2D.DelegatePaint(OnStartPaint); detector.OnPaintMovement += new PaintingDetector2D.DelegatePaint(OnPaintMovement); detector.OnPaintEnd += new PaintingDetector2D.DelegatePaint(OnPaintEnd); drawRect = DrawUtility.CreateRectTransform(prefab, new Vector2(Screen.width, Screen.height)); drawImage = drawRect.GetComponent<RawImage>(); paintTexture = DrawUtility.CreateCanvas(Screen.width, Screen.height); drawImage.texture = paintTexture; btn.onClick.AddListener(Click); }
void Start() { mRectTransform = this.transform as RectTransform; _btn = mRectTransform.GetComponent<Button>(); _mask = mRectTransform.Find("mask").GetComponent<Image>(); _mask.transform.localPosition = Vector3.zero; _mask.enabled = false; }
void Awake() { panelTournament = transform.FindChild("PanelTournament") as RectTransform; panelNormal = transform.FindChild("PanelNormal") as RectTransform; panelPlayerList = transform.FindChild("PanelPlayerList") as RectTransform; panelChatBox = transform.FindChild("PanelChatBox") as RectTransform; chatBox = panelChatBox.GetComponent<ChatBoxControl>(); }
public override RectTransform getView(RectTransform currentView, int position) { if (currentView == null) { currentView = Instantiate(prefab); } Text text = currentView.GetComponent<Text>(); text.text = textList[position] + " pos=" + position; return currentView; }
void MoveScene(RectTransform obj,int scnarioNumber) { Button button = obj.GetComponent<Button> (); button.onClick.AddListener (() => { NovelSingleton.StatusManager.callJoker("wide/scene"+ scnarioNumber,""); }); }
void Start() { internalRect = transform.FindChild ("Internal").GetComponent<RectTransform>(); externalRect = transform.FindChild ("External").GetComponent<RectTransform>(); internalButtons = internalRect.GetComponent<ButtonOrganizer> (); externalButtons = externalRect.GetComponent<ButtonOrganizer> (); attachmentPanel = PrefabLoader.GetGUIObject ("AttachmentPanel"); userInput = transform.root.GetComponent<ShipEditorUserInput> (); }
protected override void Start () { PlaceHolder = transform.GetChild(0) as RectTransform; PlaceHolder.GetComponent<Image>().sprite = imageButteon.sprite; rectTransf = transform as RectTransform; menu = rectTransf.parent.GetComponent<CirculareMenu>(); isStarted = true; }
public void Start() { // get components canvas = GameObject.Find("StatUI").GetComponent<RectTransform>(); game = canvas.GetComponent<Game>(); model = transform.Find("Model").transform; player = GameObject.Find("Player").transform; nav = GetComponent<NavMeshAgent>(); nav.speed = Random.Range(2.0f, 5.5f); // build healthbar GameObject backGO = new GameObject("healthbarback"); backGO.transform.parent = canvas.Find("HealthBars").transform; GameObject healthGO = new GameObject("healthbar"); healthGO.transform.parent = canvas.Find("HealthBars").transform; healthBar = healthGO.AddComponent<Image>(); backBar = backGO.AddComponent<Image>(); healthBar.color = Color.red; backBar.color = new Color(0.2f, 0.0f, 0.0f); healthBar.rectTransform.sizeDelta = new Vector2(100, 5); backBar.rectTransform.sizeDelta = new Vector2(100, 5); backBar.rectTransform.pivot = Vector2.zero; healthBar.rectTransform.pivot = Vector2.zero; switch (type) { case EnemyType.ORC: hp = 2.0f + game.level; damage = 2.0f + game.level; break; case EnemyType.SKELETON: hp = 0.5f + game.level / 3.0f; damage = 1.0f + (game.level) / 3.0f; break; case EnemyType.MAGE: hp = 1.0f + game.level / 3.0f; damage = 2.5f + game.level / 2.0f; break; case EnemyType.RANGER: hp = 1.0f + game.level / 2.0f; damage = 1.0f + game.level / 2.0f; break; case EnemyType.CROSSBOW: hp = 1.0f + game.level / 1.5f; damage = 1.0f + game.level / 2.0f; break; default: hp = 1.0f + game.level / 2.0f; damage = 1.0f + game.level / 2.0f; break; } maxhp = hp; }
//summon activates whenever a card is played. All spells (at least for now) target a specific tile. public override Transform Summon(RectTransform location, Transform hand) { if (location.GetComponent<Tile_Component>().unit != null) location.GetComponentInChildren<BaseUnit_Component>().TakeDamage(5); else { hand.GetComponent<ResourceManager>().AddResources(cost); hand.GetComponent<Hand_Component>().AddCard(0003); } return transform; }
void Awake() { On("OnMainCameraChange"); _healthContainer = GetComponentInChildren<Image>().gameObject; _healthContainer.GetComponentInParent<Canvas>().worldCamera = Camera.main; _rectTransform = _healthContainer.GetComponent<RectTransform>(); _healthBar = _healthContainer.transform.FindChild("HealthBar").GetComponent<RectTransform>(); _image = _healthBar.GetComponent<Image>(); _krHealth = transform.GetComponentInParent<KRHealth>(); }
//summons a creature public override Transform Summon(RectTransform tile, Transform hand) { Transform thisGuy = Instantiate(transform); tile.GetComponent<Tile_Component>().unit = thisGuy.GetComponent<RectTransform>(); thisGuy.transform.SetParent(tile, false); health = maxHealth; attack = baseAttack; countdown = baseCountdown; return transform; }
private void LoadLifeBar() { GameObject _go = ResourceManager.Instance.LoadNewPrefab("UILifeBar2",UIMgr.Instance.GetLayer(UIMgr.Layer.layer2)); _go.name = "UILifeBar_" + Enity.GetProperty("name"); barTransfrom = _go.transform as RectTransform; _uilifeBar = barTransfrom.GetComponent<UILifeBar2>(); if(_uilifeBar == null) { _uilifeBar = barTransfrom.gameObject.AddComponent<UILifeBar2>(); } _uilifeBar._camera = Enity.GetProperty("camera") as Camera; _uilifeBar._actor = Enity.Transform; }
protected static void InitializeTooltip(RectTransform tooltipObject) { UI_TooltipReceiver.UITooltipObject = tooltipObject; //set a CanvasGroup to the new tooltip if there is none if (!tooltipObject.GetComponent<CanvasGroup>()) { CanvasGroup group = tooltipObject.gameObject.AddComponent<CanvasGroup>(); group.blocksRaycasts = false; group.interactable = false; } //set tooltip pivot to top left tooltipObject.pivot = new Vector2(0f, 1f); tooltipObject.gameObject.SetActive (false); //Set the text object in UI_TooltipReceiverWithText script if (tooltipObject.GetComponent<simpleTooltipWithText>() != null) UI_TooltipReceiverWithText.textObject = UI_TooltipReceiver.UITooltipObject.GetComponent<simpleTooltipWithText>().text; else UI_TooltipReceiverWithText.textObject = null; }
//move unit from previous tile to the next tile.Actually creates instance with the exact same qualities. public void Move(RectTransform previousTile, RectTransform tileTo) { Transform thisGuy = Instantiate(transform); //set unit components tileTo.GetComponent<Tile_Component>().unit = thisGuy.GetComponent<RectTransform>(); previousTile.GetComponent<Tile_Component>().unit = null; thisGuy.transform.SetParent(tileTo, false); DestroyImmediate(gameObject, true); }
void Awake() { m_Rect = GetComponent<ScrollRect>(); m_RectContent = m_Rect.content; GridLayoutGroup group; if((group = m_RectContent.GetComponent<GridLayoutGroup>())) { m_Gap = group.cellSize.x + group.spacing.x; } else { Debug.LogError("No grid layout group component attach at the scroll rect content !"); } }
void Start() { canvas = GameObject.Find("Canvas").GetComponent<RectTransform>(); nodoUIRectTransform = GetComponent<RectTransform>(); Panel = GameObject.Find("Canvas/Panel").GetComponent<RectTransform>(); janelaUI=Panel.GetComponent<JanelaUI>(); // transform.parent = canvas.transform; // Vector3 vetor= new Vector3(canvas.GetComponent<RectTransform>().rect.width, canvas.GetComponent<RectTransform>().rect.height,0); // transform.position += canvas.GetComponent<RectTransform>().position +vetor; //Vector3 vetor = new Vector3(canvas.rect.width/2, canvas.rect.height/2, 0); //transform.position = vetor; //AdicionarPorta(); }
protected override void OnAwakeView() { Transform _Text_TextSample0 = transform.FindChild("TextSample"); textSample = _Text_TextSample0.GetComponent<Text>(); Transform ScrollView1 = transform.FindChild("ScrollView"); Transform Viewport10 = ScrollView1.FindChild("Viewport"); Transform _Panel_Content100 = Viewport10.FindChild("Content"); contentPanel = _Panel_Content100.GetComponent<RectTransform>(); layoutGroup = contentPanel.GetComponent<VerticalLayoutGroup>(); if(layoutGroup == null) { layoutGroup = contentPanel.gameObject.AddComponent<VerticalLayoutGroup>(); } UpdateWidth(); }
void Start () { spriteRenderer = GetComponent<SpriteRenderer>(); target = GameObject.FindGameObjectWithTag("Player").transform; exclaimation = GameObject.Find("Exclaimation"); // Generate idle sprite animations var spriteRegex = new Regex(@".*\-"); var spriteMatch = spriteRegex.Match(spriteRenderer.sprite.ToString()); if (spriteMatch.Success) { string spriteName = spriteMatch.Groups[0].Value; for (int i = 1; i <= animationFrameCount; i++) { Sprite tmpSprite = Resources.Load<Sprite>("NPCs/" + spriteName + i); idleSpriteList.Add(tmpSprite); } } // Get specific children var children = GetComponentsInChildren<RectTransform>(); foreach (var child in children) { if (child.name == "PlayerInfo") { playerInfo = child; playerInfoCanvas = playerInfo.GetComponent<Canvas>(); } } UpdatePlayerInfo(); // Add exclaimation if (hasInteraction) { Vector3 exclaimationPos = new Vector3(transform.position.x + interactionOffset, transform.position.y, transform.position.z); Instantiate(exclaimation, exclaimationPos, Quaternion.identity); } // Trigger idle animations if (spriteMatch.Success) { InvokeRepeating("UpdateIdleAnimation", idleAnimationStepTime, idleAnimationStepTime); } }
void Awake() { tform = transform; myRigidbody = GetComponent<Rigidbody>(); stats = GetComponent<PlayerStats>(); cam = Camera.main.GetComponent<CameraManager>(); canvas = GameObject.Find("StatUI").GetComponent<RectTransform>(); game = canvas.GetComponent<Game>(); GameObject healthFront = new GameObject("healthBar"); healthBar = healthFront.AddComponent<Image>(); healthBar.rectTransform.SetParent(canvas.transform, false); healthBar.color = Color.red; GameObject healthBack = new GameObject("healthBarBack"); backBar = healthBack.AddComponent<Image>(); backBar.rectTransform.SetParent(canvas.transform, false); backBar.color = new Color(0.0f, 0.0f, 0.0f); Application.runInBackground = false; }
//0: width, 1, height //anchor1line: 0, anchor2line: 1, anchor1connectline: 2, anchor2connectline: 3 private void Initiate() { for (int i = 0; i < 2; i++) { rtms[i] = new List <rtm>(); } canvas = go.Find("Canvas").GetComponent <rtm>(); for (int j = 0; j < 2; j++) { for (int i = 0; i < 4; i++) { go obj = new go("line", typeof(Image)); obj.transform.SetParent(this.canvas, false); obj.GetComponent <Image>().color = Color.red; rtm temp = obj.GetComponent <rtm>(); temp.anchorMax = temp.anchorMin = new v2(0f, 0f); temp.pivot = new v2(0f, 0.5f); temp.gameObject.SetActive(isActive); rtms[j].Add(temp); } } //adds the label for (int i = 0; i < 2; i++) { go obj3 = new go("lengthText", typeof(Text)); obj3.transform.SetParent(this.canvas, false); rtm label = obj3.GetComponent <rtm>(); label.anchorMin = label.anchorMax = new v2(0.5f, 0.5f); label.pivot = new v2(0.5f, 0.5f); label.gameObject.SetActive(false); rtms[i].Add(label); Text t = label.GetComponent <Text>(); t.color = new Color(1, 1, 1); t.fontSize = 60; t.font = Util.Caladea_Bold; } }
// Use this for initialization void Start() { ParentButtonDefault = ParentButton; ParentRectDefault = ParentButtonDefault.GetComponent<RectTransform>(); ParentRectHeight = ParentRectDefault.rect.height; ParentRect = ParentRectDefault; ScrollBar = ScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>(); }
protected override float GetSize(RectTransform item) { return item.GetComponent<LayoutElement>().preferredHeight + contentSpacing; }
void Awake() { fill = slider.fillRect; fill.GetComponent<Image> ().color = MaxHealthColor; }
protected override float GetSize (RectTransform item) { return item.GetComponent<LayoutElement> ().minWidth + content.GetComponent<HorizontalLayoutGroup> ().spacing; }
// Use this for initialization public void Start() { FeatParentButtonDefault = FeatParentButton; FeatParentRectDefault = FeatParentButtonDefault.GetComponent<RectTransform>(); ParentRectHeight = FeatParentRectDefault.rect.height; ParentRect = FeatParentRectDefault; ScrollBar = FeatScrollView.gameObject.transform.GetChild(1).GetComponent<Scrollbar>(); XML_Loader xmlLoader = ScriptableObject.CreateInstance<XML_Loader> ();//load xml List<string> XmlResult = new List<string> (); if (Settings_Screen.is_online == true) { XmlResult = xmlLoader.LoadInnerXml("https://raw.githubusercontent.com/theslimreaper/DnD/master/XML%20Files/Character Features/feats.xml", "feat"); } else { XmlResult = xmlLoader.LoadInnerXmlFromFile("..\\XML Files/Character Features/feats.xml", "feat"); } foreach(var item in XmlResult)//loop through the spell list and sort the spells based off of spell level (if character class is correct) { var idLine = item.Substring(item.IndexOf("<id>") + 4,(item.IndexOf("</id>")-item.IndexOf("<id>")) - 4); bool cont = true; List<string> IDList = new List<string> (); IDList = Character_Info.characterFeats; foreach(var id in IDList) { if (idLine.Contains (id)) { cont = false; } } if (cont == true) { Feat_Class FeatsSet = new Feat_Class(); FeatsSet.featName = item.Substring((item.IndexOf("<name>") + 6),((item.IndexOf("</name>")-item.IndexOf("<name>")) - 6)); FeatsSet.featPrereq = item.Substring(item.IndexOf("<prerequisite>") + 14,(item.IndexOf("</prerequisite>")-item.IndexOf("<prerequisite>")) - 14); if (item.IndexOf("<modifier>") != -1) { FeatsSet.featModifier = item.Substring(item.IndexOf("<modifier>") + 10,(item.IndexOf("</modifier>")-item.IndexOf("<modifier>")) - 10); } FeatsSet.featID = item.Substring(item.IndexOf("<id>") + 4,(item.IndexOf("</id>")-item.IndexOf("<id>")) - 4); FeatsSet.featDescription = item.Substring(item.IndexOf("<text>") + 6,(item.IndexOf("</text>")-item.IndexOf("<text>")) - 6); FeatsList.Add(FeatsSet); } } MakeButtons(); }
private void BlockDecoration(RectTransform blockPrefab, Block block) { Color color = new Color(); string name = ""; if (block is LandBlock) { color = new Color(0x00 / 255f, 0xB0 / 255f, 0x06 / 255f); name = (block as LandBlock).land.name; } else if (block is ChanceBlock) { color = new Color(0xFF / 255f, 0x28 / 255f, 0x28 / 255f); name = "Chance"; } else if(block is DestinyBlock) { color = new Color(0xFF / 255f, 0xCC / 255f, 0x1F / 255f); name = "Destiny"; } blockPrefab.GetComponent<RawImage>().color = color; blockPrefab.GetChild(0).GetComponent<Text>().text = name; }
public void FadeInAddChild(RectTransform child) { this.AddChild(child); var image = child.GetComponent<Image>(); image.DOFade(0, 1).From(); image.DOFade(1, .5f); }