예제 #1
0
        static void MenuItem_SetBrushReleaseVersions()
        {
            // Go through brushes we're about to release, and set their "first released version"

            // Assume the release version is current version, minus the "beta" tag
            string desiredVersion; {
                var config = GameObject.Find("/App/Config").GetComponent <Config>();
                desiredVersion = config.m_VersionNumber;
                if (desiredVersion.EndsWith("b"))
                {
                    desiredVersion = desiredVersion.Substring(0, desiredVersion.Length - 1);
                }
                else
                {
                    Debug.LogError(
                        $"This doesn't look like an in-development build of {App.kAppDisplayName}");
                    return;
                }
            }

            TiltBrushManifest manifest = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>(
                "Assets/Manifest.asset");

            foreach (BrushDescriptor desc in manifest.Brushes.Concat(manifest.CompatibilityBrushes))
            {
                if (string.IsNullOrEmpty(desc.m_CreationVersion))
                {
                    Debug.LogFormat("Brush {0} -> version {1}", desc.name, desiredVersion);
                    desc.m_CreationVersion = desiredVersion;
                    EditorUtility.SetDirty(desc);
                }
            }
        }
예제 #2
0
        private static Dictionary <Guid, BrushDescriptor> GetBrushes()
        {
            var cat = new Dictionary <Guid, BrushDescriptor>();
            // We don't export experimental brushes brushes in the live prod build.
            TiltBrushManifest productionManifest = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>(
                "Assets/Manifest.asset");

            foreach (BrushDescriptor desc in productionManifest.UniqueBrushes())
            {
                cat.Add(desc.m_Guid, desc);
            }

            return(cat);
        }
예제 #3
0
        static IEnumerable <BrushDescriptor> GetBrushesToExport(TiltBrushManifest manifest)
        {
            HashSet <BrushDescriptor> all = new HashSet <BrushDescriptor>();

            foreach (var brush in manifest.Brushes.Concat(manifest.CompatibilityBrushes))
            {
                for (var current = brush; current != null; current = current.m_Supersedes)
                {
                    all.Add(current);
                }
            }

            return(all);
        }
예제 #4
0
        static void ListBrushes()
        {
            brushList = new StringBuilder();

            Object[] defaultBrushes      = Resources.LoadAll("Brushes", typeof(BrushDescriptor)).ToArray();
            var      experimentalBrushes = Resources.LoadAll("X/Brushes", typeof(BrushDescriptor)).ToArray();

            brushManifest  = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>("Assets/Manifest.asset");
            brushManifestX = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>("Assets/Manifest_Experimental.asset");

            deprecated = new List <Guid>();

            foreach (BrushDescriptor b in defaultBrushes)
            {
                if (b.m_Supersedes != null)
                {
                    deprecated.Add(b.m_Supersedes.m_Guid);
                }
            }
            foreach (BrushDescriptor b in experimentalBrushes)
            {
                if (b.m_Supersedes != null)
                {
                    deprecated.Add(b.m_Supersedes.m_Guid);
                }
            }

            foreach (BrushDescriptor brush in defaultBrushes)
            {
                AppendValidBrushString(brush, false);
            }
            foreach (BrushDescriptor brush in experimentalBrushes)
            {
                try { AppendValidBrushString(brush, true); }
                catch (Exception UnassignedReferenceException)
                {
                    Debug.Log($"Experimental brush loading error: {UnassignedReferenceException}");
                }
            }

            Debug.Log($"{brushList}");
        }
예제 #5
0
 /// Append the contents of rhs to this, eliminating duplicates
 public void AppendFrom(TiltBrushManifest rhs)
 {
     AppendUnique(ref Brushes, rhs.Brushes);
     AppendUnique(ref Environments, rhs.Environments);
     AppendUnique(ref CompatibilityBrushes, rhs.CompatibilityBrushes);
 }
예제 #6
0
        private static void ExportEnvironments()
        {
#if !GAMEOBJ_EXPORT_TO_GLTF
            Debug.LogError("Enable the define and fix up the code");
#else
            // Save the original RenderSettings
            Environment.RenderSettingsLite originalRenderSettings = Environment.GetRenderSettings();

            // Clear out the existing environments directory to do a clean export
            string projectPath           = Path.GetDirectoryName(Application.dataPath);
            string environmentExportPath = Path.Combine(projectPath,
                                                        ExportUtils.kProjectRelativeEnvironmentExportRoot);
            try {
                Directory.Delete(environmentExportPath, recursive: true);
            } catch (DirectoryNotFoundException) {
                // It's okay if this directory doesn't exist yet as it will be created later.
            }

            // Clear out the existing textures directory to do a clean export
            string textureExportPath = Path.Combine(projectPath,
                                                    ExportUtils.kProjectRelativeTextureExportRoot);
            try {
                Directory.Delete(textureExportPath, recursive: true);
            } catch (DirectoryNotFoundException) {
                // It's okay if this directory doesn't exist yet as it will be created later.
            }
            if (!FileUtils.InitializeDirectoryWithUserError(
                    textureExportPath, "Failed to export, can't create texture export directory"))
            {
                return;
            }

            // Get the environment
            TiltBrushManifest manifest = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>("Assets/Manifest.asset");
            foreach (Environment env in manifest.Environments)
            {
                // Copy over the RenderSettings
                Environment.SetRenderSettings(env.m_RenderSettings);

                // Set up the environment
                string envGuid = env.m_Guid.ToString("D");
                Debug.LogFormat("Exporting environment: {0}", env.m_RenderSettings.m_EnvironmentPrefab);
                GameObject envPrefab     = Resources.Load <GameObject>(env.m_RenderSettings.m_EnvironmentPrefab);
                GameObject envGameObject = UObject.Instantiate(envPrefab);
                envGameObject.name = envGuid;

                // Hide game objects that don't get exported to Poly.
                foreach (Transform child in envGameObject.transform)
                {
                    if (SceneSettings.ExcludeFromPolyExport(child))
                    {
                        child.gameObject.SetActive(false);
                    }
                }

                // Set up the environment export directory
                string directoryName = Path.Combine(environmentExportPath, envGuid);
                if (!FileUtils.InitializeDirectoryWithUserError(
                        directoryName, "Failed to export, can't create environment export directory"))
                {
                    return;
                }

                string basename = FileUtils.SanitizeFilename(envGameObject.name);
                string gltfName = Path.Combine(directoryName, basename + ".gltf");

                var exporter = new ExportGlTF();
                exporter.ExportGameObject(envGameObject, gltfName, env);

                // DestroyImmediate is required because editor mode never runs object garbage collection.
                UObject.DestroyImmediate(envGameObject);
            }

            // Restore the original RenderSettings
            Environment.SetRenderSettings(originalRenderSettings);
#endif
        }
예제 #7
0
        private static void TagBrushes()
        {
            var whiteboardBrushes = new List <string>
            {
                "Marker",
                "TaperedMarker",
                "SoftHighlighter",
                "CelVinyl",
                "Dots",
                "Icing",
                "Toon",
                "Wire",
                "MatteHull",
                "ShinyHull",
                "UnlitHull",
            };

            TiltBrushManifest brushManifest  = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>("Assets/Manifest.asset");
            TiltBrushManifest brushManifestX = AssetDatabase.LoadAssetAtPath <TiltBrushManifest>("Assets/Manifest_Experimental.asset");

            var guids = AssetDatabase.FindAssets("t:BrushDescriptor");

            foreach (var guid in guids)
            {
                string          path  = AssetDatabase.GUIDToAssetPath(guid);
                BrushDescriptor brush = AssetDatabase.LoadAssetAtPath <BrushDescriptor>(path);

                brush.m_Tags = new List <string>();

                EditorUtility.SetDirty(brush);

                if (whiteboardBrushes.Contains(brush.DurableName))
                {
                    brush.m_Tags.Add("whiteboard");
                }
                if (brushManifest.Brushes.Contains(brush))
                {
                    brush.m_Tags.Add("default");
                }
                if (brushManifestX.Brushes.Contains(brush))
                {
                    brush.m_Tags.Add("experimental");
                }
                if (brush.m_AudioReactive)
                {
                    brush.m_Tags.Add("audioreactive");
                }

                if (brush.m_BrushPrefab == null)
                {
                    continue;
                }
                if (brush.m_BrushPrefab.GetComponent <HullBrush>() != null)
                {
                    brush.m_Tags.Add("hull");
                }
                if (brush.m_BrushPrefab.GetComponent <GeniusParticlesBrush>() != null)
                {
                    brush.m_Tags.Add("particle");
                }
                if (brush.m_BrushPrefab.GetComponent <ParentBrush>() != null)
                {
                    brush.m_Tags.Add("broken");
                }
            }
        }