コード例 #1
0
        public static TransformFloatDrawer Create(float value, LinkedMemberInfo memberInfo, [NotNull] TransformMemberBaseDrawer parent, GUIContent label, bool readOnly)
        {
            TransformFloatDrawer result;

            if (!DrawerPool.TryGet(out result))
            {
                result = new TransformFloatDrawer();
            }
            result.Setup(value, typeof(float), memberInfo, parent, label, readOnly);
            result.LateSetup();
            return(result);
        }
コード例 #2
0
        /// <inheritdoc />
        protected sealed override void DoBuildMembers()
        {
            var first = Value;

            Array.Resize(ref members, 3);

            var labels = Preferences.labels;
            TransformFloatDrawer x, y, z;

            bool readOnly = ReadOnly;

            if (memberBuildList.Count == 3)
            {
                x = TransformFloatDrawer.Create(first.x, memberBuildList[0], this, labels.X, readOnly);
                y = TransformFloatDrawer.Create(first.y, memberBuildList[1], this, labels.Y, readOnly);
                z = TransformFloatDrawer.Create(first.z, memberBuildList[2], this, labels.Z, readOnly);
            }
            else
            {
                x = TransformFloatDrawer.Create(first.x, null, this, labels.X, readOnly);
                y = TransformFloatDrawer.Create(first.y, null, this, labels.Y, readOnly);
                z = TransformFloatDrawer.Create(first.z, null, this, labels.Z, readOnly);
            }

                        #if UNITY_EDITOR
            var firstTransform = Transform;
            if (firstTransform != null && firstTransform.IsPrefabInstance())
            {
                Func <bool> hasUnappliedChanges = () =>
                {
                    var mods = PropertyModifications;
                    if (mods != null)
                    {
                        for (int n = mods.Length - 1; n >= 0; n--)
                        {
                            if (string.Equals(mods[n].propertyPath, XPropertyPath()))
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                };
                x.OverrideHasUnappliedChanges = hasUnappliedChanges;

                hasUnappliedChanges = () =>
                {
                    var mods = PropertyModifications;
                    if (mods != null)
                    {
                        for (int n = mods.Length - 1; n >= 0; n--)
                        {
                            if (string.Equals(mods[n].propertyPath, YPropertyPath()))
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                };
                y.OverrideHasUnappliedChanges = hasUnappliedChanges;

                hasUnappliedChanges = () =>
                {
                    var mods = PropertyModifications;
                    if (mods != null)
                    {
                        for (int n = mods.Length - 1; n >= 0; n--)
                        {
                            if (string.Equals(mods[n].propertyPath, ZPropertyPath()))
                            {
                                return(true);
                            }
                        }
                    }
                    return(false);
                };
                z.OverrideHasUnappliedChanges = hasUnappliedChanges;
            }
                        #endif

            members[0] = x;
            members[1] = y;
            members[2] = z;
        }