- Home /
I can't use some codes in dll file?
I try to create an dll file and i have to use the following codes in it 1.float Val= PlayerPrefs.GetFloat ("value"); 2.Time.deltaTime 3.Input.GetMouseButtonDown. it gives an error "The name "PlayerPrefs" does not exist in current context". I am new for unity.
Answer by CHPedersen · Apr 28, 2014 at 07:29 AM
The script stubs created by Unity's editor have "using UnityEngine;" added to their top. But in your dll, the namespace "UnityEngine" is not automatically included. So it doesn't know what PlayerPrefs is, because that's a static class which is a member of the UnityEngine namespace.
Add "using UnityEngine;" to the top of those of your classes that use it in the DLL.
working fine but when i use "GetComponent" code it shows the same error. Example: GetComponent().mesh.bounds; transform.GetComponent
That's a different question. Post a new question with (more complete) sample code. :)
Here is my code
Bounds bounds = GetComponent().mesh.bounds;
Vector4 v3Center = transform.GetComponent().center;