Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MainObject //Note: Does not extend MonoBehaviour, the Update method is called manually from a MonoBehaviour Update.
- {
- public class InnerBase {}
- public class InnerMain : InnerBase
- {
- public void ChangePrimary()
- {
- cInput.ChangeKey("Input", 1);
- }
- }
- public class InnerTwo : InnerBase
- {
- public void SomethingUnrelated(){} //Including this to mimic the structure.
- }
- public InnerBase[] objects; //Note: Not putting the declaration in, but this is declared in a constructor in the actual code.
- public int index;
- public void Update()
- {
- if(!cInput.scanning)
- {
- if(cInput.GetKeyDown("Select"))
- {
- try
- {
- ((InnerTwo)objects[index]).SomethingUnrelated();
- }
- catch(IndexOutOfRangeException) { }
- catch(InvalidCastException)
- {
- try
- {
- ((InnerMain)objects[index]).ChangePrimary();
- }
- catch(InvalidCastException) { }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement