/// <summary> /// Recreates all the GUI elements used by this inspector. /// </summary> private void BuildGUI() { Layout.Clear(); GUIWidget guiWidget = InspectedObject as GUIWidget; if (guiWidget == null) { return; } skinField = new GUIResourceField(typeof(GUISkin), new LocEdString("Skin")); cameraField = new GUIGameObjectField(typeof(Camera), new LocEdString("Camera")); skinField.OnChanged += x => { GUISkin skin = Resources.Load <GUISkin>(x.UUID); guiWidget.Skin = skin; MarkAsModified(); ConfirmModify(); }; cameraField.OnChanged += x => { guiWidget.Camera = x as Camera; MarkAsModified(); ConfirmModify(); }; Layout.AddElement(skinField); Layout.AddElement(cameraField); }
/// <inheritoc/> protected internal override void Initialize(int layoutIndex) { if (property != null) { guiField = new GUIGameObjectField(property.InternalType, new GUIContent(title)); guiField.OnChanged += OnFieldValueChanged; layout.AddElement(layoutIndex, guiField); } }
/// <summary> /// Creates GUI elements for fields common to all joints. /// </summary> protected virtual void BuildGUI(Joint joint, bool showOffsets) { this.showOffsets = showOffsets; targetField = new GUIGameObjectField(typeof(Rigidbody), new LocEdString("Target")); anchorField = new GUIGameObjectField(typeof(Rigidbody), new LocEdString("Anchor")); if (showOffsets) { targetOffsetField = new GUIVector3Field(new LocEdString("Target offset")); anchorOffsetField = new GUIVector3Field(new LocEdString("Anchor offset")); } breakForceField = new GUIFloatField(new LocEdString("Break force")); breakTorqueField = new GUIFloatField(new LocEdString("Break torque")); collisionField = new GUIToggleField(new LocEdString("Enable collision")); targetField.OnChanged += x => { joint.SetBody(JointBody.Target, (Rigidbody)x); MarkAsModified(); ConfirmModify(); }; anchorField.OnChanged += x => { joint.SetBody(JointBody.Anchor, (Rigidbody)x); MarkAsModified(); ConfirmModify(); }; if (showOffsets) { targetOffsetField.OnValueChanged += x => { joint.SetTransform(JointBody.Target, x, joint.GetRotation(JointBody.Target)); MarkAsModified(); }; targetOffsetField.OnFocusLost += ConfirmModify; targetOffsetField.OnConfirm += x => ConfirmModify(); anchorOffsetField.OnValueChanged += x => { joint.SetTransform(JointBody.Anchor, x, joint.GetRotation(JointBody.Anchor)); MarkAsModified(); }; anchorOffsetField.OnFocusLost += ConfirmModify; anchorOffsetField.OnConfirm += x => ConfirmModify(); } breakForceField.OnChanged += x => { joint.BreakForce = x; MarkAsModified(); }; breakForceField.OnFocusLost += ConfirmModify; breakForceField.OnConfirmed += ConfirmModify; breakTorqueField.OnChanged += x => { joint.BreakTorque = x; MarkAsModified(); }; breakTorqueField.OnFocusLost += ConfirmModify; breakTorqueField.OnConfirmed += ConfirmModify; collisionField.OnChanged += x => { joint.EnableCollision = x; MarkAsModified(); ConfirmModify(); }; Layout.AddElement(targetField); if (showOffsets) { Layout.AddElement(targetOffsetField); } Layout.AddElement(anchorField); if (showOffsets) { Layout.AddElement(anchorOffsetField); } Layout.AddElement(breakForceField); Layout.AddElement(breakTorqueField); Layout.AddElement(collisionField); }
private static extern void Internal_CreateInstance(GUIGameObjectField instance, Type type, ref GUIContent title, int titleWidth, string style, GUIOption[] options, bool withTitle);