File Explorer and Unity

Card Creation

One of the most interesting parts of this capstone project is allowing users to create cards that are then saved to a database and used to build custom playing decks. Naturally, I volunteered for this assignment. Most of the card creation system implementation is straight forward. I set up text information for card statistics and flavor text information. I added images that change based on a card’s characteristics. This information is saved via an HTTP request to the server (which part is still under construction).

However, there was one very difficult requirement to get working. The project specification allowed a user to upload an image and then use that image in the card design. Initially, I thought this would be something readily built into Unity. I was wrong. Very wrong.

There is a lot of complexity surrounding this one little command:

Uploading Images

Uploading local images in Unity during a game’s run time is surprisingly complex considering this is a common Window’s task. The complexity must be why so many games allow users to pick skins from a predefined list. Accessing predefined information in Unity is pretty straight forward. Simply access the “Resources” folder and load the asset into the project, assigning the loaded asset to the desired UI element. You cannot use the “Resources” folder approach if the information needed is not known before compiling the program.

Unity has logical reasons for making loading local assets a difficult task. First, Unity is designed to support multiple platforms. The different platforms do not share a uniform System.IO object, meaning that the windows-type file I/O is not a universal solution (c# – Attempting to upload .png file to web directory – Stack Overflow). Second, there are concerns about copyright and needing to monitor what images are uploaded. I can see why this a concern for commercial developers. The concern is almost zero for a class project.

Non-Solutions

I was surprised that the Unity community forums contained only a few good ideas on how to solve this issue. Most of the answers I found are examples of how to work with files when you already know the file location. If you know the location, you can use the UnityWebRequest object to load the file and use it in the project. Despite the name, the UnityWebRequest object can read local files across platforms.

Other suggestions used the deprecated www object in combination with the Unity EditorUtility. For example: Unity – Manual: Uploading raw data to an HTTP server (PUT) (unity3d.com). These solutions used Unity’s EditorUtility to open a file and read the information using www tools. This works great…in theory. Unfortunately, EditorUtility only works in editing mode and will not work with deployed code, making the solution impractical for the final product. The real answer is: “There is no built in file browser for the player, so you would need to roll your own using the .NET frameworks classes for file system access” How do I let the user select a local file for my application to use? – Unity Answers

The Real Answer

Frustrating, right? At this point, I became very worried about the project’s scope. Writing a new .NET application seemed like a capstone project by itself. I didn’t think the team could create both a new application and develop a game. Frustrated, I was about to move on to a different part of the project. Luckily, I remembered the unity asset store. Eureka!

Searching the store finds a few different option. The free one I used is:

https://assetstore.unity.com/packages/tools/gui/runtime-file-browser-113006

This plugin allows you to load multiple files, save files, and specify search criteria. Likely overkill for what I need, but the price sold me.

Getting It Working

When I first imported the plugin, I could not get the tool to work. This was my mistake, and I failed to import the C# script into the project library after importing the package from the asset store. This failure caused Unity to replicate a similar script in the resources location and crash when run, stating that two assets were detected with the same name. To get the plugin working correctly, I needed to import the plugin into my C# code before testing. I also had to delete the created file. After fixing my installation issues, the plugin worked great and included very comprehensive user documentation. You can see it working below.

Working File Explorer

Yay! The code to make this work is a small modification on the example implementation.

	private void GetPath()
	{
		FileBrowser.SetFilters(false, new FileBrowser.Filter("Images", ".jpg", ".png"));
		FileBrowser.SetDefaultFilter(".jpg");
		FileBrowser.SetExcludedExtensions(".lnk", ".tmp", ".zip", ".rar", ".exe");
		FileBrowser.AddQuickLink("Users", "C:\\Users", null);


		FileBrowser.ShowLoadDialog( ( paths ) => { path = paths[0]; },
								   () => { Debug.Log( "Canceled" ); },
								   FileBrowser.PickMode.Folders, false, null, null, "Select Folder", "Select" );

		// Coroutine example
		StartCoroutine(ShowLoadDialogCoroutine());
	}

Conclusion

In retrospect, the first place I should have looked for an answer to my problem is the asset store. Being new to unity, the idea didn’t occur to me. I thought of the asset store as a place to buy sprites and images, not useful tools. Turns out the asset store is a real boon to the community and filled with useful items. The biggest takeaway from this headache is that when you get stuck, look at the asset store. There’s a good chance someone already solved your problem.

LucidCharts: A Love Letter

In this blog, I wanted to share one of my favorite pieces of software, LucidCharts. I use LucidCarts quite a bit for work, and I find that it’s one of the best ways to coordinate across large teams. LucidCharts helps me organize my projects and trains of thought.

Apologies to Elizabeth Barrett Browning on this parody of her sonnet. To break up the poem, I included images of a few projects I’ve done in LucidCarts over the course of my tenure at OSU.  

The Poem

LucidCharts, how do I love thee? Let me count the ways.

I love thee because of thy ERDs and UML diagrams, which are so easy to create.

ERD for the gaming project

My soul can reach (to LucidCharts), when feeling like I need to start mapping out a project.

Laying out a personal project

For the end of hand-drawn images and the ideal packages that contain all the icons I need.

Example of how many icons exist just for users

Most quiet need, whether I’m working on OSU homework by sun or candle-light (mostly candle-light).

I love thee freely, as I strive to get my project plan just right.

I love thee purely, as you turn diagrams into creative layouts.

Design of Card Creator

I love thee with the passion because it’s so easy to use,

Compared to my old griefs with my childhood’s faith in spreadsheets.

Some homework was so much easier in LucidCharts

I love thee with a love I seemed to lose using Microsoft Visio.

Especially with my lost files because of failures to save, I love thee with your cloud-based saving,

And the lack of tears when doing all my homework; and if my instructor choose,

I shall but love thee better after this class ends.

The End

I really like LucidCarts.

You can find the real poem by Elizabeth Barrett Browning here: How Do I Love Thee, Let Me Count The Ways: Sonnet Analysis (nosweatshakespeare.com)

Ready…Set…Go!

For me, the hardest part of any project is getting started. New projects always feel like you’re lost in a big world with every direction leading to new options. The best way to get somewhere interesting is just start moving.

One of the most interesting elements of this class is the lack of a set directions on how our team accomplishes our goal. Previous classes set forth the required language, the desired outcome, and the specifics on how you implemented that outcome. With CS492, everything changes. Suddenly, you have a wide selection of tools and a project where “complete” is left to the imagination. This is both exciting and terrifying!

Just Start Already!

The best way I have found to overcome the anxiety that always seems to accompany new experiences is to just start moving. Type out notes. Sketch a framework. Do something or anything to just start moving! Starting early often means moving in the wrong direction. However, the act of starting starts the gears in motion, allowing me break through the nervousness and focus on the problem.

For my capstone project, I applied this practice by writing out what I wanted to accomplish, consolidating the project outline provided online with what I thought sounded interesting. started by writing out what I hoped to accomplish. I also watched several videos on how to code in unity and set up the repository in Github. These small acts made me feel more confident in the undertaking, got things organized, and was fun to do.

The Second Step

Despite my initial nerves calmed by the act of starting, I still found the project very overwhelming. The project just seems so big! To further “just get started”, I diagrammed a possible flow/architecture for the project. This is the diagram I came up with:

A possible project flowchart

Sketching out diagrams like this help give you direction and help solidify what you want to accomplish.

Rough diagrams like this help me visualize the various steps along the way, breaking the project into more manageable chunks. They also give me direction. Even though the team hasn’t scoped the size or efforts of these chunks, diagrams can help split up an huge undertaking into smaller, and doable, steps.

Added Benefits

One added benefit of starting on a project is the process of starting might find holes in your thought planning process. For example, putting together the flow diagram made me realize that the team never discussed a very important part of the project in planning – how do you actually play the game! The project’s main goal is to allow users to create customizable card games, but we need a simple set of modifiable rules that a computer can follow when becoming an opponent. We are working on creating these now, but thank goodness for staring into the project! 

Conclusion

For me, jumping straight into the work is the best way to start a project , feet first. Even if the project initially feels overwhelming, the act of starting helps calm my nerves, organizes the process, and allows me to better see the project’s bigger picture. Just doing something towards the end-goal makes big tasks seem smaller.

A Project of Cards

Welcome to the Capstone Gaming blog! I’m glad you stopped by! In this first post, I’m excited to introduce my new blog and what I’m hoping to accomplish during CS467. Although this blog will usually focus on my team’s capstone project, for the first post I wanted to share why I am passionate about this project and document a few thoughts on what I hope the project end-state looks like.  

My Obsession

When perusing the list of available projects, one particular request immediately caught my eye as a unique opportunity. To ensure I captured the projected, I needed two like-minded individuals. Luckily, using the class discussion list, I found two individuals who shared my immediate enthusiasm for this project. We quickly formed a team and signed up for the trading card project, a project where we will create a tool to generate trading cards. Sharing two pictures should fully explain why I am excited about this project:

I guess I have a few games
Okay…. a lot of games.

I own a lot of games. A LOT of games. What’s not shown is that this collection extends onto another shelf. I love games. 

Existing Tools

I love games so much that I spent my summer designing and creating a new game. My game is a card-centric endeavor that I’m hoping hits kickstart next year. Because I needed an extensive set of cards, I spent a significant amount of time looking at the current market for card-generation software. Turns out, the market is really small, consisting of only a single dedicated solution called nanDeck (nanDECK | Code your graphics). Other card designers recommended using Illustrator or Adobe. However, I believe nanDeck is the only software designed solely for making playing cards.

Nandeck is a pretty good open-source tool with a comprehensive. You can add images, replace strings with icons, set the number of cards generated, and import CSV data. Best of all, Nandeck is free to use.

Although the generally robust, the software’s bugs can result in critical failures when trying to print cards. The worst bug, a pointer error, renders the software unusable when encountered. The software also looks dated and needs a serious UX upgrade.

Defining Success

I’m looking forward to seeing the client requirements, but I hope that a successful project will include connecting to a datasource, allowing customization of layouts and display of text and images. The program will need an option to print the cards and save them to a file for future editing. Hopefully, the feature set will be rich enough that I can test the software using my own game. 

If you can’t tell, I’m excited to get started and work on this project with a great team. The team will have a lot of fun working together and creating software that will have a big impact on this niche market. We will at least have fun discovering how to actually build this software. I can’t wait to share with you what I learn and the progress our team makes.  

See you next blog post!