Exemple #1
0
    void OnEnable()
    {
        HeroColorPresets presets = target as HeroColorPresets;

        if (presets != null)
        {
            m_PresetCount = presets.PresetColorCount;
        }
    }
Exemple #2
0
    void OnDisable()
    {
        GameObject go = GameObject.Find("__HeroColorPreset");

        if (go != null)
        {
            DestroyImmediate(go);
        }
        m_HeroColorPresets = null;
    }
Exemple #3
0
    void OnEnable()
    {
        if (HeroColorPresets.Instance == null)
        {
            GameObject go = GameObject.Find("__HeroColorPreset");
            if (go == null)
            {
                GameObject prefab = AssetDatabase.LoadAssetAtPath(GetHeroPresetsAssetPath(), typeof(GameObject)) as GameObject;
                if (prefab == null)
                {
                    Debug.LogError("Failed to load hero color preset prefab");
                    return;
                }
                go                 = GameObject.Instantiate(prefab) as GameObject;
                go.name            = "__HeroColorPreset";
                m_HeroColorPresets = go.GetComponent <HeroColorPresets>();
            }
        }
        else
        {
            m_HeroColorPresets = HeroColorPresets.Instance;
        }
        if (m_HeroColorPresets != null)
        {
            m_PresetList.Clear();
            m_PresetList.Add("None");
            int presetCount = m_HeroColorPresets.PresetColorCount;
            for (int i = 0; i < presetCount; i++)
            {
                m_PresetList.Add(string.Format("Preset {0}", i + 1));
            }

            ColorCustomization customization = target as ColorCustomization;
            if (customization != null)
            {
                if (customization.m_SkinColorIndex >= presetCount)
                {
                    customization.m_SkinColorIndex = -1;
                }
                if (customization.m_HairColorIndex >= presetCount)
                {
                    customization.m_HairColorIndex = -1;
                }
                if (customization.m_EyeColorIndex >= presetCount)
                {
                    customization.m_EyeColorIndex = -1;
                }
                if (customization.m_EquipmentColorIndex >= presetCount)
                {
                    customization.m_EquipmentColorIndex = -1;
                }
            }
        }
    }
Exemple #4
0
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();
        GUILayout.Space(8);
        HeroColorPresets presets = target as HeroColorPresets;

        m_ScrollPosition = GUILayout.BeginScrollView(m_ScrollPosition);

        GUILayout.BeginHorizontal();
        m_PresetCount = EditorGUILayout.IntField("Preset Count", m_PresetCount);
        if (GUILayout.Button("Resize"))
        {
            presets.PresetColorCount = m_PresetCount;
        }
        GUILayout.EndHorizontal();

        GUI.color = Color.red;
        if (NGUIEditorTools.DrawHeader("Skin Color Presets"))
        {
            DrawColorPresets(ref presets.m_SkinColorPresets);
        }

        GUI.color = Color.green;
        if (NGUIEditorTools.DrawHeader("Hair Color Presets"))
        {
            DrawColorPresets(ref presets.m_HairColorPresets);
        }
        GUI.color = new Color(0.0f, 0.5f, 1.0f);
        if (NGUIEditorTools.DrawHeader("Eye Color Presets"))
        {
            DrawColorPresets(ref presets.m_EyeColorPresets);
        }
        GUI.color = Color.grey;
        if (NGUIEditorTools.DrawHeader("Equipment Color Presets"))
        {
            DrawColorPresets(ref presets.m_EquipmentColorPresets);
        }

        GUILayout.EndScrollView();
    }
Exemple #5
0
 void Awake()
 {
     m_instance = this;
     DontDestroyOnLoad(gameObject);
 }