protected static VisualElement AddNewGraphButton <T>( IGraphTemplate template, string promptTitle = null, string buttonText = null, string prompt = null, string assetExtension = k_AssetExtension) where T : ScriptableObject, IGraphAssetModel { promptTitle = promptTitle ?? string.Format(k_PromptToCreateTitle, template.GraphTypeName); buttonText = buttonText ?? string.Format(k_ButtonText, template.GraphTypeName); prompt = prompt ?? string.Format(k_PromptToCreate, template.GraphTypeName); var container = new VisualElement(); container.AddToClassList("onboarding-block"); var label = new Label(prompt); container.Add(label); var button = new Button { text = buttonText }; button.clicked += () => { var graphAsset = GraphAssetCreationHelpers <T> .PromptToCreate(template, promptTitle, prompt, assetExtension); Selection.activeObject = graphAsset as Object; }; container.Add(button); return(container); }
public CreateGraphAssetAction(Type graphType, Type assetType, string name = "", string assetPath = "", GameObject instance = null, bool writeOnDisk = true, IGraphTemplate graphTemplate = null) { GraphType = graphType; AssetType = assetType; Name = name; AssetPath = assetPath; Instance = instance; WriteOnDisk = writeOnDisk; GraphTemplate = graphTemplate; }
public static IGraphAssetModel PromptToCreate(IGraphTemplate template, string title, string prompt, string assetExtension) { var path = EditorUtility.SaveFilePanelInProject(title, template.DefaultAssetName, assetExtension, prompt); if (path.Length != 0) { string fileName = Path.GetFileNameWithoutExtension(path); return(CreateGraphAsset(template.StencilType, fileName, path, template)); } return(null); }
public static IGraphAssetModel CreateGraphAsset(Type stencilType, string name, string assetPath, IGraphTemplate graphTemplate = null) { IGraphAssetModel graphAssetModel; graphAssetModel = IGraphAssetModelHelper.Create(name, assetPath, typeof(TGraphAssetModelType)); graphAssetModel.CreateGraph(name, stencilType, assetPath != null); graphTemplate?.InitBasicGraph(graphAssetModel.GraphModel); AssetDatabase.SaveAssets(); return(graphAssetModel); }
public static void CreateInProjectWindow(IGraphTemplate template, CommandDispatcher commandDispatcher, string path) { var asset = ScriptableObject.CreateInstance <TGraphAssetModelType>(); var endAction = ScriptableObject.CreateInstance <DoCreateAsset>(); endAction.SetUp(commandDispatcher, asset, template); ProjectWindowUtil.StartNameEditingIfProjectWindowExists( asset.GetInstanceID(), endAction, $"{path}/{template.DefaultAssetName}.asset", AssetPreview.GetMiniThumbnail(asset), null); }
public CreateGraphAssetAction(Type stencilType, string name = "", string assetPath = "", GameObject instance = null, bool writeOnDisk = true, IGraphTemplate graphTemplate = null) : this(stencilType, typeof(VSGraphModel), typeof(VSGraphAssetModel), name, assetPath, instance, writeOnDisk, graphTemplate) { }
public static IGraphAssetModel CreateInMemoryGraphAsset(Type stencilType, string name, IGraphTemplate graphTemplate = null) { return(CreateGraphAsset(stencilType, name, null, graphTemplate)); }
public void SetUp(CommandDispatcher commandDispatcher, IGraphAssetModel assetModel, IGraphTemplate template) { m_CommandDispatcher = commandDispatcher; m_Template = template; m_AssetModel = assetModel; }
public static void CreateGraphAsset <TStencilType, TAssetType>(string graphAssetName = k_DefaultGraphAssetName, IGraphTemplate template = null) where TStencilType : Stencil where TAssetType : GraphAssetModel { string uniqueFilePath = VseUtility.GetUniqueAssetPathNameInActiveFolder(graphAssetName); string modelName = Path.GetFileName(uniqueFilePath); var endAction = CreateInstance <DoCreateVisualScriptAsset>(); endAction.Template = template; endAction.StencilType = typeof(TStencilType); endAction.AssetType = typeof(TAssetType); ProjectWindowUtil.StartNameEditingIfProjectWindowExists(0, endAction, modelName, GetIcon(), null); }
public static void PromptToCreate(Type stencilType, Store store, string graphTitle, string assetName, IGraphTemplate template = null) { var path = EditorUtility.SaveFilePanelInProject( "Create visual script", assetName, "asset", "Create a new visual script for " + graphTitle); if (path.Length != 0) { string fileName = Path.GetFileNameWithoutExtension(path); store.Dispatch(new CreateGraphAssetAction(stencilType, fileName, path, graphTemplate: template)); } }
public static void PromptToCreate(this IGraphTemplate template, Store store, string graphTitle, string assetName) { PromptToCreate(template.StencilType, store, graphTitle, assetName, template); }