Ejemplo n.º 1
0
        private void editMemberName(InspectorField field)
        {
            var tween = (ITweenPropertyBase)target;

            var options      = getMemberList();
            var currentValue = string.Format("{0}.{1}", tween.ComponentType, tween.MemberName);
            var currentIndex = options.IndexOf(currentValue);

            var selectedIndex = EditorGUILayout.Popup("Property", currentIndex, options.ToArray());

            if (selectedIndex != currentIndex)
            {
                EditorUtility.SetDirty(target);
            }

            if (selectedIndex >= 0)
            {
                var selectedValue = options[selectedIndex].Split('.');
                tween.ComponentType = selectedValue[0];
                tween.MemberName    = selectedValue[1];

                field.EditorTarget.FindProperty("componentType").stringValue = tween.ComponentType;
                field.EditorTarget.FindProperty("memberName").stringValue    = tween.MemberName;
            }
            else
            {
                tween.ComponentType = "";
                tween.MemberName    = "";

                field.EditorTarget.FindProperty("componentType").stringValue = "";
                field.EditorTarget.FindProperty("memberName").stringValue    = "";
            }
        }
Ejemplo n.º 2
0
        public override void OnLabelDragged(InspectorField field)
        {
            if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll))
            {
                object result = field.GetValues()[0];
                long   value  = Convert.ToInt64(result);
                result = (long)Math.Round(value + (CalculateDragSensitivity(value) * HandleUtility.niceMouseDelta * 0.1f));

                RangeValueAttribute rangeValue = field.GetAttribute <RangeValueAttribute>();
                if (rangeValue != null)
                {
                    result = Math.Min(Math.Max((long)result, (long)rangeValue.Min), (long)rangeValue.Max);
                }

                RangeAttribute range = field.GetAttribute <RangeAttribute>();
                if (range != null)
                {
                    result = Math.Min(Math.Max((long)result, (long)range.min), (long)range.max);
                }

                try
                {
                    result = Convert.ChangeType(result, field.Type);
                    field.SetValue(result);
                }
                catch (Exception)
                {
                    return;
                }
            }
        }
Ejemplo n.º 3
0
 public override void OnLabelDraw(InspectorField field, Rect rect)
 {
     if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll))
     {
         EditorGUIUtility.AddCursorRect(rect, MouseCursor.ResizeHorizontal);
     }
 }
Ejemplo n.º 4
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            object o    = GetValue(field);
            Type   type = o.GetType();

            Color color;

            if (type == typeof(Color32))
            {
                Color32 color32 = (Color32)o;
                color = color32;
            }
            else
            {
                color = (Color)o;
            }

            EditorGUI.BeginChangeCheck();
            color = EditorGUILayout.ColorField(color);

            if (EditorGUI.EndChangeCheck())
            {
                if (type == typeof(Color32))
                {
                    Color32 color32 = color;
                    field.SetValue(color32);
                }
                else
                {
                    field.SetValue(color);
                }
            }
        }
Ejemplo n.º 5
0
        public override void OnLabelDragged(InspectorField field)
        {
            if (InspectorPreferences.IsDragControl(InspectorPreferences.ValueScroll))
            {
                object result      = field.GetValues()[0];
                double sensitivity = CalculateDragSensitivity(result);
                result = Convert.ToDouble(result) + (double)(sensitivity * HandleUtility.niceMouseDelta);

                RangeValueAttribute rangeValue = field.GetAttribute <RangeValueAttribute>();
                if (rangeValue != null)
                {
                    result = Math.Min(Math.Max((double)result, rangeValue.Min), rangeValue.Max);
                }

                RangeAttribute range = field.GetAttribute <RangeAttribute>();
                if (range != null)
                {
                    result = Math.Min(Math.Max((double)result, range.min), range.max);
                }

                try
                {
                    result = Convert.ChangeType(result, field.Type);
                    field.SetValue(result);
                }
                catch (Exception)
                {
                    return;
                }
            }
        }
Ejemplo n.º 6
0
        private void Picked(GameObject go, object tag)
        {
            InspectorField field = tag as InspectorField;

            if (field == null)
            {
                return;
            }

            if (field.Type == typeof(GameObject))
            {
                field.SetValue(go);
            }
            else if (typeof(Component).IsAssignableFrom(field.Type))
            {
                field.SetValue(go.GetComponent(field.Type));
            }

            for (int i = 0; i < field.SerializedInstances.Length; i++)
            {
                if (field.SerializedInstances[i] is IDataChanged)
                {
                    ((IDataChanged)field.SerializedInstances[i]).DataChanged();
                }
            }
        }
Ejemplo n.º 7
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            GUILayout.BeginHorizontal();

            object value = GetValue(field);
            string text  = "";

            if (value != null)
            {
                text = value.ToString();
            }

            EditorGUI.BeginChangeCheck();

            string result = EditorGUILayout.TextField(text);

            char c;

            if (result.Length == 0)
            {
                c = '\0';
            }
            else
            {
                c = result[0];
            }

            if (EditorGUI.EndChangeCheck())
            {
                field.SetValue(c);
            }

            GUILayout.EndHorizontal();
        }
Ejemplo n.º 8
0
        public override void OnLabelDoubleClick(InspectorField field)
        {
            UnityEngine.Object target = field.GetValue() as UnityEngine.Object;
            if (target == null)
            {
                return;
            }

            if (!string.IsNullOrEmpty(AssetDatabase.GetAssetPath(target)))
            {
                EditorGUIUtility.PingObject(target);
            }
            else
            {
                SceneView  view     = SceneView.lastActiveSceneView;
                Quaternion rotation = view.camera.transform.rotation;

                if (target is GameObject)
                {
                    SceneView.lastActiveSceneView.LookAt(((GameObject)target).transform.position, rotation, 10);
                }
                else if (target is Component)
                {
                    SceneView.lastActiveSceneView.LookAt(((Component)target).transform.position, rotation, 10);
                }
            }
        }
Ejemplo n.º 9
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            DateTime time = field.GetValue <DateTime>();

            if (time == DateTime.MinValue)
            {
                time = DateTime.Now;
            }

            string title = time.ToString();

            if (field.Mixed)
            {
                title = " - - - ";
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.Space();
            if (GUILayout.Button(Calendar, GUIStyle.none, GUILayout.Width(18), GUILayout.Height(18)))
            {
                this.field = field;
                DateTimeDialog.Create(this, time, GUIUtility.GUIToScreenPoint(Event.current.mousePosition));
            }

            TextAnchor anchor = GUI.skin.label.alignment;

            GUI.skin.label.alignment = TextAnchor.MiddleLeft;
            GUILayout.Label(title);
            GUI.skin.label.alignment = anchor;

            GUILayout.FlexibleSpace();
            EditorGUILayout.EndHorizontal();
        }
Ejemplo n.º 10
0
        public override void OnContextualClick(InspectorField field, GenericMenu menu)
        {
            menu.AddItem(new GUIContent("Zero"), false, Zero);
            menu.AddItem(new GUIContent("One"), false, One);

            menu.AddSeparator("");
        }
Ejemplo n.º 11
0
        protected override void RefreshFields()
        {
            Type type = typeof(Rigidbody);

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("mass"),
                                          new DescriptorAttribute("Mass", "The mass of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-mass.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("drag"),
                                          new DescriptorAttribute("Drag", "The drag of the object", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-drag.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("angularDrag"),
                                          new DescriptorAttribute("Angular Drag", "The angular drag of the object", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-angularDrag.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("useGravity"),
                                          new DescriptorAttribute("Use Gravity", "Is the object affected by world gravity", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-useGravity.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("isKinematic"),
                                          new DescriptorAttribute("Is Kinematic", "If true, physic does not drive this object, used for animation", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-isKinematic.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("interpolation"),
                                          new DescriptorAttribute("Interpolation", "Interpolation allows you to smooth out the effect of running physics at a fixed frame rate", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-interpolation.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("collisionDetectionMode"),
                                          new DescriptorAttribute("Collision Detection", "How collision are detected", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-collisionDetectionMode.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("constraints"), new EnumAttribute(true),
                                          new DescriptorAttribute("Constraints", "Controls which degrees of freedom are allowed for the simulation of this Rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-constraints.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("centerOfMass"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Center of Mass", "In essence, the pivot around which the object spins", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-centerOfMass.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("freezeRotation"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Freeze Rotation", "Controls whether physics will change the rotation of the object", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-freezeRotation.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("inertiaTensor"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Inertia Tensor", "The diagonal inertia tensor of mass relative to the center of mass", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-inertiaTensor.html")));
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("inertiaTensorRotation"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Inertia Tensor Rotation", "The rotation of the inertia tensor", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-inertiaTensorRotation.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("maxAngularVelocity"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Max Angular Velocity", "The maximimum angular velocity of the rigidbody. (Default 7) range { 0, infinity }", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-maxAngularVelocity.html")));

            Fields.Add(new InspectorField(type, Instances, type.GetProperty("sleepThreshold"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Sleep Threshold", "The mass-normalized energy threshold, below which objects start going to sleep.", "http://docs.unity3d.com/ScriptReference/Rigidbody-sleepThreshold.html")));

#if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("solverIterationCount"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Solver Iteration Count", "Allows you to override the solver iteration count per rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-solverIterationCount.html")));
#else
            Fields.Add(new InspectorField(type, Instances, type.GetProperty("solverIterations"), new InspectAttribute(InspectorLevel.Advanced),
                                          new DescriptorAttribute("Solver Iteration Count", "Allows you to override the solver iteration count per rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-solverIterationCount.html")));
#endif

            InspectorField debug = new InspectorField("Debug");
            Fields.Add(debug);

            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("position"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Position", "The position of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-position.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("rotation"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Rotation", "The rotation of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-rotation.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("velocity"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Velocity", "The velocity of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-velocity.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("angularVelocity"), new ReadOnlyAttribute(), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("Angular Velocity", "The rotation velocity of the rigidbody", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-angularVelocity.html")));
            debug.Fields.Add(new InspectorField(type, Instances, type.GetProperty("worldCenterOfMass"), new InspectAttribute(InspectorLevel.Debug),
                                                new DescriptorAttribute("World Center of Mass", "The center of mass of the rigidbody in world space", "https://docs.unity3d.com/Documentation/ScriptReference/Rigidbody-worldCenterOfMass.html")));
        }
Ejemplo n.º 12
0
        private void _view_CellValueChanged(object sender, DataGridViewCellEventArgs e)
        {
            InspectorField fieldChanged = _cellToComponentMap[e.RowIndex];

            SceneInterface.ModifyGameObjectComponentField(_sceneManager, fieldChanged.GameObjectID,
                                                          (int)fieldChanged.ComponentIndex, (int)fieldChanged.FieldIndex, _view[e.ColumnIndex, e.RowIndex].Value.ToString());
            _scene.HasChanged = true;
        }
Ejemplo n.º 13
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            RangeValueAttribute range = field.GetAttribute <RangeValueAttribute>();

            if (range == null)
            {
                return;
            }

            EditorGUILayout.BeginHorizontal();

            RangeFloat[] ranges = field.GetValues <RangeFloat>();

            float[] mins      = new float[ranges.Length];
            float[] maxs      = new float[ranges.Length];
            float   min       = ranges[0].min;
            float   max       = ranges[0].max;
            bool    different = false;

            for (int i = 0; i < ranges.Length; i++)
            {
                mins[i] = ranges[i].min;
                maxs[i] = ranges[i].max;
                if (ranges[i].min != min || ranges[0].max != max)
                {
                    different = true;
                }
            }

            if (FloatEditor.DrawFloat("", mins, out min, GUILayout.Width(64)))
            {
                for (int i = 0; i < field.Instances.Length; i++)
                {
                    field.SetValue(field.Instances[i], new RangeFloat(min, ranges[i].max));
                }
            }

            EditorGUI.BeginChangeCheck();
            EditorGUI.showMixedValue = different;
            EditorGUILayout.MinMaxSlider(ref min, ref max, range.Min, range.Max);
            if (EditorGUI.EndChangeCheck() && min < max)
            {
                for (int i = 0; i < field.Instances.Length; i++)
                {
                    field.SetValue(field.Instances[i], new RangeFloat(min, max));
                }
            }

            if (FloatEditor.DrawFloat("", maxs, out max, GUILayout.Width(64)))
            {
                for (int i = 0; i < field.Instances.Length; i++)
                {
                    field.SetValue(field.Instances[i], new RangeFloat(ranges[i].min, max));
                }
            }

            EditorGUILayout.EndHorizontal();
        }
        public static void AddField(InspectorField field)
        {
            if (Contains(field))
            {
                return;
            }

            Instance.references.Add(new InspectorReference(field));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Get a new theme instance and load it with settings
        /// </summary>
        /// <param name="settings"></param>
        /// <param name="host"></param>
        /// <param name="lists"></param>
        /// <returns></returns>
        public static InteractableThemeBase GetTheme(InteractableThemePropertySettings settings, GameObject host, ThemeLists lists)
        {
            int  index     = InspectorField.ReverseLookup(settings.Name, lists.Names.ToArray());
            Type themeType = lists.Types[index];
            InteractableThemeBase theme = (InteractableThemeBase)Activator.CreateInstance(themeType, host);

            theme.Init(host, settings);
            return(theme);
        }
Ejemplo n.º 16
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            names = new List <string>();
            masks = new List <int>();

            for (int i = 0; i < 32; i++)
            {
                string name = LayerMask.LayerToName(i);

                if (!string.IsNullOrEmpty(name))
                {
                    names.Add(name);
                    masks.Add(1 << i);
                }
            }

            object value = field.GetValue();

            if (value != null)
            {
                bool isMask = value is LayerMask;

                int mask;
                if (isMask)
                {
                    mask = (int)(LayerMask)value;
                }
                else
                {
                    mask = (int)value;
                }

                int result;
                if (DrawLayerMaskField(mask, style, out result))
                {
                    if (isMask)
                    {
                        field.SetValue((LayerMask)result);
                    }
                    else
                    {
                        field.SetValue(result);
                    }
                }
            }
            else
            {
                EditorGUI.showMixedValue = true;

                int result;
                if (DrawLayerMaskField(0, style, out result))
                {
                    field.SetValue(result);
                }
            }
        }
Ejemplo n.º 17
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            field.Expandable = true;
            if (!field.Expanded)
            {
                return;
            }

            EditorGUI.showMixedValue = field.Mixed;

            EditorGUI.BeginChangeCheck();

            RigidbodyConstraints value = (RigidbodyConstraints)GetValue(field);
            int newValue = 0;

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Freeze Position ", GUILayout.Width(LABEL_WIDTH));
            if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezePositionX), "X", GUILayout.Width(TOGGLE_WIDTH)))
            {
                newValue += (int)RigidbodyConstraints.FreezePositionX;
            }

            if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezePositionY), "Y", GUILayout.Width(TOGGLE_WIDTH)))
            {
                newValue += (int)RigidbodyConstraints.FreezePositionY;
            }

            if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezePositionZ), "Z", GUILayout.Width(TOGGLE_WIDTH)))
            {
                newValue += (int)RigidbodyConstraints.FreezePositionZ;
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Freeze Rotation ", GUILayout.Width(LABEL_WIDTH));
            if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezeRotationX), "X", GUILayout.Width(TOGGLE_WIDTH)))
            {
                newValue += (int)RigidbodyConstraints.FreezeRotationX;
            }

            if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezeRotationY), "Y", GUILayout.Width(TOGGLE_WIDTH)))
            {
                newValue += (int)RigidbodyConstraints.FreezeRotationY;
            }

            if (GUILayout.Toggle(value.Has(RigidbodyConstraints.FreezeRotationZ), "Z", GUILayout.Width(TOGGLE_WIDTH)))
            {
                newValue += (int)RigidbodyConstraints.FreezeRotationZ;
            }
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                field.SetValue(Enum.ToObject(typeof(RigidbodyConstraints), newValue));
            }
        }
		protected override bool CanShowField( InspectorField field )
		{

			if( field.Member.Name != "memberName" )
				return true;

			editMemberName( field );

			return false;

		}
        public override void Draw(FieldAttribute attribute, InspectorField field)
        {
            object value = field.GetValue();

            if (value == null)
            {
                return;
            }

            GUILayout.Label(value.ToString());
        }
Ejemplo n.º 20
0
        public override void Draw(InspectorField field, GUIStyle style)
        {
            ReflectionProbeBlendInfo info = field.GetValue <ReflectionProbeBlendInfo>();

            GUILayout.BeginHorizontal();

            EditorGUILayout.ObjectField(info.probe, typeof(ReflectionProbe), true, GUILayout.MinWidth(100), GUILayout.MaxWidth(float.MaxValue));
            GUILayout.Label("Weight: " + info.weight.ToString());

            GUILayout.EndHorizontal();
        }
Ejemplo n.º 21
0
        protected override bool CanShowField(InspectorField field)
        {
            if (field.Member.Name != "memberName")
            {
                return(true);
            }

            editMemberName(field);

            return(false);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Create the event and setup the values from the inspector
        /// </summary>
        /// <param name="iEvent"></param>
        /// <param name="lists"></param>
        /// <returns></returns>
        public static ReceiverBase GetReceiver(InteractableEvent iEvent, EventLists lists)
        {
            int  index     = InspectorField.ReverseLookup(iEvent.ClassName, lists.EventNames.ToArray());
            Type eventType = lists.EventTypes[index];
            // apply the settings?
            ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(eventType, iEvent.Event);

            InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings);

            return(newEvent);
        }
        public override void Draw(InspectorField field, GUIStyle style)
        {
            object value = GetValue(field);

            try
            {
                //Always throw "ExitGUIException"
                gradientField.Invoke(null, new object[] { value, null });
            }
            catch (Exception) { }
        }
Ejemplo n.º 24
0
		protected override bool CanShowField( InspectorField field )
		{

			if( !isEditingMultipleObjects )
			{

				var tween = target as TweenComponentBase;
				var fieldName = field.Member.Name;

				if( fieldName == "loopCount" && tween.LoopType == TweenLoopType.None )
				{
					return false;
				}

				if( fieldName == "assignStartValueBeforeDelay" )
				{
					if( tween.StartDelay <= 0 )
						return false;
				}

				if( fieldName == "startValue" )
				{

					var startTypeProperty = serializedObject.FindProperty( "startValueType" );
					if( startTypeProperty != null )
					{
						if( startTypeProperty.intValue == (int)TweenStartValueType.SyncOnRun )
						{
							return false;
						}
					}

				}

				if( fieldName == "endValue" )
				{

					var endTypeProperty = serializedObject.FindProperty( "endValueType" );
					if( endTypeProperty != null )
					{
						if( endTypeProperty.intValue == (int)TweenEndValueType.SyncOnRun )
						{
							return false;
						}
					}

				}

			}

			return base.CanShowField( field );

		}
        public static void RemoveField(InspectorField field)
        {
            InspectorReference reference = new InspectorReference(field);

            for (int i = Instance.references.Count - 1; i >= 0; i--)
            {
                if (reference.Equals(Instance.references[i]))
                {
                    Instance.references.RemoveAt(i);
                }
            }
        }
        public override void Draw(InspectorField field, GUIStyle style)
        {
            AnimationCurve curve = GetValue(field) as AnimationCurve;
            if (curve == null && !field.Mixed)
                curve = new AnimationCurve();

            EditorGUI.BeginChangeCheck();

            AnimationCurve result = EditorGUILayout.CurveField(curve);

            if (EditorGUI.EndChangeCheck())
                field.SetValue(result);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Create the event and setup the values from the inspector
        /// </summary>
        public static ReceiverBase GetReceiver(InteractableEvent iEvent, InteractableTypesContainer interactableTypes)
        {
#if UNITY_EDITOR
            int  index     = InspectorField.ReverseLookup(iEvent.ClassName, interactableTypes.ClassNames);
            Type eventType = interactableTypes.Types[index];
#else
            Type eventType = Type.GetType(iEvent.AssemblyQualifiedName);
#endif
            // apply the settings?
            ReceiverBase newEvent = (ReceiverBase)Activator.CreateInstance(eventType, iEvent.Event);
            InspectorGenericFields <ReceiverBase> .LoadSettings(newEvent, iEvent.Settings);

            return(newEvent);
        }
        public static bool Contains(InspectorField field)
        {
            InspectorReference reference = new InspectorReference(field);

            foreach (InspectorReference child in Instance.references)
            {
                if (child.Equals(reference))
                {
                    return(true);
                }
            }

            return(false);
        }
        public override void Draw(InspectorField field, GUIStyle style)
        {
            // GetValue returns null if multi-selection and different values
            Guid id = field.GetValue <Guid>();

            if (id == Guid.Empty)
            {
                GUILayout.Label("GUID: --------------");
            }
            else
            {
                GUILayout.Label("GUID: " + id.ToString());
            }
        }
Ejemplo n.º 30
0
        public static void AddField(InspectorField field)
        {
            Instance.references.Add(new InspectorReference(field));

            InspectorField parent = CreateContainer(field.SerializedInstances, editor.Fields);

            parent.Fields.Add(new InspectorField(field));
            parent.Depth = 0;

            if (!editor.Fields.Contains(parent))
            {
                editor.Fields.Add(parent);
            }

            Instance.Repaint();
        }
Ejemplo n.º 31
0
        private static InspectorField CreateContainer(UnityEngine.Object[] objs, List <InspectorField> existing)
        {
            string name = "";

            if (objs.Length == 1)
            {
                name = objs[0].name + " [" + objs[0].GetType().Name + "]";
            }
            else
            {
                name = "List of " + objs[0].GetType().Name;
            }

            for (int i = 0; i < existing.Count; i++)
            {
                if (existing[i].Name != name)
                {
                    continue;
                }

                if (existing[i].internalValue.Length != objs.Length)
                {
                    continue;
                }

                bool same = true;
                for (int j = 0; j < objs.Length; j++)
                {
                    if ((existing[i].internalValue[j] as UnityEngine.Object) != objs[j])
                    {
                        same = false;
                        break;
                    }
                }

                if (same)
                {
                    return(existing[i]);
                }
            }

            InspectorField container = new InspectorField(name);

            container.internalValue = objs;

            return(container);
        }
Ejemplo n.º 32
0
        protected override bool CanShowField(InspectorField field)
        {
            if (!isEditingMultipleObjects)
            {
                var tween     = target as TweenComponentBase;
                var fieldName = field.Member.Name;

                if (fieldName == "loopCount" && tween.LoopType == TweenLoopType.None)
                {
                    return(false);
                }

                if (fieldName == "assignStartValueBeforeDelay")
                {
                    if (tween.StartDelay <= 0)
                    {
                        return(false);
                    }
                }

                if (fieldName == "startValue")
                {
                    var startTypeProperty = serializedObject.FindProperty("startValueType");
                    if (startTypeProperty != null)
                    {
                        if (startTypeProperty.intValue == (int)TweenStartValueType.SyncOnRun)
                        {
                            return(false);
                        }
                    }
                }

                if (fieldName == "endValue")
                {
                    var endTypeProperty = serializedObject.FindProperty("endValueType");
                    if (endTypeProperty != null)
                    {
                        if (endTypeProperty.intValue == (int)TweenEndValueType.SyncOnRun)
                        {
                            return(false);
                        }
                    }
                }
            }

            return(base.CanShowField(field));
        }
		private void editMemberName( InspectorField field )
		{

			var tween = (ITweenPropertyBase)target;

			var options = getMemberList();
			var currentValue = string.Format( "{0}.{1}", tween.ComponentType, tween.MemberName );
			var currentIndex = options.IndexOf( currentValue );

			var selectedIndex = EditorGUILayout.Popup( "Property", currentIndex, options.ToArray() );
			if( selectedIndex != currentIndex )
				EditorUtility.SetDirty( target );

			if( selectedIndex >= 0 )
			{
				
				var selectedValue = options[ selectedIndex ].Split( '.' );
				tween.ComponentType = selectedValue[ 0 ];
				tween.MemberName = selectedValue[ 1 ];

				field.EditorTarget.FindProperty( "componentType" ).stringValue = tween.ComponentType;
				field.EditorTarget.FindProperty( "memberName" ).stringValue = tween.MemberName;

			}
			else
			{

				tween.ComponentType = "";
				tween.MemberName = "";

				field.EditorTarget.FindProperty( "componentType" ).stringValue = "";
				field.EditorTarget.FindProperty( "memberName" ).stringValue = "";

			}

		}
Ejemplo n.º 34
0
		protected virtual bool CanShowField( InspectorField field )
		{
			return true;
		}