public static MenuInfo MakeBGObjectMenu(PhotoBGObjectData dat)
        {
            MenuInfo menu = new MenuInfo();

            menu.modelType = ModelType.BGObject;
            menu.modelName = dat.create_prefab_name;
            menu.menuName  = dat.name;
            return(menu);
        }
        // override Object loaded from resources with Object created from asset bundle if bundle with same name exists
        public static void PhotBGObj_Instantiate_Ext(PhotoBGObjectData self, ref UnityEngine.Object @object)
        {
            string name = Path.GetFileName(self.create_prefab_name.ToLower());

            if ((GameUty.BgFiles.ContainsKey(name + ".asset_bg")))
            {
                @object = GameMain.Instance.BgMgr.CreateAssetBundle(name);
            }
        }
Beispiel #3
0
            public void UpdateMenusBGObject()
            {
                buttons.Clear();

                if (PhotoBGObjectData.data == null)
                {
                    PhotoBGObjectData.Create();
                }

                foreach (PhotoBGObjectData data in PhotoBGObjectData.data)
                {
                    Texture2D iconTexture = new Texture2D(1, 1);
                    iconTexture.SetPixel(0, 0, new Color32(1, 1, 1, 1));
                    iconTexture.Apply();
                    CustomTextureButton button = new CustomTextureButton(iconTexture);
                    string modelName           = String.Copy(data.name);

                    button.Text = modelName;

                    MenuInfo menuCopy = MenuInfo.MakeBGObjectMenu(data);
                    button.Click += (o, e) => func(menuCopy);
                    buttons.Add(button);
                }
            }
Beispiel #4
0
        // add data from *phot_bg_object_list*.nei files to PhotoBGObjectData.bg_data_
        public static void PhotoBGobjext()
        {
            string[] BgObj_list = null;

            BgObj_list = GameUty.FileSystemMod.GetList("PhotoBG_OBJ_NEI", AFileSystemBase.ListType.AllFile);


            if (BgObj_list == null || 0 == BgObj_list.Length)
            {
                return;
            }


            foreach (string str in BgObj_list)
            {
                string nei_filename = Path.GetFileName(str);


                if (Path.GetExtension(nei_filename) == ".nei" && nei_filename != "phot_bg_object_list.nei")
                {
                    using (AFileBase aFileBase = GameUty.FileSystemMod.FileOpen(nei_filename))
                    {
                        using (CsvParser csvParser = new CsvParser())
                        {
                            if (csvParser.Open(aFileBase))
                            {
                                for (int i = 1; i < csvParser.max_cell_y; i++)
                                {
                                    int num = 1;
                                    PhotoBGObjectData photoBGObjectData = new PhotoBGObjectData(); // this requires prepatched assembly to compile
                                    photoBGObjectData.id                       = 0;                // not sure if't necessary for id to actually have a value
                                    photoBGObjectData.category                 = csvParser.GetCellAsString(num++, i);
                                    photoBGObjectData.name                     = csvParser.GetCellAsString(num++, i);
                                    photoBGObjectData.create_prefab_name       = csvParser.GetCellAsString(num++, i);
                                    photoBGObjectData.create_asset_bundle_name = csvParser.GetCellAsString(num++, i);
                                    //assign id from rpefab/bundles string
                                    //this is done because save/load of objects in photomode is based on id
                                    if (!string.IsNullOrEmpty(photoBGObjectData.create_prefab_name))
                                    {
                                        photoBGObjectData.id = photoBGObjectData.create_prefab_name.GetHashCode();
                                    }
                                    else if (!string.IsNullOrEmpty(photoBGObjectData.create_asset_bundle_name))
                                    {
                                        photoBGObjectData.id = photoBGObjectData.create_asset_bundle_name.GetHashCode();
                                    }
                                    string check = csvParser.GetCellAsString(num++, i);
                                    if (String.IsNullOrEmpty(check) || GameUty.BgFiles.ContainsKey(photoBGObjectData.create_asset_bundle_name.ToLower() + ".asset_bg"))
                                    {
                                        PhotoBGObjectData.bg_data_.Add(photoBGObjectData);
                                    }
                                }
                            }
                            else
                            {
                                Debug.Log($"Skipping invalid file: Mod/{str}");
                            }
                        }
                    }
                }
            }
        }