This is the multi-page printable view of this section.
Click here to print.
Return to the regular view of this page.
Start Using It
Drag and drop Generic Case Opening Panel into your Canvas.
Then right click on the newly created object in the hierarchy and select Prefab > Unpack.
(The Canvas Scaler settings in demo scene is 1280 x 720 Scale With Screen Size
if you want the exact same result.)
«Case Opening Visual Controller» script is responsible for filling the case with items, playing the opening animations, reporting the start and complete
events and customization settings.
The «Generic Case Controller» is the simple basis of any implementation you might want to do. It holds the main functionality.
It includes comments in each step in the script file and demo cases are a changed copy of it.
You can assign one of the demo case configs in the appropriate field and test if it’s working. I don’t recommend directly editing the script,
that’s why we are going to create ours.
1 - Create Your Own Controller
Copy
Create a script file on anywhere you are comfortable (outside of the package folder). Copy the contents of «Generic Case Controller»
and paste it on your own script.
Change the class name with your own and change the namespace with yours or completely remove it.
Rewire
We are going to delete the «Generic Case Controller» from our panel and add our new script.
Some fields gone missing now because we deleted the script.
- Drag and drop your case controller on inspector (not the actual file) to On Animation Start and On Animation Complete fields.
Then select the appropriate function from your controller from the dropdown.
- Select the Open Button from hierarchy and drop it on the Open Button field on your controller script.
- Click on the Open Button and drag Generic Case Opening Panel to button On Click field. Select your controller from the dropdown and
select OpenCase function.
- Select one of the pre-made configs for Case Config field for testing purposes.
- And test opening the case.
We should have a functioning case with our own editable script at this point. Try Debug.Logging something out on animation complete!
Next we are going to create our own case contents.
2 - Create Your Own Case Contents
Create a Case Item
You can inspect the items in Demo > Cases > (Select any) > Items for example.
Visual
Most effective way of creating a Case Item visual is actually creating it in the panel because width and height of the visual is
governed by the Grid Layout Group that is on the Strip Inner - Item Container.
Select Strip Inner - Item Container located in Generic Case Opening Panel from the hierarchy and add an UI Image to it.
Then duplicate it until you can see it in the panel.
Now do your decoration to it and maybe add some icons or text.
Script
Now we need to handle the script for the item.
Create a script for your item. Then inherit from CaseItemBase.
using SolClovser.CaseOpeningToolkit.Base;
public class YourCaseItem : CaseItemBase
{
}
Then add it to your item and save your item as a prefab. Don’t forget to clear the contents of Strip Inner - Item Container after doing this.
Config
We need to create a config file to store our case config.
Right click anywhere in the project window and select Create > Case Opening Toolkit > New Config.
Add your item to the filler items list in config. This list is used to populate the unimportant parts of the case such as the portion before your
actual items show up.
Then add a Probability Group to the list and add your item to Items in it. Raise the probability slider. It’s probability will be 100% because
it is the only item in the list.
Select your Case Config as the config for the panel. Now name your panel and save it as a prefab. Congratulations! You just created your first case.
3 - Testing Probabilities
After selecting the case config, you can press Test Spin and see the outcome of 1000 (or any amount) case openings in the logs.