Author Topic: Conditional  (Read 2417 times)

devomage

  • Sr. Member
  • ****
  • Thank You
  • -Given: 7
  • -Receive: 67
  • Posts: 250
    • View Profile
Conditional
« on: June 11, 2017, 02:30:57 AM »
I have a couple mono files where I'd like to use TNET if the user has TNET installed.  I cant seem to find an appropriate conditional within TNET.  What is the best way to deal with this?

Maybe like this?

  1. #if TNET_EXISTS
  2.    //TNET code
  3. #else
  4.    //code that doesnt require TNET
  5. #endif



ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Conditional
« Reply #1 on: June 18, 2017, 07:38:12 PM »
Pretty sure there is no way to have a package-specific #define, so you have to have your own project-specified #define set.

Keep in mind you don't need it if you use reflection instead. Just look at how I handled runtime code execution or look at TNet.TypeExtensions. You can use Invoke to call a method by its name same way Unity can do it with its MonoBehaviours, except this is much faster and works with everything.