- Home /
Ambiguous reference 'preview'
So I made a game in Unity before I updated to Unity 5. However, as I updated my project and Unity I ran into these errors and now my game won't run and I have no idea what the errors are asking of me. Anyone have any ideas on how to fix this?
Assets/Editor/Image Effects/CameraMotionBlurEditor.js(92,36): BCE0004: Ambiguous reference 'preview': CameraMotionBlurEditor.preview, UnityEditor.Editor.preview.
Assets/Editor/Image Effects/CameraMotionBlurEditor.js(93,9): BCE0004: Ambiguous reference 'preview': CameraMotionBlurEditor.preview, UnityEditor.Editor.preview.
NavMesh asset format has changed. Please rebake the NavMesh data
#pragma strict
@CustomEditor (CameraMotionBlur)
class CameraMotionBlurEditor extends Editor
{
var serObj : SerializedObject;
var filterType : SerializedProperty;
var preview : SerializedProperty;
var previewScale : SerializedProperty;
var movementScale : SerializedProperty;
var jitter : SerializedProperty;
var rotationScale : SerializedProperty;
var maxVelocity : SerializedProperty;
var minVelocity : SerializedProperty;
var maxNumSamples : SerializedProperty;
var velocityScale : SerializedProperty;
var velocityDownsample : SerializedProperty;
var noiseTexture : SerializedProperty;
var showVelocity : SerializedProperty;
var showVelocityScale : SerializedProperty;
var excludeLayers : SerializedProperty;
//var dynamicLayers : SerializedProperty;
function OnEnable () {
serObj = new SerializedObject (target);
filterType = serObj.FindProperty ("filterType");
preview = serObj.FindProperty ("preview");
previewScale = serObj.FindProperty ("previewScale");
movementScale = serObj.FindProperty ("movementScale");
rotationScale = serObj.FindProperty ("rotationScale");
maxVelocity = serObj.FindProperty ("maxVelocity");
minVelocity = serObj.FindProperty ("minVelocity");
maxNumSamples = serObj.FindProperty ("maxNumSamples");
jitter = serObj.FindProperty ("jitter");
excludeLayers = serObj.FindProperty ("excludeLayers");
//dynamicLayers = serObj.FindProperty ("dynamicLayers");
velocityScale = serObj.FindProperty ("velocityScale");
velocityDownsample = serObj.FindProperty ("velocityDownsample");
noiseTexture = serObj.FindProperty ("noiseTexture");
}
function OnInspectorGUI () {
serObj.Update ();
EditorGUILayout.LabelField("Simulates camera based motion blur", EditorStyles.miniLabel);
EditorGUILayout.PropertyField (filterType, new GUIContent("Technique"));
if (filterType.enumValueIndex == 3 && !(target as CameraMotionBlur).Dx11Support()) {
EditorGUILayout.HelpBox("DX11 mode not supported (need shader model 5)", MessageType.Info);
}
EditorGUILayout.PropertyField (velocityScale, new GUIContent(" Velocity Scale"));
if(filterType.enumValueIndex >= 2) {
EditorGUILayout.LabelField(" Tile size used during reconstruction filter:", EditorStyles.miniLabel);
EditorGUILayout.PropertyField (maxVelocity, new GUIContent(" Velocity Max"));
}
else
EditorGUILayout.PropertyField (maxVelocity, new GUIContent(" Velocity Max"));
EditorGUILayout.PropertyField (minVelocity, new GUIContent(" Velocity Min"));
EditorGUILayout.Separator ();
EditorGUILayout.LabelField("Technique Specific");
if(filterType.enumValueIndex == 0) {
// portal style motion blur
EditorGUILayout.PropertyField (rotationScale, new GUIContent(" Camera Rotation"));
EditorGUILayout.PropertyField (movementScale, new GUIContent(" Camera Movement"));
}
else {
// "plausible" blur or cheap, local blur
EditorGUILayout.PropertyField (excludeLayers, new GUIContent(" Exclude Layers"));
EditorGUILayout.PropertyField (velocityDownsample, new GUIContent(" Velocity Downsample"));
velocityDownsample.intValue = velocityDownsample.intValue < 1 ? 1 : velocityDownsample.intValue;
if(filterType.enumValueIndex >= 2) { // only display jitter for reconstruction
EditorGUILayout.PropertyField (noiseTexture, new GUIContent(" Sample Jitter"));
EditorGUILayout.PropertyField (jitter, new GUIContent(" Jitter Strength"));
}
}
EditorGUILayout.Separator ();
EditorGUILayout.PropertyField (preview, new GUIContent("Preview"));
if (preview.boolValue)
EditorGUILayout.PropertyField (previewScale, new GUIContent(""));
serObj.ApplyModifiedProperties();
}
}
Haven't played with 5 yet, so I may be way off. Perhaps re-importing your camera effects from the new Unity 5 standard assets release will solve this.
Otherwise, you may have to edit the script to qualify the ambiguous reference. Ambiguity occurs when two variables in the same scope share a name, and you must qualify them by including their class or namespace name.
So preview becomes Camera$$anonymous$$otionBlurEditor.preview or UnityEditor.Editor.preview depending on which is intended. (I don't know)
There may be other internal issues, who knows. Big releases always come with quirks and issues.
Had the same problem, deleting and re importing the scripts worked perfectly for me.
Answer by ptr0x · Mar 10, 2015 at 01:37 PM
I ran into the same problem.
The solution I took was modifying the 'preview' variable name to 'preview_'.
Thanks @ptr0x worked for me! Changed
var preview : SerializedProperty; to var preview_ : SerializedProperty;
make sure you get all of the lines:
preview_ = serObj.FindProperty ("preview");
EditorGUILayout.PropertyField (preview_, new GUIContent("Preview"));
if (preview_.boolValue)
dude you are AWESO$$anonymous$$E you saved the day- even the month..!
Answer by TTGxINSTINCT · Dec 13, 2015 at 02:47 PM
@lazerdarts In your script you are most likely using the same script, just change this line
var preview : SerializedProperty;
to
var preview_ : SerializedProperty;
Now replace all instances that it uses this variable in the code. I believe it is only about 4-5 changes or less.
You can also tell what is incorrect if your using MonoDevelop, it will tell you what lines need to be changed.
Example, this line needs to be fixed from
EditorGUILayout.PropertyField (preview, new GUIContent("Preview"));
to
EditorGUILayout.PropertyField (preview_, new GUIContent("Preview"));
Notice that the preview variable changed to preview_ because thats whats declared in your variables at the top of the code. I hopes this helped!
That worked perfectly! Thanks so much for the help! @TTGxINSTINCT
@TTGxINSTINCT : Thanks for the response. I have figured out that there is no issue with 'Ambiguous Reference' solution, because when I checked the same scenario in an empty project, there was no issue whatsoever. (Imported Image effects in Unity3D 4.5 in a new project -> created a package for the same->Created a new empty project in Unity3D 5.1.1->Imported the created package->Resolved the 'Ambiguous Reference ' issue successfully). However, as far as I can understand this has something to do with Unity's automatic API updater. There may be other compile errors throwing these crashes. Thanks for the help again. I will update my Unity to version 5.3.4f1 and will get back to you regarding this.