Search Unity

Extensions methods in dlls arn't recognized by unity or monodevelop

Discussion in 'Scripting' started by BenZed, Mar 27, 2015.

  1. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    I've got a dll i've created from a series of useful helper classes I've accumulated since starting with unity:

    Code (CSharp):
    1. //Abbreviated for the sake of example
    2. namespace UnityEngine.Extensions {
    3.  
    4.     public static class KinematicExtensions {
    5.    
    6.         public static Vector2 PointOnCircle(this Vector2 origin, float radius, float angle) {
    7.  
    8.             float x = radius * Mathf.Cos (angle * Mathf.Deg2Rad) + origin.x;
    9.             float y = radius * Mathf.Sin (angle * Mathf.Deg2Rad) + origin.y;
    10.  
    11.             return new Vector2(x,y);
    12.  
    13.         }
    14.    
    15.     }
    16.  
    17. }
    But after I've dragged the .dll into the project files MonoDevelop and Unity can't recognize Extension Methods:

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Extensions;
    3.  
    4. public class Test : MonoBehaviour {
    5.    
    6.     void Start() {
    7.  
    8.         var test = Vector2.zero;
    9.         var angle = test.AbsoluteAngle(Vector2.up); // Doesn't work
    10.         var otherAngle = KinematicExtensions.AbsoluteAngle(test, Vector2.up);// Also doesn't work
    11.  
    12.   }
    13.  
    14. }
    15.  
    but everything else inside the dll is. Even strange is despite the fact that they both spit errors, they're not shown as red in mono-develop and autocomplete still works on them.

    I've tried adding the dll as a reference in mono-develop as well, this doesn't seem to do anything.

    Anyone have any clues? Problem present in Unity 4.6.3 and 5
     
  2. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
  3. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    the Bumpening
     
  4. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Code (csharp):
    1. using UnityEngine.Extensions;
     
  5. BenZed

    BenZed

    Joined:
    May 29, 2014
    Posts:
    524
    Yes. I am.

    As I've said, I dragged the .dll into the project files MonoDevelop and Unity can't recognize Extension Methods. Everything else inside the dll works fine. Class instances and draggable MonoBehaviours. Even stranger is that despite the fact that extension methods spit errors, they're not shown as red in mono-develop and autocomplete still works on them.
     
  6. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    My bad, I skimmed your first post too quickly :oops: