// ################################################################################## // ################################################################################## // instantiate prefab // ################################################################################## GameObject Instantiate_Selection_Element_Prefab(UI_Helicopter_Or_Scenery_Selection ui_selection, ref int prefabs_vertical_position_on_scroll_view_ui) { GameObject prefab_instance = Instantiate(ui_selection.ui_prefab_selection); prefab_instance.transform.SetParent(ui_selection.ui_scroll_view_content, true); prefab_instance.transform.localScale = new Vector3(1, 1, 1); prefab_instance.transform.localPosition = new Vector3(10, -prefabs_vertical_position_on_scroll_view_ui, 0); prefabs_vertical_position_on_scroll_view_ui += 150; return(prefab_instance); }
// ################################################################################## #endregion // ################################################################################## // IIIIIIIIII iiii tttt // I::::::::I i::::i ttt:::t // I::::::::I iiii t:::::t // II::::::II t:::::t // I::::Innnn nnnnnnnn iiiiiiittttttt:::::ttttttt // I::::In:::nn::::::::nn i:::::it:::::::::::::::::t // I::::In::::::::::::::nn i::::it:::::::::::::::::t // I::::Inn:::::::::::::::n i::::itttttt:::::::tttttt // I::::I n:::::nnnn:::::n i::::i t:::::t // I::::I n::::n n::::n i::::i t:::::t // I::::I n::::n n::::n i::::i t:::::t // I::::I n::::n n::::n i::::i t:::::t tttttt // II::::::IIn::::n n::::ni::::::i t::::::tttt:::::t // I::::::::In::::n n::::ni::::::i tt::::::::::::::t // I::::::::In::::n n::::ni::::::i tt:::::::::::tt // IIIIIIIIIInnnnnn nnnnnniiiiiiii ttttttttttt // ##################################################################################s #region initialize // ################################################################################## // Use this for initialization // ################################################################################## // is called by Start() in main partial class file void UI_Initialize_Selection_UI(Ui_Selection_Type ui_Selection_Type) { UI_Helicopter_Or_Scenery_Selection ui_selection = new UI_Helicopter_Or_Scenery_Selection(); string type_setup = null; if (ui_Selection_Type == Ui_Selection_Type.helicopter) { type_setup = "Helicopter"; } if (ui_Selection_Type == Ui_Selection_Type.scenery) { type_setup = "Scenery"; } ui_selection.ui_scroll_view_content = ui_canvas.transform.Find("UI Info Menu " + type_setup + " Selection/List Panel/Scroll View/Viewport/Content"); ui_selection.ui_scroll_view_scrollbar = ui_canvas.transform.Find("UI Info Menu " + type_setup + " Selection/List Panel/Scroll View/Scrollbar Vertical").GetComponent <Scrollbar>(); ui_selection.ui_scroll_view_scrollbar.value = 1f; ui_selection.ui_toggle_show_only_favourites = ui_canvas.transform.Find("UI Info Menu " + type_setup + " Selection/Toggle_Only_Favourites").GetComponent <Toggle>(); // seleted object from list ui_selection.ui_toggle_show_only_favourites.isOn = PlayerPrefs.GetInt("SavedSetting____" + type_setup + "____Toggle_Show_Only_Favourites", 0) == 0 ? false : true; ui_selection.ui_toggle_show_only_favourites.onValueChanged.AddListener(delegate { Listener_UI_Toggle_Show_Only_Favourites_OnValueChanged(ui_selection.ui_toggle_show_only_favourites, ui_Selection_Type); }); ui_selection.ui_prefab_selection = (GameObject)Resources.Load("Prefabs/UI_Selection_Panel", typeof(GameObject)); if (ui_Selection_Type == Ui_Selection_Type.helicopter) { ui_helicopter_selection = ui_selection; } if (ui_Selection_Type == Ui_Selection_Type.scenery) { ui_scenery_selection = ui_selection; } }
// ################################################################################## #endregion // ################################################################################## // dddddddd // UUUUUUUU UUUUUUUUIIIIIIIIII hhhhhhh d::::::dlllllll iiii // U::::::U U::::::UI::::::::I h:::::h d::::::dl:::::l i::::i // U::::::U U::::::UI::::::::I h:::::h d::::::dl:::::l iiii // UU:::::U U:::::UUII::::::II h:::::h d:::::d l:::::l // U:::::U U:::::U I::::I h::::h hhhhh aaaaaaaaaaaaa nnnn nnnnnnnn ddddddddd:::::d l::::l iiiiiiinnnn nnnnnnnn ggggggggg ggggg // U:::::D D:::::U I::::I h::::hh:::::hhh a::::::::::::a n:::nn::::::::nn dd::::::::::::::d l::::l i:::::in:::nn::::::::nn g:::::::::ggg::::g // U:::::D D:::::U I::::I h::::::::::::::hh aaaaaaaaa:::::an::::::::::::::nn d::::::::::::::::d l::::l i::::in::::::::::::::nn g:::::::::::::::::g // U:::::D D:::::U I::::I h:::::::hhh::::::h a::::ann:::::::::::::::nd:::::::ddddd:::::d l::::l i::::inn:::::::::::::::ng::::::ggggg::::::gg // U:::::D D:::::U I::::I h::::::h h::::::h aaaaaaa:::::a n:::::nnnn:::::nd::::::d d:::::d l::::l i::::i n:::::nnnn:::::ng:::::g g:::::g // U:::::D D:::::U I::::I h:::::h h:::::h aa::::::::::::a n::::n n::::nd:::::d d:::::d l::::l i::::i n::::n n::::ng:::::g g:::::g // U:::::D D:::::U I::::I h:::::h h:::::h a::::aaaa::::::a n::::n n::::nd:::::d d:::::d l::::l i::::i n::::n n::::ng:::::g g:::::g // U::::::U U::::::U I::::I h:::::h h:::::ha::::a a:::::a n::::n n::::nd:::::d d:::::d l::::l i::::i n::::n n::::ng::::::g g:::::g // U:::::::UUU:::::::U II::::::II h:::::h h:::::ha::::a a:::::a n::::n n::::nd::::::ddddd::::::ddl::::::li::::::i n::::n n::::ng:::::::ggggg:::::g // UU:::::::::::::UU I::::::::I h:::::h h:::::ha:::::aaaa::::::a n::::n n::::n d:::::::::::::::::dl::::::li::::::i n::::n n::::n g::::::::::::::::g // UU:::::::::UU I::::::::I h:::::h h:::::h a::::::::::aa:::a n::::n n::::n d:::::::::ddd::::dl::::::li::::::i n::::n n::::n gg::::::::::::::g // UUUUUUUUU IIIIIIIIII hhhhhhh hhhhhhh aaaaaaaaaa aaaa nnnnnn nnnnnn ddddddddd dddddlllllllliiiiiiii nnnnnn nnnnnn gggggggg::::::g // g:::::g // gggggg g:::::g // g:::::gg gg:::::g // g::::::ggg:::::::g // gg:::::::::::::g // ggg::::::ggg // ################################################################################## gggggg #region ui_handling // ################################################################################## // update every parameter prefab on ui // ################################################################################## public void UI_Update_Helicopter_Or_Scenery_Selection_Panel_UI(Ui_Selection_Type ui_Selection_Type, UI_Helicopter_Or_Scenery_Selection ui_selection) { // remove all children form Scroll View Content UI foreach (Transform child in ui_selection.ui_scroll_view_content) { GameObject.Destroy(child.gameObject); } // helicopter: get information xml and fill list on ui if (ui_Selection_Type == Ui_Selection_Type.helicopter) { helicopter__prefabs_vertical_position_on_scroll_view_ui = 0; int selection_id = 0; foreach (Transform each_helicopter in helicopters_available.transform) { string selection_name = each_helicopter.name; // only show helicopter in list, which are marked as favourit when filter toggle "ui_toggle_show_only_favourites.isOn == true" is active if (!(ui_selection.ui_toggle_show_only_favourites.isOn == true && (PlayerPrefs.GetInt("SavedSetting____" + selection_name + "____is_helicopter_favourite", 0) == 0 ? false : true) == false)) { // import xml helicopter_selection_content = new stru_selection_content(); TextAsset txtAsset = (TextAsset)Resources.Load(each_helicopter.name + "_information_file", typeof(TextAsset)); if (txtAsset != null) { helicopter_selection_content = Common.Helper.IO_XML_Deserialize <stru_selection_content>(txtAsset); } //Common.Helper.IO_XML_Serialize(txtAsset,"c:/Temp/test1.txt"); // create ui-prefab instance GameObject prefab_instance = Instantiate_Selection_Element_Prefab(ui_selection, ref helicopter__prefabs_vertical_position_on_scroll_view_ui); // setup instanced prefab (settings and listeners) Setup_Selection_Element_Instance(ref prefab_instance, ui_Selection_Type, selection_id, selection_name, helicopter_selection_content, null); } selection_id++; } // resize rect-transform area now to fit all UI-prefabs into ui_selection.ui_scroll_view_content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, helicopter__prefabs_vertical_position_on_scroll_view_ui + 20); } // scenery: get information xml and fill list on ui if (ui_Selection_Type == Ui_Selection_Type.scenery) { scenery__prefabs_vertical_position_on_scroll_view_ui = 0; for (int selection_id = 0; selection_id < list_skymap_paths.Count; selection_id++) { string selection_name = list_skymap_paths[selection_id].name; // only show scenery in list, which are marked as favourit when filter toggle "ui_toggle_show_only_favourites.isOn == true" is active if (!(ui_selection.ui_toggle_show_only_favourites.isOn == true && (PlayerPrefs.GetInt("SavedSetting____" + selection_name + "____is_scenery_favourite", 0) == 0 ? false : true) == false)) { // import xml scenery_selection_content = new stru_selection_content(); if (File.Exists(list_skymap_paths[selection_id].fullpath_information_file)) { scenery_selection_content = Common.Helper.IO_XML_Deserialize <stru_selection_content>(list_skymap_paths[selection_id].fullpath_information_file); } //Common.Helper.IO_XML_Serialize(scenery_selection_content, "c:/Temp/test2.txt"); // create ui-prefab instance GameObject prefab_instance = Instantiate_Selection_Element_Prefab(ui_selection, ref scenery__prefabs_vertical_position_on_scroll_view_ui); // setup instanced prefab (settings and listeners) Setup_Selection_Element_Instance(ref prefab_instance, ui_Selection_Type, selection_id, selection_name, scenery_selection_content, list_skymap_paths[selection_id]); } } // resize rect-transform area now to fit all UI-prefabs into ui_selection.ui_scroll_view_content.GetComponent <RectTransform>().sizeDelta = new Vector2(0, scenery__prefabs_vertical_position_on_scroll_view_ui + 20); } }