static bool IsPackable(Object o) { return(o != null && (o.GetType() == typeof(Sprite) || o.GetType() == typeof(Texture2D) || (o.GetType() == typeof(DefaultAsset) && ProjectWindowUtil.IsFolder(o.GetInstanceID())))); }
public override void Action(int instanceId, string pathName, string resourceFile) { Object o = DoshikScriptImporter.CreateAsset(pathName); ProjectWindowUtil.ShowCreatedAsset(o); }
public static void CreateAuthoringComponentType() { ProjectWindowUtil.CreateScriptAssetFromTemplateFile( $"{TemplatesRoot}/AuthoringComponent.txt", "NewComponent.cs"); }
static void CreateUniversalPipeline() { ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance <CreateUniversalPipelineAsset>(), "UniversalRenderPipelineAsset.asset", null, null); }
public static void CreateMaterialGraph() { ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance <CreateFabricShaderGraph>(), "New Shader Graph.ShaderGraph", null, null); }
public static void CreateNdiResourcesAsset() { var asset = ScriptableObject.CreateInstance <NdiResources>(); ProjectWindowUtil.CreateAsset(asset, "NdiResources.asset"); }
static void CreateLightweightPipeline() { ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance <CreateLightweightPipelineAsset>(), "LightweightRenderPipelineAsset.asset", null, null); }
private static void CreateConverterCSharpScritpt() => ProjectWindowUtil.CreateScriptAssetFromTemplateFile(ConverterTemplatePath, converterBaseName);
// [MenuItem ("Assets/Create/Empty Code Graph Class", false, 0)] public static void CreateEmptyCodeGraph() { ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, CreateInstance <CreateCodeGraphStandard> (), "New Code Graph Class.codegraph", Resources.Load <Texture2D> ("codegraph_256"), null); }
public static void CreatUI(string UIWindowName, string UIcameraKey, UIType UIType, UILayerManager UILayerManager, bool isAutoCreatePrefab) { GameObject uiGo = new GameObject(UIWindowName); Type type = EditorTool.GetType(UIWindowName); UIWindowBase uiBaseTmp = uiGo.AddComponent(type) as UIWindowBase; uiGo.layer = LayerMask.NameToLayer("UI"); uiBaseTmp.m_UIType = UIType; Canvas canvas = uiGo.AddComponent <Canvas>(); if (EditorExpand.isExistShortLayer(UIType.ToString())) { canvas.overrideSorting = true; canvas.sortingLayerName = UIType.ToString(); } uiGo.AddComponent <GraphicRaycaster>(); RectTransform ui = uiGo.GetComponent <RectTransform>(); ui.sizeDelta = Vector2.zero; ui.anchorMin = Vector2.zero; ui.anchorMax = Vector2.one; GameObject BgGo = new GameObject("BG"); BgGo.layer = LayerMask.NameToLayer("UI"); RectTransform Bg = BgGo.AddComponent <RectTransform>(); Bg.SetParent(ui); Bg.sizeDelta = Vector2.zero; Bg.anchorMin = Vector2.zero; Bg.anchorMax = Vector2.one; GameObject rootGo = new GameObject("root"); rootGo.layer = LayerMask.NameToLayer("UI"); RectTransform root = rootGo.AddComponent <RectTransform>(); root.SetParent(ui); root.sizeDelta = Vector2.zero; root.anchorMin = Vector2.zero; root.anchorMax = Vector2.one; uiBaseTmp.m_bgMask = BgGo; uiBaseTmp.m_uiRoot = rootGo; if (UILayerManager) { UILayerManager.SetLayer(uiBaseTmp); } if (isAutoCreatePrefab) { string Path = "Resources/UI/" + UIWindowName + "/" + UIWindowName + ".prefab"; FileTool.CreatFilePath(Application.dataPath + "/" + Path); PrefabUtility.CreatePrefab("Assets/" + Path, uiGo, ReplacePrefabOptions.ConnectToPrefab); } ProjectWindowUtil.ShowCreatedAsset(uiGo); }
public static void CreateGuideWindow() { string UIWindowName = "GuideWindow"; UIType UIType = UIType.TopBar; GameObject uiGo = new GameObject(UIWindowName); Type type = EditorTool.GetType(UIWindowName); GuideWindowBase guideBaseTmp = uiGo.AddComponent(type) as GuideWindowBase; uiGo.layer = LayerMask.NameToLayer("UI"); guideBaseTmp.m_UIType = UIType; Canvas can = uiGo.AddComponent <Canvas>(); uiGo.AddComponent <GraphicRaycaster>(); can.overrideSorting = true; can.sortingLayerName = "Guide"; RectTransform ui = uiGo.GetComponent <RectTransform>(); ui.sizeDelta = Vector2.zero; ui.anchorMin = Vector2.zero; ui.anchorMax = Vector2.one; GameObject BgGo = new GameObject("BG"); BgGo.layer = LayerMask.NameToLayer("UI"); RectTransform Bg = BgGo.AddComponent <RectTransform>(); Bg.SetParent(ui); Bg.sizeDelta = Vector2.zero; Bg.anchorMin = Vector2.zero; Bg.anchorMax = Vector2.one; GameObject rootGo = new GameObject("root"); rootGo.layer = LayerMask.NameToLayer("UI"); RectTransform root = rootGo.AddComponent <RectTransform>(); root.SetParent(ui); root.sizeDelta = Vector2.zero; root.anchorMin = Vector2.zero; root.anchorMax = Vector2.one; GameObject mask = new GameObject("mask"); mask.layer = LayerMask.NameToLayer("UI"); RectTransform maskrt = mask.AddComponent <RectTransform>(); Image img = mask.AddComponent <Image>(); img.color = new Color(0, 0, 0, 0.75f); maskrt.SetParent(root); maskrt.sizeDelta = Vector2.zero; maskrt.anchorMin = Vector2.zero; maskrt.anchorMax = Vector2.one; GameObject tips = new GameObject("Tips"); tips.layer = LayerMask.NameToLayer("UI"); RectTransform tipsrt = tips.AddComponent <RectTransform>(); tipsrt.SetParent(root); guideBaseTmp.m_objectList.Add(tips); GameObject Text_tips = new GameObject("Text_tip"); Text_tips.layer = LayerMask.NameToLayer("UI"); RectTransform txt_tipsrt = Text_tips.AddComponent <RectTransform>(); //Text text = Text_tips.AddComponent<Text>(); txt_tipsrt.SetParent(tipsrt); guideBaseTmp.m_objectList.Add(Text_tips); //guideBaseTmp.m_mask = img; //guideBaseTmp.m_TipText = text; //guideBaseTmp.m_TipTransfrom = txt_tipsrt; guideBaseTmp.m_bgMask = BgGo; guideBaseTmp.m_uiRoot = rootGo; string Path = "Resources/UI/" + UIWindowName + "/" + UIWindowName + ".prefab"; FileTool.CreatFilePath(Application.dataPath + "/" + Path); PrefabUtility.CreatePrefab("Assets/" + Path, uiGo, ReplacePrefabOptions.ConnectToPrefab); ProjectWindowUtil.ShowCreatedAsset(uiGo); }
public static void CreateExample_53_CustomSO_2() { var so2 = ScriptableObject.CreateInstance <CustomSO_2>(); ProjectWindowUtil.CreateAsset(so2, "CreateExample_53_CustomSO_2.asset"); }
public override void Action(int instanceId, string pathName, string resourceFile) { var newAsset = CreateInstance <RenderPipelineResources>(); newAsset.name = Path.GetFileName(pathName); // Load default renderPipelineResources / Material / Shader string HDRenderPipelinePath = HDEditorUtils.GetHDRenderPipelinePath(); string CorePath = HDEditorUtils.GetCorePath(); newAsset.defaultDiffuseMaterial = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/DefaultHDMaterial.mat"); newAsset.defaultDecalMaterial = Load <Material>(HDRenderPipelinePath + "RenderPipelineResources/DefaultHDDecalMaterial.mat"); newAsset.defaultShader = Load <Shader>(HDRenderPipelinePath + "Material/Lit/Lit.shader"); newAsset.debugFontTexture = Load <Texture2D>(HDRenderPipelinePath + "RenderPipelineResources/DebugFont.tga"); newAsset.debugDisplayLatlongShader = Load <Shader>(HDRenderPipelinePath + "Debug/DebugDisplayLatlong.Shader"); newAsset.debugViewMaterialGBufferShader = Load <Shader>(HDRenderPipelinePath + "Debug/DebugViewMaterialGBuffer.Shader"); newAsset.debugViewTilesShader = Load <Shader>(HDRenderPipelinePath + "Debug/DebugViewTiles.Shader"); newAsset.debugFullScreenShader = Load <Shader>(HDRenderPipelinePath + "Debug/DebugFullScreen.Shader"); newAsset.debugColorPickerShader = Load <Shader>(HDRenderPipelinePath + "Debug/DebugColorPicker.Shader"); newAsset.deferredShader = Load <Shader>(HDRenderPipelinePath + "Lighting/Deferred.Shader"); newAsset.colorPyramidCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipelineResources/ColorPyramid.compute"); newAsset.depthPyramidCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipelineResources/DepthPyramid.compute"); newAsset.copyChannelCS = Load <ComputeShader>(CorePath + "CoreResources/GPUCopy.compute"); newAsset.texturePaddingCS = Load <ComputeShader>(CorePath + "CoreResources/TexturePadding.compute"); newAsset.applyDistortionCS = Load <ComputeShader>(HDRenderPipelinePath + "RenderPipelineResources/ApplyDistorsion.compute"); newAsset.clearDispatchIndirectShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/cleardispatchindirect.compute"); newAsset.buildDispatchIndirectShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/builddispatchindirect.compute"); newAsset.buildScreenAABBShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/scrbound.compute"); newAsset.buildPerTileLightListShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild.compute"); newAsset.buildPerBigTileLightListShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild-bigtile.compute"); newAsset.buildPerVoxelLightListShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/lightlistbuild-clustered.compute"); newAsset.buildMaterialFlagsShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/materialflags.compute"); newAsset.deferredComputeShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/LightLoop/Deferred.compute"); newAsset.deferredDirectionalShadowComputeShader = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/DeferredDirectionalShadow.compute"); newAsset.volumeVoxelizationCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Volumetrics/VolumeVoxelization.compute"); newAsset.volumetricLightingCS = Load <ComputeShader>(HDRenderPipelinePath + "Lighting/Volumetrics/VolumetricLighting.compute"); newAsset.subsurfaceScatteringCS = Load <ComputeShader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/SubsurfaceScattering.compute"); newAsset.subsurfaceScattering = Load <Shader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/SubsurfaceScattering.shader"); newAsset.combineLighting = Load <Shader>(HDRenderPipelinePath + "Material/SubsurfaceScattering/CombineLighting.shader"); // General newAsset.cameraMotionVectors = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/CameraMotionVectors.shader"); newAsset.copyStencilBuffer = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/CopyStencilBuffer.shader"); newAsset.copyDepthBuffer = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/CopyDepthBuffer.shader"); newAsset.blit = Load <Shader>(HDRenderPipelinePath + "RenderPipelineResources/Blit.shader"); // Sky newAsset.blitCubemap = Load <Shader>(HDRenderPipelinePath + "Sky/BlitCubemap.shader"); newAsset.buildProbabilityTables = Load <ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/BuildProbabilityTables.compute"); newAsset.computeGgxIblSampleData = Load <ComputeShader>(HDRenderPipelinePath + "Material/GGXConvolution/ComputeGgxIblSampleData.compute"); newAsset.GGXConvolve = Load <Shader>(HDRenderPipelinePath + "Material/GGXConvolution/GGXConvolve.shader"); newAsset.opaqueAtmosphericScattering = Load <Shader>(HDRenderPipelinePath + "Sky/OpaqueAtmosphericScattering.shader"); newAsset.hdriSky = Load <Shader>(HDRenderPipelinePath + "Sky/HDRISky/HDRISky.shader"); newAsset.proceduralSky = Load <Shader>(HDRenderPipelinePath + "Sky/ProceduralSky/ProceduralSky.shader"); // Skybox/Cubemap is a builtin shader, must use Sahder.Find to access it. It is fine because we are in the editor newAsset.skyboxCubemap = Shader.Find("Skybox/Cubemap"); // Material newAsset.preIntegratedFGD = Load <Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD.shader"); newAsset.preIntegratedFGD_AxFWard = Load <Shader>(HDRenderPipelinePath + "Material/PreIntegratedFGD_AxFWard.shader"); // BMAYAUX (18/05/28) // Utilities / Core newAsset.encodeBC6HCS = Load <ComputeShader>(CorePath + "CoreResources/EncodeBC6H.compute"); newAsset.cubeToPanoShader = Load <Shader>(CorePath + "CoreResources/CubeToPano.shader"); newAsset.blitCubeTextureFace = Load <Shader>(CorePath + "CoreResources/BlitCubeTextureFace.shader"); // Shadow newAsset.shadowClearShader = Load <Shader>(CorePath + "Shadow/ShadowClear.shader"); newAsset.shadowBlurMoments = Load <ComputeShader>(CorePath + "Shadow/ShadowBlurMoments.compute"); newAsset.debugShadowMapShader = Load <Shader>(CorePath + "Shadow/DebugDisplayShadowMap.shader"); AssetDatabase.CreateAsset(newAsset, pathName); ProjectWindowUtil.ShowCreatedAsset(newAsset); }
static void CreateHDRenderPipeline() { var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon"); ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreateNewAssetHDRenderPipeline>(), "New HDRenderPipelineAsset.asset", icon, null); }
public override void Action(int instanceId, string pathName, string resourceFile) { ProjectWindowUtil.ShowCreatedAsset(PrefabUtility.CreateEmptyPrefab(pathName)); }
static void CreateCustomRuleTile() { ProjectWindowUtil.CreateScriptAssetFromTemplateFile("Assets/Tilemap/Tiles/Rule Tile/ScriptTemplates/NewCustomRuleTile.cs.txt", "NewCustomRuleTile.cs"); }
public override void Action(int instanceId, string pathName, string resourceFile) { Object o = CreateScriptAssetFromTemplate(pathName, resourceFile); ProjectWindowUtil.ShowCreatedAsset(o); }
static void CreateModuleSet() { var mset = ScriptableObject.CreateInstance <ModuleSet>(); ProjectWindowUtil.CreateAsset(mset, "New Module Set.asset"); }
public override void Action(int instanceId, string pathName, string resourceFile) { Object script = TextFileTemplateConverter.Convert(pathName, resourceFile); ProjectWindowUtil.ShowCreatedAsset(script); }
public static void CreateAsset <T>() where T : ScriptableObject { var asset = ScriptableObject.CreateInstance <T>(); ProjectWindowUtil.CreateAsset(asset, "New " + typeof(T).Name + ".asset"); }
public override void Action(int instanceId, string pathName, string resourceFile) { Object o = CodeTemplates.CreateScript(pathName, resourceFile, m_WipeString); ProjectWindowUtil.ShowCreatedAsset(o); }
static void MenuCreateDiffusionProfile() { var icon = EditorGUIUtility.FindTexture("ScriptableObject Icon"); ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, ScriptableObject.CreateInstance <DoCreateNewAssetDiffusionProfileSettings>(), "New Diffusion Profile.asset", icon, null); }
static void CreatePrefabBrush() { ProjectWindowUtil.CreateAsset(ScriptableObject.CreateInstance <PrefabBrush>(), "New Prefab Brush.asset"); }
static void MenuCreateCustomRenderersPassShader() { string templatePath = $"{HDUtils.GetHDRenderPipelinePath()}/Editor/RenderPipeline/CustomPass/CustomPassRenderersShader.template"; ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, "New Renderers CustomPass.shader"); }
private void Create() { SchemaName = EditorGUILayout.TextField("Schema Name: ", SchemaName); EditorGUILayout.Space(); // Divisor // Loads the spreadsheet file and splits the 2 first rows of the document in order to store them in an array if (GUILayout.Button("Load CSV file")) { nameOfFile = "data1"; TextAsset data = Resources.Load <TextAsset>(nameOfFile); rows = data.text.Split(new char[] { '\n' }); string[] dataType = rows[0].Split(new char[] { ';' }); string[] dataName = rows[1].Split(new char[] { ';' }); string[] dataTest = rows[2].Split(new char[] { ';' }); arrayTypeName = new string[dataType.Length, 2]; for (int i = 0; i < dataType.Length; i++) { arrayTypeName[i, 0] = dataType[i]; Debug.Log("dataType[" + i + "]: " + dataType[i]); for (int j = 1; j < 2; j++) { arrayTypeName[i, j] = dataName[i]; } } for (int i = 0; i < dataType.Length; i++) { for (int j = 0; j < 2; j++) { Debug.Log("arrayTypeName[" + i + ", " + j + "]: " + arrayTypeName[i, j]); } } // Creation of the script that will be the base the scriptable objects, with the data names and types path = Application.dataPath + "/" + nameOfFile + ".cs"; if (!File.Exists(path)) { File.WriteAllText(path, "using UnityEngine;\n\n" + "[CreateAssetMenu(fileName = \"New " + SchemaName + "\", menuName = \"" + SchemaName + "\")]\n" + // fileName = name variable // menuName = ask user input "public class " + nameOfFile + " : ScriptableObject\n" + "{\n"); Debug.Log("File created!"); } for (int i = 0; i < dataType.Length; i++) { string temp; for (int j = 0; j < 1; j++) { temp = "\tpublic " + arrayTypeName[i, j] + " " + arrayTypeName[i, j + 1] + ";\n"; Debug.Log(temp); content = temp; } File.AppendAllText(path, content); } File.AppendAllText(path, "\n}"); AssetDatabase.Refresh(); } EditorGUILayout.Space(); // Divisor // Refreshes all the ScriptableObjects search to find the new one just created GetAllScriptableObjects(); Debug.Log("names.Length: " + names.Length); for (int i = 0; i < names.Length; i++) { if (names[i] == nameOfFile) { selectedIndex = i; } } // Creates all the scriptable objects as many rows with data the spreadsheet has if (GUILayout.Button("Create")) { for (int i = 2; i < rows.Length - 1; i++) { var asset = ScriptableObject.CreateInstance(types[selectedIndex]); ProjectWindowUtil.StartNameEditingIfProjectWindowExists( asset.GetInstanceID(), ScriptableObject.CreateInstance <EndNameEdit>(), //string.Format("{0}.asset", names[selectedIndex]), // File name string.Format("{0}.asset", SchemaName), // SchemaName name AssetPreview.GetMiniThumbnail(asset), null); objects.Add((data1)asset); } //Debug.Log(objects[1]); } }
static void MenuCreateCustomPassCSharpScript() { string templatePath = $"{HDUtils.GetHDRenderPipelinePath()}/Editor/RenderPipeline/CustomPass/CustomPassCSharpScript.template"; ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, "New Custom Pass.cs"); }
public static void Create() { ProjectWindowUtil.CreateAsset(CreateInstance <AddressableAssetsInfo>(), "AddressableAssetsInfo.asset"); }
static void MenuCreatePostProcessShader() { string templatePath = $"{HDUtils.GetHDRenderPipelinePath()}/Editor/PostProcessing/Templates/CustomPostProcessingShader.template"; ProjectWindowUtil.CreateScriptAssetFromTemplateFile(templatePath, "New Post Process Shader.shader"); }
public static void CreateSystem() { ProjectWindowUtil.CreateScriptAssetFromTemplateFile( $"{TemplatesRoot}/System.txt", "NewSystem.cs"); }
public static void CreateScriptFromTemplate() { ProjectWindowUtil.CreateScriptAssetFromTemplateFile(pathToYourScriptTemplate, "Event_New.cs"); }