Hi,
I want my script make a selection of all child of my object in editor scene. Well,tried such code:
@CustomEditor (SolidDiscExample)
class DrawSolidDisc extends Editor {
var positions : Vector3[];
var aChild:GameObject;
function OnSceneGUI () {
Handles.color = Color(1,0,0,0.1);
Handles.DrawSolidDisc(target.transform.position, Vector3.up, target.areaOfEffect);
Handles.color = Color.cyan;
target.areaOfEffect =
Handles.ScaleValueHandle(target.areaOfEffect,
target.transform.position + Vector3(target.areaOfEffect,0,0),
Quaternion.identity,
2,
Handles.CylinderCap,
2);
if(target.transform.childCount>0){
for(var i = 0;i<=1; i++){
aChild = target.transform.Find(target.transform.name + i);
Handles.color = Color(1,0,0,0.1);
Handles.DrawSolidDisc(aChild.transform.position, Vector3.up, aChild.areaOfEffect);
Handles.color = Color.cyan;
aChild.areaOfEffect =
Handles.ScaleValueHandle(aChild.areaOfEffect,
aChild.transform.position + Vector3(aChild.areaOfEffect,0,0),
Quaternion.identity,
2,
Handles.CylinderCap, 2);
}
}
}
}
But I believe that there no reference to child at all or something because have exception:
NullReferenceException
(wrapper dynamic-method) UnityEngine.Transform.Transform$get_transform$ (object,object) <IL 0x00006, 0x0004b>
Boo.Lang.Runtime.RuntimeServices.GetProperty (object,string) <IL 0x00043, 0x00118>
UnityScript.Lang.UnityRuntimeServices.GetProperty (object,string) <IL 0x00017, 0x000ac>
DrawSolidDisc.OnSceneGUI () (at Assets/Editor/DrawSolidDisc.js:23)
System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object,System.Globalization.CultureInfo) <IL 0x000d6, 0x0036f>
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object parameters)
and
InvalidCastException: Cannot cast from source type to destination type.
DrawSolidDisc.OnSceneGUI () (at Assets/Editor/DrawSolidDisc.js:21)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object parameters)
UnityEditor.SceneView.CallOnSceneGUI () (at C:/BuildAgent/work/842f9557127e852/Editor/Mono/SceneView/SceneView.cs:1148)
UnityEditor.SceneView.OnGUI () (at C:/BuildAgent/work/842f9557127e852/Editor/Mono/SceneView/SceneView.cs:673)
System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object parameters, System.Globalization.CultureInfo culture)
Thanks