Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Managed Plugins Docs

Discussion in 'Documentation' started by strattonbrazil, Nov 24, 2015.

  1. strattonbrazil

    strattonbrazil

    Joined:
    Nov 24, 2015
    Posts:
    1
    Is the doc for managed plugin development up to date?

    http://docs.unity3d.com/Manual/UsingDLL.html

    I tried following the steps, but get an error "A namespace can only contain types and namespace declarations".

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3. using DLLTest;
    4.  
    5. void Start () {
    6.     MyUtilities utils = new MyUtilities();
    7.     utils.AddValues(2, 3);
    8.     print("2 + 3 = " + utils.c);
    9. }
    10.  
    11. void Update () {
    12.     print(MyUtilities.GenerateRandom(0, 100));
    13. }
    Looking online it seems like this code needs to be in a class or something (I would suspect such based on my basic C# knowledge, but am trying to follow the docs). I can wrap it in a MonoBehavior to get it to compile and run, but it doesn't do anything.
     
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    I am no expert... but the UsingDLL page shows you how you create the DLLTest. When you use this from inside your Unity application you'll need a normal Unity project. In your code example you miss a correctly arranged script. In your code example you miss out the way that a script is set up:

    Code (csharp):
    1. public class Blah : MonoBehaviour {
    2.   void Start () {
    3.   }
    4.   void Update () {
    5.   }
    6. }