/// <summary> /// Bind a GameObject to a C++ ObjectScriptable through its node name. /// </summary> /// <param name="nodeName">Name of the Node to bind.</param> public void bind(String nodeName) { if (nodeName == null) { throw new CKLBException("Impossible to bind with a null name."); } if (m_cppObject != IntPtr.Zero) { throw new CKLBException("This GameObject is already binded."); } NodeIterator nodeIterator = new NodeIterator(NativeManagement.getContextCounter(), NodeIterator.getRoot()); if (nodeIterator.find(nodeName)) { IntPtr cppObj = nodeIterator.getAsUITask().CppObject; uint nativeHandle = CKLBObjectScriptable_getScriptContext(cppObj); if (nativeHandle == NULLHANDLER) { NativeManagement.registerWrapper(cppObj, m_handle); m_cppObject = cppObj; doSetupCallbacks(); } else { throw new CKLBException("This C++ object is already wrapped."); } } else { throw new CKLBException("There is not any Node with this name."); } }
/// <summary> /// Associates the C++ to the C# GameObject. /// </summary> /// <param name='cppObj'> /// Cpp object. /// </param> internal void bind(IntPtr cppObj) { if (cppObj != IntPtr.Zero) { if (m_cppObject == IntPtr.Zero) { uint nativeHandle = CKLBObjectScriptable_getScriptContext(cppObj); // Is this object already bound ? if yes it must already have a Handle. if (nativeHandle == NULLHANDLER) { NativeManagement.registerWrapper(cppObj, m_handle); m_cppObject = cppObj; doSetupCallbacks(); } else { throw new CKLBException("This C++ object is already wrapped."); } } else { throw new CKLBException("This GameObject is already binded."); } } else { throw new CKLBException("Impossible to bind a null pointer (It can be a failure on Engine side while creating C++ instance)."); } }