forum.boolean.name

forum.boolean.name (http://forum.boolean.name/index.php)
-   2D/GUI (http://forum.boolean.name/forumdisplay.php?f=167)
-   -   Копилка хелперов к новому UI (http://forum.boolean.name/showthread.php?t=19598)

ANIK123 25.12.2014 21:45

Копилка хелперов к новому UI
 
1. Помогает настраивать кнопку
Примитивный скрипт, который вешается на кнопку, имеет текстовое поле ввода, изменяя которое вы переименовываете текст кнопки и имя её геймобджекта прямо в эдиторе
Можно легко подстроить под свои нужды, например добавить линк на картинку, и еще всякое что будет душе угодно
PHP код:

using System;
using UnityEngine;
using UnityEngine.UI;
using System.Collections;

[
AddComponentMenu("UI/Custom/ButtonLinker ")]
public class 
ButtonLinker MonoBehaviour {
    public 
string text;
    [
Serializable]
    public class 
Links {
        public 
Text text;
    }
    public 
Links links;
    public 
void Awake(){
        
AppyData();
    }
    public 
void OnValidate(){
        
AppyData();
    }
    public 
void AppyData(){
        
string tmp_str "";
        if (
links.text != null){
            if (
text == ""){tmp_str "????????";}
            else {
tmp_str text;}
            
links.text.text tmp_str;
            
gameObject.name tmp_str;
        }
        else {
            
Debug.LogWarning("Text link is not assigned");
        }
    }


2. Градиент для текста :)
PHP код:

using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
 
[
AddComponentMenu("UI/Effects/Gradient")]
public class 
Gradient BaseVertexEffect {
    [
SerializeField]
    private 
Color32 topColor Color.white;
    [
SerializeField]
    private 
Color32 bottomColor Color.black;
 
    public 
override void ModifyVertices(List<UIVertexvertexList) {
        if (!
IsActive()) {
            return;
        }
 
        
int count vertexList.Count;
        
float bottomY vertexList[0].position.y;
        
float topY vertexList[0].position.y;
 
        for (
int i 1counti++) {
            
float y vertexList[i].position.y;
            if (
topY) {
                
topY y;
            }
            else if (
bottomY) {
                
bottomY y;
            }
        }
 
        
float uiElementHeight topY bottomY;
 
        for (
int i 0counti++) {
            
UIVertex uiVertex vertexList[i];
            
uiVertex.color Color32.Lerp(bottomColortopColor, (uiVertex.position.bottomY) / uiElementHeight);
            
vertexList[i] = uiVertex;
        }
    }



ANIK123 29.01.2015 03:43

Ответ: Копилка хелперов к новому UI
 
Пара классных скриптов, позволяющих сделать такое:

NicerOutline
CurvedText


ANIK123 19.09.2015 12:45

Ответ: Копилка хелперов к новому UI
 
>>>МЕГА НИШТЯКИ<<<


Часовой пояс GMT +4, время: 03:14.

vBulletin® Version 3.6.5.
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Перевод: zCarot