public LayerPropertyViewModel(ILayerProperty layerProperty, IPropertyVmFactory propertyVmFactory)
        {
            LayerProperty = layerProperty;

            TreePropertyViewModel     = propertyVmFactory.TreePropertyViewModel(layerProperty, this);
            TimelinePropertyViewModel = propertyVmFactory.TimelinePropertyViewModel(layerProperty, this);
        }
Beispiel #2
0
        public ILayerPropertyKeyframe Paste(List <ILayerProperty> properties, TimeSpan offset)
        {
            ILayerProperty property = properties.FirstOrDefault(p => p.LayerPropertyGroup.Feature.Id == FeatureId && p.Path == Path);

            if (property != null)
            {
                KeyframeEntity.Position += offset;
                ILayerPropertyKeyframe keyframe = property.AddKeyframeEntity(KeyframeEntity);
                KeyframeEntity.Position -= offset;

                return(keyframe);
            }

            return(null);
        }
 internal LayerPropertyEventArgs(ILayerProperty layerProperty)
 {
     LayerProperty = layerProperty;
 }
        void PropertyGUI( ILayerProperty property )
        {
            bool focused = focusedWindow == this;

            RectOffset margin = new RectOffset( 4,4,4,4 );
            Rect rect = GUILayoutUtility.GetRect( 0.0f,0.0f,GUILayout.ExpandWidth(true),GUILayout.Height(32.0f + margin.vertical) );

            int controlID = GUIUtility.GetControlID( property.gameObject.GetInstanceID(),FocusType.Passive,rect );

            bool selected = Selection.gameObjects.Contains(property.gameObject);

            if( selected )
            {
                Color[] darkColors = new Color[]{
                    new Color32( 72,72,72,255 ),
                    new Color32( 62,95,150,255 )
                };
                Color[] lightColors = new Color[]{
                    new Color32( 142,142,142,255 ),
                    new Color32( 62,124,230,255 )
                };

                Color[] colors = !EditorGUIUtility.isProSkin ? lightColors : darkColors;
                Color color = focused ? colors[1] : colors[0];

                EditorGUI.DrawRect( rect,color );
            }

            rect = margin.Remove( rect );

            Rect activeRect = new Rect( rect );
            activeRect.y = rect.y+rect.height*0.5f-16.0f;
            activeRect.width = 16.0f;
            activeRect.height = 16.0f;

            EditorGUI.BeginChangeCheck();
            bool active = EditorGUI.Toggle( activeRect,property.active );
            if( EditorGUI.EndChangeCheck() )
            {
                property.active = active;
            }

            Rect visibleRect = new Rect( rect );
            visibleRect.y = rect.y+rect.height*0.5f;
            visibleRect.width = 16.0f;
            visibleRect.height = 16.0f;

            EditorGUI.BeginChangeCheck();
            bool enabled = EditorGUI.Toggle( visibleRect,property.enabled,Styles.visiblyToggle );
            if( EditorGUI.EndChangeCheck() )
            {
                property.enabled = enabled;
            }

            Rect previewRect = new Rect( rect );

            previewRect.x += 16.0f;
            previewRect.width = 32.0f;
            previewRect.height = 32.0f;

            property.OnPreviewGUI( previewRect,GUI.skin.box );

            if( Event.current.type == EventType.Repaint )
            {
                GUIContent label = new GUIContent( property.name );
                GUIContent orderContent = new GUIContent( property.sortingOrder.ToString() );

                GUIStyle labelStyle = Styles.hiLabel;
                GUIStyle orderStyle = Styles.rightLabel;

                Rect labelRect = new Rect( rect );

                labelRect.x += 48.0f;
                labelRect.width -= 100.0f - 48.0f;

                float labelHeight = labelStyle.CalcHeight(label,labelRect.width);
                labelRect.y += (labelRect.height-labelHeight )*0.5f;
                labelRect.height = labelHeight;

                Rect orderRect = new Rect( rect );

                orderRect.x = rect.xMax - 100.0f;
                orderRect.width = 100.0f;

                float orderHeight = orderStyle.CalcHeight(orderContent,orderRect.width);
                orderRect.y += (orderRect.height-orderHeight )*0.5f;
                orderRect.height = orderHeight;

                Color[] colorArray = !EditorGUIUtility.isProSkin ? s_HierarchyColors : s_DarkColors;

                int colorCode = property.colorCode;
                Color color = colorArray[colorCode & 3];
                Color onColor = colorArray[(colorCode & 3) + 4];
                color.a = colorCode < 4 ? (onColor.a = 1f) : (onColor.a = 0.6f);

                labelStyle.normal.textColor = color;
                labelStyle.focused.textColor = color;
                labelStyle.hover.textColor = color;
                labelStyle.active.textColor = color;
                labelStyle.onNormal.textColor = onColor;
                labelStyle.onHover.textColor = onColor;
                labelStyle.onActive.textColor = onColor;
                labelStyle.onFocused.textColor = onColor;

                labelStyle.Draw( labelRect,label,false,false,selected,focused );
                orderStyle.Draw( orderRect,orderContent,false,false,selected,focused );
            }

            Event current = Event.current;

            switch( current.type )
            {
            case EventType.MouseDown:
                if( current.button == 0 && rect.Contains(Event.current.mousePosition) )
                {
                    if (Event.current.clickCount == 2)
                    {
                        if( SceneView.lastActiveSceneView != null )
                        {
                            SceneView.lastActiveSceneView.FrameSelected();
                        }
                    }
                    else
                    {
                        GUIUtility.hotControl = controlID;
                        GUIUtility.keyboardControl = 0;
                    }

                    current.Use();
                }
                break;
            case EventType.MouseUp:
                if( GUIUtility.hotControl == controlID && rect.Contains(Event.current.mousePosition) )
                {
                    if( EditorGUI.actionKey )
                    {
                        Object[] objects = Selection.objects;
                        if( objects.Contains( property.gameObject ) )
                        {
                            ArrayUtility.Remove( ref objects,property.gameObject );
                        }
                        else
                        {
                            ArrayUtility.Add( ref objects,property.gameObject );
                        }
                        Selection.objects = objects;
                    }
                    else
                    {
                        Selection.activeGameObject = property.gameObject;
                    }

                    GUIUtility.hotControl = 0;

                    current.Use();
                }
                break;
            }
        }
        static int CompareProperty( ILayerProperty a,ILayerProperty b )
        {
            if( a.IsMissingComponent() || b.IsMissingComponent() )
            {
                return 0;
            }

            if( a.sortingLayerID != b.sortingLayerID )
            {
                return b.sortingLayerID - a.sortingLayerID;
            }
            return b.sortingOrder - a.sortingOrder;
        }