Advertisement
Guest User

Untitled

a guest
Apr 16th, 2014
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 KB | None | 0 0
  1. public class MainObject //Note: Does not extend MonoBehaviour, the Update method is called manually from a MonoBehaviour Update.
  2. {
  3.     public class InnerBase {}
  4.         public class InnerMain : InnerBase
  5.         {
  6.             public void ChangePrimary()
  7.             {
  8.                 cInput.ChangeKey("Input", 1);
  9.             }
  10.     }
  11.     public class InnerTwo : InnerBase
  12.     {
  13.         public void SomethingUnrelated(){} //Including this to mimic the structure.
  14.     }
  15.  
  16.     public InnerBase[] objects; //Note: Not putting the declaration in, but this is declared in a constructor in the actual code.
  17.     public int index;
  18.  
  19.     public void Update()
  20.     {
  21.         if(!cInput.scanning)
  22.         {
  23.             if(cInput.GetKeyDown("Select"))
  24.             {
  25.             try
  26.             {
  27.                 ((InnerTwo)objects[index]).SomethingUnrelated();
  28.             }
  29.             catch(IndexOutOfRangeException) { }
  30.             catch(InvalidCastException)
  31.             {
  32.                 try
  33.                 {
  34.                     ((InnerMain)objects[index]).ChangePrimary();
  35.                 }
  36.                 catch(InvalidCastException) { }
  37.             }
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement