error: ambiguous reference 'constructor': UnityEditor.SerializedObject.constructor

Can someone help me with this?

var serialLightSource1 : SerializedObject = new SerializedObject(target.dynamicLightsource1);
var SerialProperty1 : SerializedProperty = serialLightSource1.FindProperty("m_Lightmapping")

The first line causes a error since Unity 3.5:
Assets/StasisDevelopments/power set/files/scripts/editor/sd_hanginglightseditor.js(56,73): BCE0004: Ambiguous reference ‘constructor’: UnityEditor.SerializedObject.constructor(UnityEngine.Object[ ]), UnityEditor.SerializedObject.constructor(UnityEngine.Object).

Background info:
I found this code on unity awnsers in c++ and converted it to java a while ago.

What’s target.dynamicLighsource1, is it null?

The script with the error is a editor script.
dynamicLightsource1 is a light on the script that the editor script is for.

var dynamicLightsource1: Light;

Solved:

var targetDynamicLight : Light = (target as sd_hanginglights).dynamicLightsource1;
var serialLightSource1 : SerializedObject = new SerializedObject(targetDynamicLight);
var serialProperty1 : SerializedProperty = serialLightSource1.FindProperty("m_Lightmapping");

UPDATE: Solved as well. Since my class below was not extended from MonoBehaviour, Object for me was using System.Object, not UnityEngine.Object. Changing the incoming object type for the first parameter to UnityEngine.Object solved the problem.

Not for me.

Your problem was solved because you specifically cast dynamicLightsource1 (which I guess is of type Object or untyped) to type Light type before instantiating the SerializedObject.

It looks like since they added support for multi-object inspecting/editing they added another constructor to SerializedObject that takes an Object[ ]. This pretty much destroys your ability to instantiate a new SerializedObject with an Object as a parameter since both Object and Object[ ] can be represented as Object type. You send a boxed Object to it and it can’t tell which constructor to use. (At least this is what it looks like to me.) This ruins your ability to use SerializedObject in a generic way.

Take my case below. I had a function which would make it easier for me to work with SerializedProperties. I would simply call my funciton SetSerializedProperty passing it the component (objectInfo) as an Object, a string name for the property I wanted to modify, and the value I wanted to set as an Object.

 // called in another script
EditorTools.SetSerializedProperty(objectInfo, "scriptTargetId", -1); // remove script target id from object

static public function SetSerializedProperty(object : Object, variableName : String, variableValue : Object) : void {
		var so : SerializedObject = new SerializedObject(object as Object);
		var sp : SerializedProperty = so.FindProperty(variableName);
				
		so.Update(); // refresh the data
		
		// Type the property and fill with new value
		var type : SerializedPropertyType = sp.propertyType;
		.....

// Unity3.4 - Works perfectly
// Unity3.5 - Ambiguous reference 'constructor': UnityEditor.SerializedObject.constructor(UnityEngine.Object[]), UnityEditor.SerializedObject.constructor(UnityEngine.Object)

Try this:

static public function SetSerializedProperty(object : UnityEngine.Object, variableName : String, variableValue : Object) : void {

System.Object can represent arrays, but UnityEngine.Object cannot. Since SerializedProperty requires a UnityEngine.Object anyway, use that as your base type instead of System.Object.

Edit: Also you could look into Generics, as then you could specify the type in the function call, like when using List. But I’m unsure if JS supports creating your own Generic functions/objects.

Right, that was the problem as I found out and mentioned in my Update in the 1st paragraph. I didn’t post the corrected code though. Thanks. I need to watch out for the two different types of Object in the future.

I wondered about that also, but according to http://forum.unity3d.com/threads/121999-Unityscript-generic-functions it’s not possible. I love UScript and its come a long way since 2.5, but it still has a few disadvantages. Cest la vie.