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; } }
public int GetPackageList(out DevPart[] _list, params PACKAGE_TYPE[] _pak_types) { List<DevPart> temp_list = new List<DevPart>(); foreach (DevPart temp in m_package_list.Values) { foreach (PACKAGE_TYPE temp_type in _pak_types) { if (temp.type == temp_type) { int temp_insert; for (temp_insert = 0; temp_insert < temp_list.Count; temp_insert++) { if (temp.search_order < temp_list[temp_insert].search_order) break; } temp_list.Insert(temp_insert, temp); } } } _list = temp_list.ToArray(); return _list.Length; }
public void LoadPackages(DevPart[] _packages) { foreach (DevPart pack in _packages) { if (m_package_list.ContainsKey(pack.package_name)) continue; m_package_list.Add(pack.package_name, pack); } }
void _init_array(DevPart[] _src, bool _add_default, out string[] _dest) { if (_add_default) { _dest = new string[_src.Length + 1]; _dest[0] = "none"; for (int i = 0; i < _src.Length; i++) { _dest[i + 1] = _src[i].package_name; } } else { _dest = new string[_src.Length]; for (int i = 0; i < _src.Length; i++) { _dest[i] = _src[i].package_name; } } }
void OnGUI() { const float temp_width_total = 500f; const float temp_width_label = 200f; DevPart temp_part = null; // unit GUI.backgroundColor = m_color_green; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Unit Package", GUILayout.Width(temp_width_label)); temp_part = (DevPart)EditorGUILayout.ObjectField(m_unit_part, typeof(DevPart), false); if (temp_part == null || temp_part.type == PACKAGE_TYPE.UNIT) m_unit_part = temp_part; EditorGUILayout.EndHorizontal(); GUI.backgroundColor = m_color_old; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Unit Index", GUILayout.Width(temp_width_label)); if (m_unit_part != null) { m_unit_index = EditorGUILayout.IntSlider(m_unit_index, 0, _index_value(m_unit_part.item_count)); } else { m_unit_index = EditorGUILayout.IntSlider(m_unit_index, 0, 0); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10f); // armor GUI.backgroundColor = m_color_green; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Armor Package", GUILayout.Width(temp_width_label)); temp_part = (DevPart)EditorGUILayout.ObjectField(m_armor_part, typeof(DevPart), false); if (temp_part == null || temp_part.type == PACKAGE_TYPE.ARMOR) m_armor_part = temp_part; EditorGUILayout.EndHorizontal(); GUI.backgroundColor = m_color_old; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Armor Index", GUILayout.Width(temp_width_label)); if (m_armor_part != null) { m_armor_index = EditorGUILayout.IntSlider(m_armor_index, 0, _index_value(m_armor_part.item_count)); } else { m_armor_index = EditorGUILayout.IntSlider(m_armor_index, 0, 0); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Armor Color", GUILayout.Width(temp_width_label)); if (m_armor_part != null) { m_armor_color = EditorGUILayout.IntSlider(m_armor_color, 0, _index_value(m_armor_part.color_count)); } else { m_armor_color = EditorGUILayout.IntSlider(m_armor_color, 0, 0); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10f); // weapon main GUI.backgroundColor = m_color_green; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Weapon Package (Main)", GUILayout.Width(temp_width_label)); temp_part = (DevPart)EditorGUILayout.ObjectField(m_weapon_main_part, typeof(DevPart), false); if (temp_part == null) { m_weapon_main_part = temp_part; } else { switch (temp_part.type) { case PACKAGE_TYPE.WEAPON_BOW: case PACKAGE_TYPE.WEAPON_MELEE: case PACKAGE_TYPE.WEAPON_STAFF: m_weapon_main_part = temp_part; break; default: break; } } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = m_color_old; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Weapon Index (Main)", GUILayout.Width(temp_width_label)); if (m_weapon_main_part != null) { m_weapon_main_index = EditorGUILayout.IntSlider(m_weapon_main_index, 0, _index_value(m_weapon_main_part.item_count)); } else { m_weapon_main_index = EditorGUILayout.IntSlider(m_weapon_main_index, 0, 0); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10f); // weapon sub GUI.backgroundColor = m_color_green; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Weapon Package (Sub)", GUILayout.Width(temp_width_label)); temp_part = (DevPart)EditorGUILayout.ObjectField(m_weapon_sub_part, typeof(DevPart), false); if (temp_part == null) { m_weapon_sub_part = temp_part; } else { switch (temp_part.type) { case PACKAGE_TYPE.WEAPON_ARROW: case PACKAGE_TYPE.WEAPON_MELEE: case PACKAGE_TYPE.WEAPON_SHIELD: m_weapon_sub_part = temp_part; break; default: break; } } EditorGUILayout.EndHorizontal(); GUI.backgroundColor = m_color_old; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Weapon Index (Sub)", GUILayout.Width(temp_width_label)); if (m_weapon_sub_part != null) { m_weapon_sub_index = EditorGUILayout.IntSlider(m_weapon_sub_index, 0, _index_value(m_weapon_sub_part.item_count)); } else { m_weapon_sub_index = EditorGUILayout.IntSlider(m_weapon_sub_index, 0, 0); } EditorGUILayout.EndHorizontal(); GUILayout.Space(10f); // wing GUI.backgroundColor = m_color_green; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Wing Package", GUILayout.Width(temp_width_label)); temp_part = (DevPart)EditorGUILayout.ObjectField(m_wing_part, typeof(DevPart), false); if (temp_part == null || temp_part.type == PACKAGE_TYPE.WING) m_wing_part = temp_part; EditorGUILayout.EndHorizontal(); GUI.backgroundColor = m_color_old; EditorGUILayout.BeginHorizontal(GUILayout.Width(temp_width_total)); EditorGUILayout.LabelField("Wing Index", GUILayout.Width(temp_width_label)); if (m_wing_part != null) { m_wing_index = EditorGUILayout.IntSlider(m_wing_index, 0, _index_value(m_wing_part.item_count)); } else { m_wing_index = EditorGUILayout.IntSlider(m_wing_index, 0, 0); } EditorGUILayout.EndHorizontal(); GUILayout.Space(20f); GUI.backgroundColor = m_color_blue; GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Generate Texture", GUILayout.Width(200f), GUILayout.Height(30f))) { string save_path = EditorUtility.SaveFilePanel( "Generate Texture", "Assets", "default", "png"); if (save_path.StartsWith(Application.dataPath)) { GameObject temp_obj = new GameObject(); DevEngine temp_engine = temp_obj.AddComponent<DevEngine>(); if (m_unit_part != null) { m_data.unit_part = m_unit_part.package_name; m_data.unit_index = m_unit_index; temp_engine.preload_packages.Add(m_unit_part); } else { m_data.unit_part = ""; } if (m_armor_part != null) { m_data.armor_part = m_armor_part.package_name; m_data.armor_index = m_armor_index; m_data.armor_color = m_armor_color; temp_engine.preload_packages.Add(m_armor_part); } else { m_data.armor_part = ""; } if (m_weapon_main_part != null) { m_data.main_weapon_part = m_weapon_main_part.package_name; m_data.main_weapon_index = m_weapon_main_index; temp_engine.preload_packages.Add(m_weapon_main_part); } else { m_data.main_weapon_part = ""; } if (m_weapon_sub_part != null) { m_data.sub_weapon_part = m_weapon_sub_part.package_name; m_data.sub_weapon_index = m_weapon_sub_index; temp_engine.preload_packages.Add(m_weapon_sub_part); } else { m_data.sub_weapon_part = ""; } if (m_wing_part != null) { m_data.wing_part = m_wing_part.package_name; m_data.wing_index = m_wing_index; temp_engine.preload_packages.Add(m_wing_part); } else { m_data.wing_part = ""; } temp_engine.Init(); temp_engine.CreateCharacterTexture(m_data, save_path); DestroyImmediate(temp_obj); EditorUtility.DisplayDialog("Successfully created", "", "OK"); } else if (save_path.Length != 0) { EditorUtility.DisplayDialog( "Failed to create package", string.Format("You must select child folder of {0}", Application.dataPath), "OK"); } } GUILayout.FlexibleSpace(); EditorGUILayout.EndHorizontal(); GUI.backgroundColor = m_color_old; }
public void InitWithoutTextureBaking() { { m_unit = DevEngine.Instance.GetPackage_Unit(Info.unit_part, Info.unit_index); m_main_weapon = DevEngine.Instance.GetPackage_Weapon(Info.main_weapon_part, Info.main_weapon_index); m_sub_weapon = DevEngine.Instance.GetPackage_Weapon(Info.sub_weapon_part, Info.sub_weapon_index); m_wing = DevEngine.Instance.GetPackage_Wing(Info.wing_part, Info.wing_index); m_unit_pak = DevEngine.Instance.GetPackage(Info.unit_part); m_main_weapon_pak = DevEngine.Instance.GetPackage(Info.main_weapon_part); m_sub_weapon_pak = DevEngine.Instance.GetPackage(Info.sub_weapon_part); } DevPart part_unit = DevEngine.Instance.GetPackage(Info.unit_part); DevPart part_armor = DevEngine.Instance.GetPackage(Info.armor_part); DevPart part_main = DevEngine.Instance.GetPackage(Info.main_weapon_part); DevPart part_sub = DevEngine.Instance.GetPackage(Info.sub_weapon_part); DevPart part_wing = DevEngine.Instance.GetPackage(Info.wing_part); PackageData_Unit pak_unit = part_unit != null ? part_unit.GetUnit(Info.unit_index) : null; PackageData_Armor pak_armor = part_armor != null ? part_armor.GetArmor(Info.armor_index, Info.armor_color) : null; PackageData_Weapon pak_main = part_main != null ? part_main.GetWeapon(Info.main_weapon_index) : null; PackageData_Weapon pak_sub = part_sub != null ? part_sub.GetWeapon(Info.sub_weapon_index) : null; PackageData_Wing pak_wing = part_wing != null ? part_wing.GetWing(Info.wing_index) : null; foreach (SpriteRenderer r in transform.GetComponentsInChildren<SpriteRenderer>(true)) { if (r.name == "head") { if (pak_armor != null) { switch (pak_armor.option) { case SHOW_OPTION.HIDE_FACE: r.sprite = null; break; case SHOW_OPTION.SHOW_HAIR: r.sprite = pak_unit != null ? pak_unit.sprite_face_normal : null; break; case SHOW_OPTION.NONE: default: r.sprite = pak_unit != null ? pak_unit.sprite_face_equiped : null; break; } } else { r.sprite = pak_unit != null ? pak_unit.sprite_face_normal : null; } } else if (r.name == "eye_normal") { if (pak_armor != null && pak_armor.option == SHOW_OPTION.HIDE_FACE) { r.sprite = null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_eye_normal == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_eye_normal : null; } else { r.sprite = null; } r.color = pak_unit != null ? pak_unit.eye_color : Color.white; } else if (r.name == "eye_damage") { if (pak_armor != null && pak_armor.option == SHOW_OPTION.HIDE_FACE) { r.sprite = null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_eye_damage == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_eye_damage : null; } else { r.sprite = null; } r.color = pak_unit != null ? pak_unit.eye_color : Color.white; } else if (r.name == "arm-back") { // color if (pak_armor != null) { r.color = pak_armor.arm_color; } else { r.color = pak_unit != null ? pak_unit.arm_color : Color.white; } // sprite if (pak_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_arm_main == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_arm_main == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_arm_main : null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_arm_main == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_arm_main : null; } else { r.sprite = null; } } else if (r.name == "arm-front") { // color if (pak_armor != null) { r.color = pak_armor.arm_color; } else { r.color = pak_unit != null ? pak_unit.arm_color : Color.white; } // sprite if (pak_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_arm_sub == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_arm_sub == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_arm_sub : null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_arm_sub == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_arm_sub : null; } else { r.sprite = null; } } else if (r.name == "body") { if (part_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_body == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_body == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_body : null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_body == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_body : null; } else { r.sprite = null; } } else if (r.name == "glove_back") { // color if (pak_armor != null) { r.color = pak_armor.glove_color; } else { r.color = pak_unit != null ? pak_unit.glove_color : Color.white; } // sprite if (pak_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_glove_main == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_glove_main == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_glove_main : null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_glove_main == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_glove_main : null; } else { r.sprite = null; } } else if (r.name == "glove_front") { // color if (pak_armor != null) { r.color = pak_armor.glove_color; } else { r.color = pak_unit != null ? pak_unit.glove_color : Color.white; } // sprite if (pak_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_glove_sub == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_glove_sub == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_glove_sub : null; } else if (part_unit != null) { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_glove_sub == null) temp_pak = part_unit.GetUnit(0); r.sprite = temp_pak != null ? temp_pak.sprite_glove_sub : null; } else { r.sprite = null; } } else if (r.name == "leg_0") { if (part_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_leg0 == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_leg0 == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_leg0 : null; } else { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_leg0 == null) temp_pak = part_unit != null ? part_unit.GetUnit(0) : null; r.sprite = temp_pak != null ? temp_pak.sprite_leg0 : null; } } else if (r.name == "leg_1") { if (part_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_leg1 == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_leg1 == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_leg1 : null; } else { PackageData_Unit temp_pak = pak_unit; if (temp_pak == null || temp_pak.sprite_leg1 == null) temp_pak = part_unit != null ? part_unit.GetUnit(0) : null; r.sprite = temp_pak != null ? temp_pak.sprite_leg1 : null; } } else if (r.name == "helm") { r.sprite = pak_armor != null ? pak_armor.sprite_helm : null; } else if (r.name == "neck") { r.color = pak_armor != null ? pak_armor.arm_color : Color.white; if (part_armor != null) { PackageData_Armor temp_pak = pak_armor; if (temp_pak == null || temp_pak.sprite_neck == null) temp_pak = part_armor.GetArmor(0, Info.armor_color); if (temp_pak == null || temp_pak.sprite_neck == null) temp_pak = part_armor.GetArmor(0, 0); r.sprite = temp_pak != null ? temp_pak.sprite_neck : null; } else { r.sprite = null; } } else if (r.sprite != null && r.sprite.name == "weapon_back") { _set_sprite(r, pak_main != null ? pak_main.sprite_weapon : null); } else if (r.sprite != null && r.sprite.name == "weapon_front") { _set_sprite(r, pak_sub != null ? pak_sub.sprite_weapon : null); } else if (r.sprite != null && r.sprite.name == "bow_0") { if (pak_main == null) { r.enabled = false; } else { Texture2D temp_texture = pak_main.sprite_weapon.texture; Sprite new_sprite = Sprite.Create(temp_texture, new Rect(0.5f * temp_texture.width, 0, 0.5f * temp_texture.width, temp_texture.height), new Vector3(0.5f, 0.5f), r.sprite.pixelsPerUnit); r.enabled = true; r.sprite = new_sprite; r.sharedMaterial.mainTexture = pak_main.sprite_weapon.texture; r.sprite.name = "bow_0"; } } else if (r.sprite != null && r.sprite.name == "bow_1") { if (pak_main == null) { r.enabled = false; } else { Texture2D temp_texture = pak_main.sprite_weapon.texture; Sprite new_sprite = Sprite.Create(temp_texture, new Rect(0, 0, 0.5f * temp_texture.width, temp_texture.height), new Vector3(0.5f, 0.5f), r.sprite.pixelsPerUnit); r.enabled = true; r.sprite = new_sprite; r.sharedMaterial.mainTexture = pak_main.sprite_weapon.texture; r.sprite.name = "bow_1"; } } else if (r.name == "cape") { r.sprite = pak_wing != null ? pak_wing.sprite_wing : null; } } _fix_sprite_property(); SetOrder(Info.order); }
public void UpdateView(Texture2D _texture) { InitMaterial(); m_unit = DevEngine.Instance.GetPackage_Unit(Info.unit_part, Info.unit_index); m_main_weapon = DevEngine.Instance.GetPackage_Weapon(Info.main_weapon_part, Info.main_weapon_index); m_sub_weapon = DevEngine.Instance.GetPackage_Weapon(Info.sub_weapon_part, Info.sub_weapon_index); m_wing = DevEngine.Instance.GetPackage_Wing(Info.wing_part, Info.wing_index); m_unit_pak = DevEngine.Instance.GetPackage(Info.unit_part); m_main_weapon_pak = DevEngine.Instance.GetPackage(Info.main_weapon_part); m_sub_weapon_pak = DevEngine.Instance.GetPackage(Info.sub_weapon_part); _fix_sprite_property(); this.SetMaterialTexture(_texture); }