Ejemplo n.º 1
0
        public void resetContainer()
        {
            this.Children.Clear();
            Timer                 = 1;
            this.Background       = Brushes.Gray;
            this.Width            = 900;
            this.Height           = 700;
            layoutData            = new LayoutData();
            layoutData.width      = this.Width;
            layoutData.height     = this.Height;
            layoutData.tag        = "Canvas";
            layoutData.text       = "";
            layoutData.sourcePath = null;

            layoutData.imageSwitch     = 0;
            layoutData.stretchModel    = 0;
            layoutData.sceneTime       = Timer;
            layoutData.backgroundColor = 0;
            MainWindow mWindow = App.Current.MainWindow as MainWindow;

            AttributeLayout.InitSceneAttributeLayout(mWindow, this);
            rotateTransform = (this.RenderTransform as RotateTransform);
            if (rotateTransform == null)
            {
                return;
            }
            layoutData.angle = rotateTransform.Angle;
        }
Ejemplo n.º 2
0
        private void Control_MouseDown(object sender, MouseButtonEventArgs e)
        {
            //base.OnMouseDown(e);
            MainWindow mWindow = App.Current.MainWindow as MainWindow;

            AttributeLayout.SetAttrTree(this, mWindow);
        }
        static void CreateShaderMetaData()
        {
            string path = "";

            foreach (Shader shader in Selection.objects)
            {
                AttributeLayout[] attributes = new AttributeLayout[]
                {
                    new AttributeLayout(MeshChannel.Color, ComponentIndex.R, Vector2.up, 0, "_Texture1"),
                    new AttributeLayout(MeshChannel.Color, ComponentIndex.G, Vector2.up, 0, "_Texture2"),
                    new AttributeLayout(MeshChannel.Color, ComponentIndex.B, Vector2.up, 0, "_Texture3"),
                    new AttributeLayout(MeshChannel.Color, ComponentIndex.A, Vector2.up, 0, "_Texture4"),
                };
#pragma warning disable 0618
                path = ShaderMetaDataUtility.SaveMeshAttributesData(shader, attributes, true);
#pragma warning restore 0618
            }

            AssetDatabase.Refresh();

            TextAsset asset = AssetDatabase.LoadAssetAtPath <TextAsset>(path);

            if (asset != null)
            {
                EditorGUIUtility.PingObject(asset);
            }
        }
Ejemplo n.º 4
0
 internal void RefreshPreviewTextureCache()
 {
     if (m_CacheTarget != null)
     {
         for (int i = 0; i < meshAttributes.Length; ++i)
         {
             AttributeLayout attributes = meshAttributes[i];
             attributes.previewTexture = (Texture2D)m_CacheMaterials[currentMeshACIndex].GetTexture(attributes.propertyTarget);
         }
     }
 }
Ejemplo n.º 5
0
        private AttributeLayout GetBaseTexture()
        {
            AttributeLayout selectedAttribute = meshAttributes[selectedAttributeIndex];

            foreach (var attr in meshAttributes)
            {
                if (attr.mask != selectedAttribute.mask)
                {
                    continue;
                }

                if (attr.isBaseTexture)
                {
                    return(attr);
                }
            }
            return(null);
        }
Ejemplo n.º 6
0
        private static void TestMeshAttributeContainer(AttributeLayoutContainer meshAttributes, Material mat)
        {
            Assert.IsNotNull(meshAttributes);
            Assert.IsTrue(meshAttributes.shader == mat.shader);
            //test textures preview and default values
            for (int i = 0; i < meshAttributes.attributes.Length; i++)
            {
                AttributeLayout attributeLayout = meshAttributes.attributes[i];

                //preview
                Texture attributeTexture = mat.GetTexture(attributeLayout.propertyTarget);
                Assert.IsTrue(attributeTexture == attributeLayout.previewTexture);
                //default
                Assert.IsTrue(Enum.IsDefined(typeof(MeshChannel), attributeLayout.channel));
                Assert.IsTrue(attributeLayout.min == 0);
                Assert.IsTrue(attributeLayout.max == 1);
                //if the index is part of the enum ComponentIndex
                Assert.IsTrue(Enum.IsDefined(typeof(ComponentIndex), attributeLayout.index));
            }
        }
        public static string CreateShaderMetadataTest(string shaderName)
        {
            //load a polybrush shader
            Shader shaderToTest = Shader.Find(shaderName);

            Assert.IsNotNull(shaderToTest);

            //create base meta data
            AttributeLayout[] attributes = new AttributeLayout[]
            {
                new AttributeLayout(MeshChannel.Color, ComponentIndex.R, Vector2.up, 0, "_Texture1"),
                new AttributeLayout(MeshChannel.Color, ComponentIndex.G, Vector2.up, 0, "_Texture2"),
                new AttributeLayout(MeshChannel.Color, ComponentIndex.B, Vector2.up, 0, "_Texture3"),
                new AttributeLayout(MeshChannel.Color, ComponentIndex.A, Vector2.up, 0, "_Texture4"),
            };

            //call the function that will create the asset containing meta data
            string path = ShaderMetaDataUtility.SaveMeshAttributesData(shaderToTest, attributes, true);

            return(path);
        }
Ejemplo n.º 8
0
        private void Scenes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ListBox listBox = sender as ListBox;
            int     index;

            if (listBox.Items.Count < 1)
            {
                return;
            }
            if (listBox.SelectedItem == null)
            {
                index = 0;
            }
            else
            {
                index = listBox.SelectedIndex;
            }
            string scenePath = (listBox.Items[index] as ListBoxItem).DataContext as string;

            CreateLayout.showScene(this.myContainer, scenePath);
            AttributeLayout.InitSceneAttributeLayout(this, myContainer);
        }
Ejemplo n.º 9
0
        private void DrawConfigurationPanel(MaterialPropertyInfo guiInfo, string propertyName, Material mat)
        {
            using (new GUILayout.HorizontalScope("box"))
            {
                using (new GUILayout.VerticalScope())
                {
                    EditorGUI.BeginChangeCheck();
                    using (new GUILayout.HorizontalScope())
                    {
                        if (!m_LoadedAttributes.HasAttributes(propertyName))
                        {
                            GUILayout.Label(propertyName, GUILayout.Width(100));
                            GUILayout.FlexibleSpace();
                            if (GUILayout.Button("Create attributes", GUILayout.Width(120), GUILayout.Height(16)))
                            {
                                AttributeLayout newAttr = new AttributeLayout();
                                newAttr.propertyTarget = propertyName;
                                m_LoadedAttributes.AddAttribute(newAttr);
                            }
                        }
                        else
                        {
                            guiInfo.IsVisible = EditorGUILayout.Foldout(guiInfo.IsVisible, propertyName, true);
                            if (GUILayout.Button("Erase attributes", GUILayout.ExpandWidth(true), GUILayout.MinWidth(60), GUILayout.MaxWidth(120), GUILayout.Height(16)))
                            {
                                m_LoadedAttributes.RemoveAttribute(propertyName);
                            }
                        }
                    }

                    if (EditorGUI.EndChangeCheck())
                    {
                        UpdatePropertyInfo(guiInfo);
                    }

                    if (m_LoadedAttributes.HasAttributes(propertyName) && guiInfo.IsVisible)
                    {
                        AttributeLayout attr = m_LoadedAttributes.GetAttributes(propertyName);

                        EditorGUILayout.Space();

                        using (new GUILayout.HorizontalScope())
                        {
                            using (new GUILayout.VerticalScope(GUILayout.Width(70), GUILayout.ExpandWidth(false)))
                            {
                                Texture tex = mat.GetTexture(propertyName);
                                EditorGUI.DrawPreviewTexture(
                                    EditorGUILayout.GetControlRect(GUILayout.Width(64), GUILayout.Height(64)),
                                    (tex != null) ? tex : Texture2D.blackTexture);
                            }

                            using (new GUILayout.VerticalScope())
                            {
                                GUILayout.Label("Channel");
                                GUILayout.Label("Index");
                                GUILayout.Label("Range");
                                GUILayout.Label("Group");
                                GUILayout.Label("Is Base Texture");
                            }
                            GUILayout.FlexibleSpace();

                            using (new GUILayout.VerticalScope())
                            {
                                // Channel selection
                                attr.channel =
                                    Styles.ToMeshChannel(EditorGUILayout.Popup(Styles.ToInt(attr.channel), Styles.k_MeshChannel, GUILayout.Width(140)));

                                // Index selection
                                attr.index = (ComponentIndex)GUILayout.Toolbar((int)attr.index, ComponentIndexUtility.ComponentIndexPopupDescriptions, GUILayout.Width(140));

                                // Value range
                                attr.range = EditorGUILayout.Vector2Field("", attr.range, GUILayout.Width(140));

                                // Group selection
                                attr.mask = EditorGUILayout.Popup(attr.mask, AttributeLayout.DefaultMaskDescriptions, GUILayout.Width(140));

                                attr.isBaseTexture = EditorGUILayout.Toggle(attr.isBaseTexture);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 10
0
 public MainWindow()
 {
     InitializeComponent();
     prepareEnv();
     AttributeLayout.InitSceneAttributeLayout(this, myContainer);
 }