Author Topic: Custom Object Creation problem  (Read 3889 times)

Knightmare

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Custom Object Creation problem
« on: January 15, 2015, 01:50:38 AM »
So, i've been playing around with this. Did what you suggest and what others state they do in the Custom Object Creation functions (1.8.0+) thread. However, I'm running into the issue that I get an error upon Resources.Load with CreateEx. If I normally call it through Create and merely point to what I normally write in Resources.Load(...), its fine like "prefab location". I'm getting this error,

Quote
[TNet] The game object was not found in the TNManager's list of objects. Did you forget to add it?
with this sample code,

  1. GameObject somePrefab = (GameObject)Resources.Load("somePrefabInResourcesFolder");
  2.  GameUnitManager.Create(somePrefab,somePos,someRot,someUnityName,pers);
  3.  

Quote
TNet supports both -- so you don't need to add objects to TNManager's list if you want to create them by their prefab's name instead (assuming you placed them in the Resources folder, of course).

What am I doing wrong to create a prefab using reousrces.load and using a custom CreateEx and RCC? It works for everything but CreateEx as it produces errors that I should add it to the list. Once I do, it's fine but I don't want to add every little prefab to it but rather have dynamic instantiation. Which you state is possible doing it this way, which still creates the object and everything but produces the error. I'm using the example code above to just create a simple object with a name like your example GameUnitManager.Create

I've added the script to the TNManager and I have tried to even call AddRCCs too. It seems to be all working fine but the output of the error but I'm not sure if its because of the instantiation code via OnCreate like any other non-TN GameObject.
« Last Edit: January 15, 2015, 02:25:13 AM by Knightmare »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Custom Object Creation problem
« Reply #1 on: January 15, 2015, 09:06:44 PM »
You can't pass game objects like that. TNManager.Create can either accept a game object that's a part of your TNManager class, or just a resource path.

What your function should be like instead is:

GameUnitManager.Create("somePrefabInResourcesFolder", somePos, someRot, someUnityName, pers);

Knightmare

  • Newbie
  • *
  • Thank You
  • -Given: 2
  • -Receive: 0
  • Posts: 8
    • View Profile
Re: Custom Object Creation problem
« Reply #2 on: January 16, 2015, 12:36:32 AM »
Thanks for the reply, I had actually solved it earlier just by merely using your RCCs with your basic TNManager.Create. The problem comes when using your example thread for Custom Object creation because you have with GameUnitManager's Create method has GameObject instead of String which you state in the reply. The create method had thrown me off since it wanted a GameObject and was called prefab so I just assumed that was the case.

So maybe change in that thread,
  1. static public void Create (string prefab, ...


and that did the trick. Otherwise, passing the string like you mentioned to the GameUnityManager.Create with it's parameter as a GameObject throws a compilation error for me but works fine when passed to the RCC for onCreate as a GameObject. Unless this GameObject method was meant for the list of objects listed on the TNManager? I'm just trying to put the pieces together.
« Last Edit: January 16, 2015, 01:02:17 AM by Knightmare »

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: Custom Object Creation problem
« Reply #3 on: January 18, 2015, 04:30:36 AM »
Yes, of course you would have to change the actual function to accept a string parameter. As I mentioned TNet works with both game objects and strings, and in most cases you will want to use strings exclusively. In Windward that's all I use.