Exemplo n.º 1
0
        public void SetOutputSizeEnumTest()
        {
            Substance.Game.Substance subs  = SubstanceExtensionsTestData.Instance.TestSubstance;
            SubstanceGraph           graph = subs.graphs[0];

            int cachedSize = graph.GetInputVector2Int(SubstanceGraphExtensions.OutputSizeParameter)[0];
            SubstanceOutputSize newSize = cachedSize == 9 ? SubstanceOutputSize._1024 : SubstanceOutputSize._512;

            Debug.Log(graph.GetGeneratedTextures()[0].width);

            graph.SetOutputSize(newSize);

            //NativeFunctions.cppProcessOutputQueue();
            graph.QueueForRender();
            Substance.Game.Substance.RenderSubstancesSync();

            int width = graph.GetGeneratedTextures()[0].width;


            Debug.Log(graph.GetGeneratedTextures()[0].width);

            Assert.AreEqual(width, (newSize == SubstanceOutputSize._1024 ? 1024 : 512));

            graph.SetOutputSize(cachedSize);

            //NativeFunctions.cppProcessOutputQueue();
            graph.QueueForRender();
            Substance.Game.Substance.RenderSubstancesSync();
        }
Exemplo n.º 2
0
        public void SetOutputSizeTest()
        {
            Substance.Game.Substance subs  = SubstanceExtensionsTestData.Instance.TestSubstance;
            SubstanceGraph           graph = subs.graphs[0];

            int cachedSize = graph.GetInputVector2Int(SubstanceGraphExtensions.OutputSizeParameter)[0];
            int newSize    = cachedSize == 9 ? 10 : 9;

            graph.SetOutputSize(newSize);
            graph.QueueForRender();

            Substance.Game.Substance.RenderSubstancesSync();

            int width = graph.GetGeneratedTextures()[0].width;

            Debug.Log(string.Format("{0} | {1} | {2} - {3}", width, (newSize == 10 ? 1024 : 512), cachedSize, newSize));

            Assert.AreEqual(width, (newSize == 10 ? 1024 : 512));

            graph.SetOutputSize(cachedSize);
            graph.QueueForRender();

            Substance.Game.Substance.RenderSubstancesSync();
        }
        private void OnGUI()
        {
            EditorGUI.BeginChangeCheck();
            substance = (Substance.Game.Substance)EditorGUILayout.ObjectField(SubstanceLabel, substance, typeof(Substance.Game.Substance), false);
            if (EditorGUI.EndChangeCheck())
            {
                RegenerateTextures();
            }

            //Safety check since recompilation or adjustments to the substance seem to remove the reference to the substance.
            if ((substance == null && graphNames.Count > 0) || (substance != null && textures.Count == 0))
            {
                RegenerateTextures();
            }

            if (graphNames.Count > 0)
            {
                DrawTextures();
            }

            EditorGUILayout.Space();

            bool cachedGUI = GUI.enabled;

            if (substance == null)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button(ButtonLabel))
            {
                ExportTextures();
            }
            if (!GUI.enabled)
            {
                GUI.enabled = cachedGUI;
            }

            if (substance != null)
            {
                EditorGUILayout.Space();

                for (int i = 0; i < textureNames.Count; i++)
                {
                    graphExportExpansions[i] = EditorGUILayout.Foldout(graphExportExpansions[i], new GUIContent(graphNames[i], string.Format("Export individual textures for the [{0}] graph.", graphNames[i])), true);

                    if (graphExportExpansions[i])
                    {
                        for (int j = 0; j < textureNames[i].Count; j++)
                        {
                            Rect buttonRect = EditorGUILayout.GetControlRect(GUILayout.Height(EditorGUIUtility.singleLineHeight + (EditorGUIUtility.standardVerticalSpacing * 1f)));
                            buttonRect.Set(buttonRect.x + EditorGUIUtility.singleLineHeight, buttonRect.y, buttonRect.width - EditorGUIUtility.singleLineHeight, buttonRect.height);

                            if (GUI.Button(buttonRect, new GUIContent(textureNames[i][j], string.Format("Export the [{0}] texture from the [{1}] graph.", textureNames[i][j], graphNames[i]))))
                            {
                                ExportTexture(textureNames[i][j], i, j);
                            }
                        }
                    }
                }
            }
        }