Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

polypulse

1
Posts
1
Topics
A member registered Mar 05, 2019

Recent community posts

(1 edit)

Hi guys,

Is there a way to use an external IDE with snippets? Maybe that should be something on the road map a long with the ability to include other cginc files. Anyways, for now I've been using this snippet to set SnippetBase.code in the AsssetPostprocessor:

using System.IO;
using UnityEditor;
using RaymarchingToolkit; public class UpdateSnippet : AssetPostprocessor
{
    private static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
    {
        for (int ai = 0; ai < importedAssets.Length; ai++)
        {
            string fileNameWithoutExt = Path.GetFileNameWithoutExtension(importedAssets[ai]);
            string ext = Path.GetExtension(importedAssets[ai]);             // Look for files with hlsl extension.
            if (ext != ".hlsl")
                continue;             string[] guids = AssetDatabase.FindAssets("t:ObjectSnippet " + fileNameWithoutExt );
            for (int gi = 0; gi < guids.Length; gi++)
            {
                string path = AssetDatabase.GUIDToAssetPath(guids[gi]);                 // Look for matching ObjectSnippet ScriptableObject in project with the same name.
                ObjectSnippet snippetBase = AssetDatabase.LoadAssetAtPath<ObjectSnippet>(path);
                if (snippetBase == null)
                    continue;                 string file = File.ReadAllText(importedAssets[ai]);
                snippetBase.code = file;                 AssetDatabase.SaveAssets();
                return;
            }
        }
    }
}