Example #1
0
 void OnEnable()
 {
     m_scrypt = (DevPart)target;
     m_target = new SerializedObject(target);
     m_type = m_scrypt.type;
     m_items_unit = m_target.FindProperty("m_items_unit");
     m_items_armor = m_target.FindProperty("m_items_armor");
     m_items_weapon = m_target.FindProperty("m_items_weapon");
     m_items_wing = m_target.FindProperty("m_items_wing");
     m_item_count = m_scrypt.item_count;
     if (m_type == PACKAGE_TYPE.ARMOR)
     {
         m_color_count = m_scrypt.color_count;
         m_scrypt.UpdateList(m_color_count);
     }
     else
     {
         m_color_count = 1;
     }
 }
Example #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        m_target.Update();

        GUI.backgroundColor = m_color_blue;
        GUILayout.BeginHorizontal();
        GUILayout.Label("Package Name");
        m_target.FindProperty("m_package_name").stringValue = EditorGUILayout.TextField(m_scrypt.package_name);
        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();
        m_target.FindProperty("m_search_order").intValue = EditorGUILayout.IntField("Order", m_scrypt.search_order);
        GUILayout.EndHorizontal();

        GUI.backgroundColor = m_color_old;
        GUILayout.BeginHorizontal();
        PACKAGE_TYPE temp_type = (PACKAGE_TYPE)EditorGUILayout.EnumPopup("Package Type", m_scrypt.type);
        if (temp_type != m_type)
        {
            m_type = temp_type;
            m_target.FindProperty("m_type").enumValueIndex = (int)temp_type;
            m_target.ApplyModifiedProperties();

            if (m_type == PACKAGE_TYPE.ARMOR)
            {
                m_scrypt.UpdateList(m_scrypt.color_count);
                m_item_count = m_scrypt.item_count;
                m_color_count = m_scrypt.color_count;
            }
            else
            {
                m_item_count = m_scrypt.item_count;
                m_color_count = 1;
            }
        }
        GUILayout.EndHorizontal();

        GUI.backgroundColor = m_color_blue;
        if (m_type != PACKAGE_TYPE.NONE)
        {
            int temp_value;
            switch (m_type)
            {
                case PACKAGE_TYPE.UNIT:
                    {
                        GUILayout.BeginHorizontal();
                        m_target.FindProperty("m_eye_pos").vector2Value = EditorGUILayout.Vector2Field("eye_pos", m_scrypt.eye_pos);
                        GUILayout.EndHorizontal();
                    }
                    break;
                default:
                    break;
            }

            GUILayout.BeginHorizontal();
            GUILayout.Label("Item Count");
            temp_value = EditorGUILayout.IntField(m_item_count);
            temp_value = Mathf.Max(0, temp_value);
            if (m_item_count != temp_value)
            {
                ChangeIndexCount(items, m_item_count, temp_value);
                m_item_count = temp_value;
            }
            GUILayout.EndHorizontal();

            switch (m_type)
            {
                case PACKAGE_TYPE.ARMOR:
                    {
                        GUILayout.BeginHorizontal();
                        GUILayout.Label("Color Count");
                        temp_value = EditorGUILayout.IntField(m_color_count);
                        temp_value = Mathf.Max(1, temp_value);
                        if (m_color_count != temp_value)
                        {
                            ChangeColorCount(items, m_color_count, temp_value);
                            m_color_count = temp_value;
                        }
                        GUILayout.EndHorizontal();
                    }
                    break;
                default:
                    break;
            }
            GUI.backgroundColor = m_color_old;

            for (int i = 0; i < m_item_count; i++)
            {
                switch (m_scrypt.type)
                {
                    case PACKAGE_TYPE.UNIT:
                        DevwinEditor.BeginBox();
                        DrawItem_Unit(i);
                        DevwinEditor.EndBox();
                        break;
                    case PACKAGE_TYPE.ARMOR:
                        for (int c = 0; c < m_color_count; c++)
                        {
                            DevwinEditor.BeginBox();
                            DrawItem_Armor(i, c);
                            DevwinEditor.EndBox();
                        }
                        break;
                    case PACKAGE_TYPE.WING:
                        DevwinEditor.BeginBox();
                        DrawItem_Wing(i);
                        DevwinEditor.EndBox();
                        break;
                    default:
                        // weapon
                        DevwinEditor.BeginBox();
                        DrawItem_Weapon(i);
                        DevwinEditor.EndBox();
                        break;
                }
            }
        }

        GUI.backgroundColor = m_color_blue;
        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Clean up un-used data", GUILayout.Width(250f)))
        {
            m_scrypt.Cleanup();
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();
        GUI.backgroundColor = m_color_old;
        m_target.ApplyModifiedProperties();
    }