Public Member Functions | Properties | Events | List of all members
Project Interface Reference

Create and access nodes and resources. More...

Public Member Functions

Brush CreateBrush (string name, BrushLibrary parent, BrushTypeEnum brushType)
 Creates a brush in the Brushes library. More...
 
Brush CreateBrush (string name, BrushLibrary parent, BrushType brushType)
 Creates a brush in the Brushes library. More...
 
Node CreateComponentNode (string name, Node parent, ComponentType componentType)
 
DataSource CreateDataSource (string name, DataSourceType dataSourceType)
 
NodeComponent CreateNodeComponent (string name, NodeComponentHost parent, NodeComponentType nodeComponentType)
 Creates a node component to the specified parent. More...
 
ProjectItem CreateProjectItem (Type projectItemType, string name, ProjectItem parent)
 Creates a project item. More...
 
CreateProjectItem< T > (string name, ProjectItem parent)
 Creates a project item. More...
 
RenderPass CreateRenderPass (string name, AbstractComposer parent, RenderPassType renderPassType)
 Creates a render pass. More...
 
ProjectItem GetProjectItem (string projectItemPath)
 Gets a project item. More...
 
bool IsAbstract (Type projectItemType)
 

Properties

ProjectItem ActiveComposition [get]
 
AnimationClipLibrary AnimationClipLibrary [get]
 
AnimationLibrary AnimationLibrary [get]
 
ApplicationConfigurationResourceFileDirectory ApplicationDirectory [get]
 
Asset3DImportSourceDirectory Asset3DImportSourceDirectory [get]
 
BinaryShaderFormatLibrary BinaryShaderFormatLibrary [get]
 
BrushLibrary BrushLibrary [get]
 Gets the Brushes library which stores brushes used in a Kanzi Studio project. More...
 
BrushTypeLibrary BrushTypeLibrary [get]
 Gets the brush types available in a Kanzi Studio project. More...
 
ComponentTypeLibrary ComponentTypeLibrary [get]
 
ComposerLibrary ComposerLibrary [get]
 Gets the Render Pass library which stores the legacy render passes used in a Kanzi Studio project. More...
 
DataSourceLibrary DataSourceLibrary [get]
 
DataSourceTypeLibrary DataSourceTypeLibrary [get]
 
EnginePluginLibrary EnginePluginLibrary [get]
 
FontDirectory FontDirectory [get]
 
GenericResourceFileDirectory GenericResourceFileDirectory [get]
 
IEnumerable< Guide > Guides [get]
 
ImageDirectory ImageDirectory [get]
 
MaterialLibrary MaterialLibrary [get]
 Gets the Material library which contains the materials in a Kanzi Studio project. More...
 
MaterialTypeLibrary MaterialTypeLibrary [get]
 Gets the Material Types library which contains the material types in a Kanzi Studio project. More...
 
MeshLibrary MeshLibrary [get]
 Gets the Meshes library which contains the meshes in a Kanzi Studio project. More...
 
NodeComponentTypeLibrary NodeComponentTypeLibrary [get]
 Gets the node component types available in a Kanzi Studio project. More...
 
PageTransitionCollectionLibrary PageTransitionCollectionLibrary [get]
 Gets the Page Transitions library which contains the page transitions in a Kanzi Studio project. More...
 
PipelineItemLibrary PipelineItemLibrary [get]
 Gets the Object Sources Library which stores the object sources and filters in a Kanzi Studio project. More...
 
PrefabLibrary PrefabLibrary [get]
 Gets the Prefabs library which contains the prefabs used in a Kanzi Studio project. More...
 
ProjectReferenceLibrary ProjectReferenceLibrary [get]
 
PropertyTypeLibrary PropertyTypeLibrary [get]
 Gets the Property Types library which stores all property types you create in a Kanzi Studio project. More...
 
RenderPassTypeLibrary RenderPassTypeLibrary [get]
 Gets the render pass types available in a Kanzi Studio project. More...
 
Screen Screen [get]
 Gets the Screen node in a Kanzi Studio project. More...
 
ShaderSourceDirectory ShaderSourceDirectory [get]
 
ShortcutLibrary ShortcutLibrary [get]
 Gets the Shortcut library which stores the bookmarks in a Kanzi Studio project. More...
 
StateManagerLibrary StateManagerLibrary [get]
 Gets the State Manager library which stores state managers used in a Kanzi Studio project. More...
 
StyleLibrary StyleLibrary [get]
 Gets the Styles library which stores styles used in a Kanzi Studio project. More...
 
TagLibrary TagLibrary [get]
 Gets the Tags library which stores tags used in a Kanzi Studio project. More...
 
TextureLibrary TextureLibrary [get]
 Gets the Textures library which stores textures used in a Kanzi Studio project. More...
 
TimelineSequenceLibrary TimelineSequenceLibrary [get]
 
TrajectoryLibrary TrajectoryLibrary [get]
 

Events

EventHandler ActiveCompositionChanged
 

Detailed Description

Create and access nodes and resources.

Use the functions in this class to create nodes and resources in a project and to access the resources in resource libraries in a project.

Member Function Documentation

Brush CreateBrush ( string  name,
BrushLibrary  parent,
BrushTypeEnum  brushType 
)

Creates a brush in the Brushes library.

You can use this function to create brushes of types that come with Kanzi Studio.

Parameters
nameThe name of the brush.
parentThe library in which you create the brush.
brushTypeThe type of the brush you create with this function. Use BrushTypeEnum.COLOR for Color Brush, BrushTypeEnum.CONTENT for Content Brush, BrushTypeEnum.MATERIAL for Material brush, and BrushTypeEnum.TEXTURE for Texture Brush.
Returns
The brush you create with this function.
See also
CreateBrush(string, BrushLibrary, BrushType), BrushLibrary

Examples

To create a green Color Brush use this code snippet.
In the Visual Studio solution of your plugin, in the Solution Explorer right-click the project name, select Add Reference, and add the reference to the PresentationCore assembly. Your plugin uses this assembly to define the color you use to set the Brush Color property of the Color Brush.

public void Execute(PluginCommandParameter parameter)
{
// Get the Brushes library in the Library > Materials and Textures which stores all the Brushes in a Kanzi Studio project.
var brushLibrary = studio.Project.BrushLibrary;
// Create a Color Brush named Green in the Brushes library.
var colorBrush = studio.Project.CreateBrush(brushLibrary.GenerateUniqueChildName("Green"), brushLibrary, BrushTypeEnum.COLOR);
// Set the Brush Color property of the Color Brush to green (A=255, R=0, G=255, B=0).
colorBrush.Set(colorBrush.PropertyTypes.ColorBrushColor, System.Windows.Media.Color.FromArgb(255, 0, 255, 0));
}
Brush CreateBrush ( string  name,
BrushLibrary  parent,
BrushType  brushType 
)

Creates a brush in the Brushes library.

Parameters
nameThe name of the brush.
parentThe library in which you create the brush.
brushTypeThe type of the brush you create with this function. BrushTypeLibrary stores the brush types available in a Kanzi Studio project.
Returns
The brush you create with this function.
See also
BrushTypeLibrary, BrushLibrary, TextureLibrary, CreateBrush(string, BrushLibrary, BrushTypeEnum)

Examples

To create a green Color Brush use this code snippet.
In the Visual Studio solution of your plugin, in the Solution Explorer right-click the project name, select Add Reference, and add the reference to the PresentationCore assembly. Your plugin uses this assembly to define the color you use to set the Brush Color property of the Color Brush.

public void Execute(PluginCommandParameter parameter)
{
// Get the Brushes library in the Library > Materials and Textures which stores all the Brushes in a Kanzi Studio project.
var brushLibrary = studio.Project.BrushLibrary;
// Create a Color Brush named Green in the Brushes library.
var colorBrush = studio.Project.CreateBrush(
brushLibrary.GenerateUniqueChildName("Green"),
brushLibrary,
studio.Project.BrushTypeLibrary.GetItemByName("Kanzi.ColorBrush"));
// Set the Brush Color property of the Color Brush to green (A=255, R=0, G=255, B=0).
colorBrush.Set(colorBrush.PropertyTypes.ColorBrushColor, System.Windows.Media.Color.FromArgb(255, 0, 255, 0));
}

To create texture brushes of all PNG images in a directory use this function.
In the class library file that implements the PluginCommand interface add the using directive for the System.IO.

// This example shows how you can create a function which creates Texture Brush resources from all PNG files in a directory.
// For example, to create texture brushes from the images in the
// <KanziInstallationDirectory>\Studio\Asset Library\AssetPackages\Album List\Tool_project\Images directory,
// use CreateTextureBrush("../Asset Library/AssetPackages/Album List/Tool_project/Images").
private void CreateTextureBrush(string directory)
{
// Get the names of all PNG files in the input directory.
// To use this function, in the class library file that implements the PluginCommand interface add the using directive for the System.IO.
var pngFiles = Directory.GetFiles(directory, "*.png").Select(x => Path.GetFileName(x)).ToArray();
// Get the Textures library in the Library > Materials and Textures which stores all the textures in a Kanzi Studio project.
var textureLibrary = studio.Project.TextureLibrary;
// Get the Brushes library in the Library > Materials and Textures which stores all the brushes in a Kanzi Studio project.
var brushLibrary = studio.Project.BrushLibrary;
// Create a Texture Brush of each of the images.
foreach (var pngFile in pngFiles)
{
// Get the name of the PNG file without the .png extension.
var resourceName = Path.GetFileNameWithoutExtension(pngFile);
// Import the image file to the Image Directory in the Library > Resource Files and create a Single Texture resource of it.
// To import an image without creating a texture of it, set the second parameter of the ImportImages command to false.
studio.Commands.ImportImages(Path.Combine(directory, pngFile), true);
// Get the texture you created in the Textures library.
var texture = textureLibrary.GetItemByName(resourceName);
// Create a Texture Brush in the Brushes library and name it after the texture.
var myTextureBrush = studio.Project.CreateBrush(
brushLibrary.GenerateUniqueChildName(resourceName),
brushLibrary,
studio.Project.BrushTypeLibrary.GetItemByName("Kanzi.TextureBrush"));
// Set the Brush Texture property of the Texture Brush to the texture.
myTextureBrush.Set(myTextureBrush.PropertyTypes.TextureBrushTexture.Name, texture);
}
}
NodeComponent CreateNodeComponent ( string  name,
NodeComponentHost  parent,
NodeComponentType  nodeComponentType 
)

Creates a node component to the specified parent.

Parameters
nameThe name of the node component.
parentThe NodeComponentHost in which you want to create the node component.
nodeComponentTypeThe type of the node component you create with this function. NodeComponentTypeLibrary stores the node component types available in a Kanzi Studio project.
Returns
The node component you create with this function.
See also
NodeComponentTypeLibrary, NodeComponentHost.CreateNodeComponent(string, NodeComponentType), NodeComponentHost.CreateNodeComponent(NodeComponent)

Examples

To create a node component:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootPage node in the Screens/Screen node.
var rootPage = studio.Project.GetProjectItem("Screens/Screen").GetChild<Page>("RootPage");
// Get the Animation Player node component type.
var animationPlayerType = studio.Project.NodeComponentTypeLibrary.GetItemByName("Kanzi.AnimationPlayer");
// Create an Animation Player named Root Animation Player in the RootPage node.
var animationPlayer = studio.Project.CreateNodeComponent(
rootPage.GenerateUniqueChildName("Root Animation Player"), rootPage, animationPlayerType);
}
ProjectItem CreateProjectItem ( Type  projectItemType,
string  name,
ProjectItem  parent 
)

Creates a project item.

Use this function to create Kanzi nodes and resources.

Parameters
projectItemTypeThe type of the item.
nameThe name of the item.
parentThe parent item of the item you create with this function.
Returns
The item you create with this function.
See also
ChildContainer.GenerateUniqueChildName, CreateProjectItem<T>(string, ProjectItem), GetProjectItem

Examples

To create five Page nodes in the RootPage node:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screens/Screen/RootPage node.
var rootPage = studio.Project.GetProjectItem("Screens/Screen/RootPage");
// Create five Page nodes in the RootPage node.
var count = "";
for (var i = 1; i <= 5; i++)
{
count = i.ToString();
studio.Project.CreateProjectItem(typeof(Page), rootPage.GenerateUniqueChildName("Page " + count), rootPage);
}
// Print "Created 5 Page nodes in the RootPage node" to the Kanzi Studio Log window.
studio.Log("Created " + count + " " + typeof(Page).Name + " nodes in the " + rootPage.Name + " node");
}
T CreateProjectItem< T > ( string  name,
ProjectItem  parent 
)

Creates a project item.

Use this function to create Kanzi nodes and resources.

Template Parameters
TThe type of the item you want to create with this function.
Parameters
nameThe name of the item.
parentThe parent item of the item you create with this function.
Returns
The item you create with this function.
See also
ChildContainer.GenerateUniqueChildName, CreateProjectItem(Type, string, ProjectItem), GetProjectItem

Examples

To create a function which creates an Empty Node 2D:

// This example shows how you can create a function which creates an Empty Node 2D node as a child node of the node,
// location of which you pass as a parameter. For example, you can prompt the user to provide the path of the parent node,
// or use the GetProjectItem function to get the parent node.
private Node2D CreateEmptyNode2D(Node2D parentNode)
{
// Create an Empty Node 2D node. You use the Project as a factory.
// The first parameter defines the name of the node. Use the GenerateUniqueChildName function,
// because the names of sibling nodes must be unique. The second parameter defines the location
// of the parent node of the Empty Node 2D node you create. You pass this parameter to the
// CreateEmptyNode2D function when you call it.
var emptyNode2D = studio.Project.CreateProjectItem<EmptyNode2D>(parentNode.GenerateUniqueChildName("Empty Node 2D"), parentNode);
// Make the Empty Node 2D 300 pixels high by setting its Layout Height property.
emptyNode2D.Set(emptyNode2D.PropertyTypes.NodeHeight, 300.0f);
// Make the Empty Node 2D 400 pixels wide by setting its Layout Width property.
emptyNode2D.Set(emptyNode2D.PropertyTypes.NodeWidth, 400.0f);
return emptyNode2D;
}
Type Constraints
T :ProjectItem 
RenderPass CreateRenderPass ( string  name,
AbstractComposer  parent,
RenderPassType  renderPassType 
)

Creates a render pass.

Use this function to create render passes of different types in the Render Pass library of a Kanzi Studio project.

Parameters
nameThe name of the render pass.
parentThe parent render pass of the render pass you create with this function.
renderPassTypeThe type of the render pass. RenderPassTypeLibrary stores the render pass types available in a Kanzi Studio project.
Returns
The render pass you create with this function.
See also
RenderPassTypeLibrary

Examples

To create a basic set of render passes which first clear depth and then draw all the content of the scene:

// This example creates this hierarchy of render passes:
// - Group Render Pass
// - Clear Render Pass
// - Draw Objects Render Pass
// It then sets Kanzi Studio to render the Screens/Screen/RootPage/Viewport 2D/Scene node using the Group Render Pass.
public void Execute(PluginCommandParameter parameter)
{
// Get the Group Render Pass render pass type.
var groupRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.RenderPass");
// Create a Group Render Pass in the Library > Rendering > Render Passes.
var groupRenderPass = studio.Project.CreateRenderPass(
studio.Project.GenerateUniqueChildName("Group Render Pass"), null, groupRenderPassType);
// Get the Clear Render Pass render pass type.
var clearRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.ClearRenderPass");
// Create a Clear Render Pass in the Group Render Pass you created.
var clearRenderPass = studio.Project.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Clear Render Pass"), groupRenderPass, clearRenderPassType);
// Get the Draw Objects Render Pass render pass type.
var drawObjectsRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.DrawObjectsRenderPass");
// Create a Draw Objects Render Pass in the Group Render Pass you created.
var drawObjectsRenderPass = studio.Project.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Draw Objects Render Pass"), groupRenderPass, drawObjectsRenderPassType);
// Get the Screens/Screen/RootPage/Viewport 2D/Scene node.
var sceneNode = studio.Project.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Set the Render Pass property of the Scene node to the Group Render Pass you created.
sceneNode.Set(Properties.SceneRenderPass.Name, groupRenderPass);
}

To create render passes which render to a composition target and draw that to the screen use this code snippet.
In the Visual Studio solution of your plugin, in the Solution Explorer right-click the project name, select Add Reference, and add the reference to the PresentationCore assembly. Your plugin uses this assembly to define the color you use to set the Clear Color property for a Clear Render Pass.

// This example creates this hierarchy of render passes:
// - Group Render Pass
// - Composition Target Render Pass which divides the resolution of its composition target by 4
// - Clear Render Pass which clears the color buffer with transparent black color
// - Draw Objects Render Pass which renders all content
// - Blit Render Pass which draws the Composition Target Render Pass to the screen
// It then creates a Sphere node in the Screens/Screen/RootPage/Viewport 2D/Scene node and
// sets Kanzi Studio to render the Scene node using the Group Render Pass.
public void Execute(PluginCommandParameter parameter)
{
// Get the Group Render Pass render pass type.
var groupRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.RenderPass");
// Create a Group Render Pass in the Library > Rendering > Render Passes.
var groupRenderPass = studio.Project.CreateRenderPass(
studio.Project.GenerateUniqueChildName("Group Render Pass"), null, groupRenderPassType);
// Get the Composition Target Render Pass render pass type.
var compositionTargetRenderPassType
= studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.CompositionTargetRenderPass");
// Create a Composition Target Render Pass in the Group Render Pass you created.
var compositionTargetRenderPass = studio.Project.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Composition Target Render Pass"), groupRenderPass, compositionTargetRenderPassType);
// Set the Resolution Divisor property of the Composition Target Render Pass to 4.
compositionTargetRenderPass.Set(
compositionTargetRenderPass.PropertyTypes.CompositionTargetRenderPassResoutionDividor, 4);
// Get the Clear Render Pass render pass type.
var clearRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.ClearRenderPass");
// Create a Clear Render Pass in the Composition Target Render Pass you created.
var clearRenderPass = studio.Project.CreateRenderPass(
compositionTargetRenderPass.GenerateUniqueChildName("Clear Render Pass"), compositionTargetRenderPass, clearRenderPassType);
// In the Clear Render Pass add the Clear Color property and set it to transparent black.
clearRenderPass.Set(
clearRenderPass.PropertyTypes.ClearRenderPassClearColor, System.Windows.Media.Color.FromArgb(0, 0, 0, 0));
// Get the Draw Objects Render Pass render pass type.
var drawObjectsRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.DrawObjectsRenderPass");
// Create a Draw Objects Render Pass in the Composition Target Render Pass you created.
studio.Project.CreateRenderPass(
compositionTargetRenderPass.GenerateUniqueChildName("Draw Objects Render Pass"), compositionTargetRenderPass, drawObjectsRenderPassType);
// Get the Blit Render Pass render pass type.
var blitRenderPassType = studio.Project.RenderPassTypeLibrary.GetItemByName("Kanzi.BlitRenderPass");
// Create a Blit Render Pass in the Group Render Pass you created.
var blitRenderPass = studio.Project.CreateRenderPass(
groupRenderPass.GenerateUniqueChildName("Blit Render Pass"), groupRenderPass, blitRenderPassType);
// Set the Texture0 property of the Blit Render Pass to the Composition Target Render Pass you created.
blitRenderPass.Set(blitRenderPass.PropertyTypes.BlitRenderPassTexture0.Name, compositionTargetRenderPass);
// Get the Screens/Screen/RootPage/Viewport 2D/Scene node.
var sceneNode = studio.Project.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Create a Sphere node in the Scene node.
studio.Project.CreateProjectItem<SphereMeshNode>(sceneNode.GenerateUniqueChildName("Sphere"), sceneNode);
// Set the Render Pass property of the Scene node to the Group Render Pass you created.
sceneNode.Set(Properties.SceneRenderPass.Name, groupRenderPass);
}
ProjectItem GetProjectItem ( string  projectItemPath)

Gets a project item.

For example, use this function to get a node in the scene graph and then add child nodes to it, or add, set, and modify the values of the node properties.

Parameters
projectItemPathThe path to the project item you want to get.
Returns
The project item at the path you pass to the function.

Examples

To get a project item:

public void Execute(PluginCommandParameter parameter)
{
// Get the RootPage node in the scene graph.
var rootNode = studio.Project.GetProjectItem("Screens/Screen/RootPage");
}

Property Documentation

BrushLibrary BrushLibrary
get

Gets the Brushes library which stores brushes used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Brushes library in a Kanzi Studio project.

See also
CreateBrush(string, BrushLibrary, BrushType), CreateBrush(string, BrushLibrary, BrushTypeEnum), BrushTypeLibrary

Examples

To get a brush from the Brushes library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Brushes library which stores brushes used in a Kanzi Studio project.
var brushesLibrary = studio.Project.BrushLibrary;
// Get the DefaultBackground texture brush from the Brushes library.
var defaultBackground = brushesLibrary.GetItemByName("DefaultBackground");
}
BrushTypeLibrary BrushTypeLibrary
get

Gets the brush types available in a Kanzi Studio project.

See also
CreateBrush(string, BrushLibrary, BrushType), BrushLibrary

Examples

To get the brush types available in a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Brush Type library which stores the brush type available in a Kanzi Studio project.
var brushTypeLibrary = studio.Project.BrushTypeLibrary;
// Print the available brush types to the Kanzi Studio Log window.
studio.Log("These brush types are available in this Kanzi Studio project:");
foreach (var brushType in brushTypeLibrary.Items)
{
studio.Log(brushType.Name);
}
}
ComposerLibrary ComposerLibrary
get

Gets the Render Pass library which stores the legacy render passes used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

See also
RenderPassTypeLibrary, ProjectItem.GetChild(string), ProjectItem.GetChild<T>(string), CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem)

Examples

To create a Legacy Render Pass in the Render Pass library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Composers library which stores composers and render passes used in a Kanzi Studio project.
var composersLibrary = studio.Project.ComposerLibrary;
// Create a Legacy Render Pass named MyRenderPass in the Composers library.
var renderPass = studio.Project.CreateProjectItem<LegacyRenderPass>(
composersLibrary.GenerateUniqueChildName("MyRenderPass"),
composersLibrary);
}
MaterialLibrary MaterialLibrary
get

Gets the Material library which contains the materials in a Kanzi Studio project.

After you get the library, you can access and create materials.

See also
MaterialTypeLibrary, CreateProjectItem<T>(string, ProjectItem)

Examples

To create a material in the Material library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Material Types library in the Library > Materials and Textures which stores
// all the Material Types in a Kanzi Studio project.
var materialTypeLibrary = studio.Project.MaterialTypeLibrary;
// Create a material type named MyMaterialType in the Material Types library.
var myMaterialType = studio.Project.CreateProjectItem<MaterialType>(
materialTypeLibrary.GenerateUniqueChildName("MyMaterialType"), materialTypeLibrary);
// Get the Material library in the Library > Materials and Textures
// which stores all the Materials in a Kanzi Studio project.
var materialLibrary = studio.Project.MaterialLibrary;
// Create a material named MyMaterialTypeMaterial in the Material library.
var myMaterial = studio.Project.CreateProjectItem<Material>(
materialLibrary.GenerateUniqueChildName(myMaterialType.Name + "Material"), materialLibrary);
// Set the Material Type property of MyMaterialTypeMaterial to MyMaterialType.
myMaterial.Set(myMaterial.PropertyTypes.MaterialType.Name, materialTypeLibrary.GetItemByName(myMaterialType.Name));
}
MaterialTypeLibrary MaterialTypeLibrary
get

Gets the Material Types library which contains the material types in a Kanzi Studio project.

After you get the library, you can access and create material types.

See also
MaterialLibrary, CreateProjectItem<T>(string, ProjectItem)

Examples

To get all material types in the Material Types library of a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Material Types library in the Library > Materials and Textures
// which stores all the material types in a Kanzi Studio project.
var materialTypeLibrary = studio.Project.MaterialTypeLibrary;
// Print the name of all material types in your project to the Kanzi Studio Log window.
studio.Log("This Kanzi Studio project contains these material types:");
foreach (var materialType in materialTypeLibrary.Items)
{
studio.Log(materialType.Name);
}
}

To create a material type in the Material Types library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Material Types library in the Library > Materials and Textures
// which stores all the material types in a Kanzi Studio project.
var materialTypeLibrary = studio.Project.MaterialTypeLibrary;
// Create a material type named MyMaterialType in the Material Types library.
var myMaterialType = studio.Project.CreateProjectItem<MaterialType>(
materialTypeLibrary.GenerateUniqueChildName("MyMaterialType"), materialTypeLibrary);
}
MeshLibrary MeshLibrary
get

Gets the Meshes library which contains the meshes in a Kanzi Studio project.

Examples

To get the meshes in a Kanzi Studio project:

public void Execute(PluginCommandParameter parameter)
{
// Get the Meshes library which stores all the meshes in a Kanzi Studio project.
var meshLibrary = studio.Project.MeshLibrary;
// If the project contains meshes, print their names and the number of meshes in the Kanzi Studio Log window.
if (meshLibrary.Items.Any())
{
var count = meshLibrary.Items.Count().ToString();
studio.Log("This Kanzi Studio project contains " + count + " meshes:");
foreach (var mesh in meshLibrary.Items)
{
studio.Log(mesh.Name);
}
}
else
{
studio.Log("This Kanzi Studio project does not contain meshes.");
}
}
NodeComponentTypeLibrary NodeComponentTypeLibrary
get

Gets the node component types available in a Kanzi Studio project.

See also
CreateNodeComponent, NodeComponentHost

Examples

To get the node component types available in Kanzi:

public void Execute(PluginCommandParameter parameter)
{
// Get the node component type library.
var nodeComponentsLibrary = studio.Project.NodeComponentTypeLibrary;
// Print the available node component types to the Kanzi Studio Log window.
studio.Log("These node component types are available in this Kanzi Studio project:");
foreach (var nodeComponentType in nodeComponentsLibrary.Items)
{
studio.Log(nodeComponentType.Name);
}
}
PageTransitionCollectionLibrary PageTransitionCollectionLibrary
get

Gets the Page Transitions library which contains the page transitions in a Kanzi Studio project.

After you get the library, you can access and create page transitions.

Examples

To create and configure a page transition:

// This example creates a Fade Transition which animates the opacity of the Page nodes
// between which the transition happens.
public void Execute(PluginCommandParameter parameter)
{
// Get the Page Transitions library which stores the page transitions in a Kanzi Studio project.
var pageTransitionsLibrary = studio.Project.PageTransitionCollectionLibrary;
// Create a Page Transition Collection named My Transition Collection in the Page Transitions library.
var myTransitionCollection = studio.Project.CreateProjectItem<PageTransitionCollection>(
pageTransitionsLibrary.GenerateUniqueChildName("My Transition Collection"),
pageTransitionsLibrary);
// Get the Page Host node RootPage in the Screens/Screen node.
var rootPage = studio.Project.GetProjectItem("Screens/Screen").GetChild<PageHost>("RootPage");
// Set the Transition property of the RootPage node to My Transition Collection.
// This way you set the RootPage node to use the page transitions in My Transition Collection.
rootPage.Set(rootPage.PropertyTypes.PageHostTransitions.Name, myTransitionCollection);
// Create three Page nodes in the RootPage node. In each Page node create a Text Block 2D node and
// set the Text property of the Text Block 2D node to the name of its parent Page node.
for (var i = 1; i <= 3; i++)
{
var page = studio.Project.CreateProjectItem<Page>(
rootPage.GenerateUniqueChildName("Page"),
rootPage);
var textBlock = studio.Project.CreateProjectItem<TextBlock2D>(
page.GenerateUniqueChildName("Text Block 2D"),
page);
textBlock.Set(textBlock.PropertyTypes.TextBlockConceptText, page.Name);
}
// Get the Page node named Page in the RootPage node.
var pageNode = rootPage.GetChild<Page>("Page");
// Set the Default Subpage property of the RootPage node to the Page node.
rootPage.Set(rootPage.PropertyTypes.PageHostDefaultSubPage, new NodeReference<Node2D>(pageNode));
// Create a Page Transition named Fade Transition in My Transition Collection.
var fadeTransition = studio.Project.CreateProjectItem<PageTransition>(
myTransitionCollection.GenerateUniqueChildName("Fade Transition"),
myTransitionCollection);
// Configure the Fade Transition:
// Set the Duration property to 200. This way you set the length of the transition to 200 ms.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionDuration, 200);
// Set the From property to the node named Page.
// This way you make the transition apply only when navigating from the node named Page.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionFrom, pageNode.Name);
// Set the To property to *. This way you apply the transition when navigating to all Page nodes.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionTo, "*");
// Set the Direction property to Unidirectional.
// Use the Direction property to set whether the transition applies to the transition
// from the nodes you set in the From property to the nodes you set in the To property,
// or to the transitions from both nodes.
// To set the Direction property of a Page Transition:
// - For Bidirectional use 0.
// This way you apply the transition to the transition from the nodes in the From property to
// the nodes in the To property, and from the nodes in the To property to the nodes in the From property.
// - For Unidirectional use 1.
// This way you apply the transition only to the transition from the nodes in the From property
// to the nodes in the To property.
fadeTransition.Set(fadeTransition.PropertyTypes.PageTransitionDirection, 1);
// Create a Page Transition Animation named Opacity In.
var fadeTransitionInAnimation = studio.Project.CreateProjectItem<PageTransitionAnimation>(
fadeTransition.GenerateUniqueChildName("Opacity In"),
fadeTransition);
// Configure the Opacity In animation:
// Set the Animation Target property to Page In.
// To set the Animation Target property of a Page Transition Animation:
// - For Page In use 0.
// This way you use the animation when navigating to the set Page or Page Host node.
// - For Page Out use 1.
// This way you use the animation when navigating from the set Page or Page Host node.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationAnimationTarget, 0);
// Set the Transition Property to Node.Opacity. This way you animate the Opacity property.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationPropertyType,
Properties.NodeOpacity);
// Set the Start Value property to 0.
// This way you set the value of the Transition Property to 0 when the transition animation starts.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationStartValue, "0");
// Set the End Value property to 1.
// This way you set the value of the Transition Property to 1 when the transition animation ends.
fadeTransitionInAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationEndValue, "1");
// Create a Page Transition Animation named Opacity Out.
var fadeTransitionOutAnimation = studio.Project.CreateProjectItem<PageTransitionAnimation>(
fadeTransition.GenerateUniqueChildName("Opacity Out"),
fadeTransition);
// Configure the Opacity Out animation:
// Set the Animation Target property to Page Out.
fadeTransitionOutAnimation.Set(
fadeTransitionOutAnimation.PropertyTypes.PageTransitionAnimationAnimationTarget, 1);
// Set the Transition Property to Node.Opacity.
fadeTransitionOutAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationPropertyType,
Properties.NodeOpacity);
// Set the Start Value property to 1.
fadeTransitionOutAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationStartValue, "1");
// Set the End Value property to 0.
fadeTransitionOutAnimation.Set(
fadeTransitionInAnimation.PropertyTypes.PageTransitionAnimationEndValue, "0");
}
PipelineItemLibrary PipelineItemLibrary
get

Gets the Object Sources Library which stores the object sources and filters in a Kanzi Studio project.

After you get the library, you can access and create object sources and filters.

See also
TagLibrary

Examples

To create a Tag Filter:

public void Execute(PluginCommandParameter parameter)
{
// Get the Object Sources library in Library > Rendering which stores
// the object sources and filters in a Kanzi Studio project.
var pipeLineItemLibrary = studio.Project.PipelineItemLibrary;
// Create a Tag Filter named My Tag Filter in the Object Sources library.
var myTagFilter = studio.Project.CreateProjectItem<TagFilterObjectSource>(
pipeLineItemLibrary.GenerateUniqueChildName("My Tag Filter"),
pipeLineItemLibrary);
// Get the Tags library which stores tags used in a Kanzi Studio project.
var tagsLibrary = studio.Project.TagLibrary;
// Create a tag named My Tag in the Tags library.
var myTag = studio.Project.CreateProjectItem<Tag>(
tagsLibrary.GenerateUniqueChildName("My Tag"), tagsLibrary);
// Create a list of tags which contains the My Tag tag.
var tagList = new List<Tag>(new Tag[] { myTag });
// Set the Included Tags property of the My Tag Filter to My Tag.
// This way you set the filter to pick the nodes that have the My Tag tag.
myTagFilter.Set(myTagFilter.PropertyTypes.TagFilterIncludeList, tagList);
}
PrefabLibrary PrefabLibrary
get

Gets the Prefabs library which contains the prefabs used in a Kanzi Studio project.

After you get the library, you can access and create prefabs.

The Prefabs library in a Kanzi Studio project.

See also
CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem), GetProjectItem(string), CreateComponentNode(string, Node, ComponentType), ResourceReference<T>

Examples

To create a prefab in the Prefabs library and instantiate it:

public void Execute(PluginCommandParameter parameter)
{
// Get the Prefabs library which stores all the prefabs in a Kanzi Studio project.
var prefabsLibrary = studio.Project.PrefabLibrary;
// In the Prefabs library create a prefab template which can hold 3D nodes.
// For 2D nodes you have to create a 2D prefab template.
var myPrefabTemplate = studio.Project.CreateProjectItem<Node3DPrefabTemplate>(
prefabsLibrary.GenerateUniqueChildName("Prefab Template"), prefabsLibrary);
// Create an Empty Node 3D node as the root node of the prefab.
var rootNode = studio.Project.CreateProjectItem<EmptyNode>(
myPrefabTemplate.GenerateUniqueChildName("Empty Node 3D"), myPrefabTemplate);
// Get a component type for the Button 3D node.
var componentType = studio.Project.ComponentTypeLibrary.GetComponentType("Kanzi.Button3D");
// Use the component type you just created to create the Button 3D node.
var button = studio.Project.CreateComponentNode("Button 3D", rootNode, componentType);
// Get the node where you want to instantiate the prefab you just created.
var instantiateHere = studio.Project.GetProjectItem("Screens/Screen/RootPage/Viewport 2D/Scene");
// Create the Prefab Placeholder node which instantiates the prefab in the scene graph.
var prefabInstance = studio.Project.CreateProjectItem<Node3DPrefabPlaceholder>(
instantiateHere.GenerateUniqueChildName("Placeholder"), instantiateHere);
// Create a resource reference from the prefab template which you want to instantiate.
var reference = new ResourceReference<Node3DPrefabTemplate>(myPrefabTemplate);
// Instantiate the prefab you created by setting the Node3DPrefabPlaceholderTemplate property
// to the prefab template reference you created in the previous line.
prefabInstance.Set(prefabInstance.PropertyTypes.Node3DPrefabPlaceholderTemplate, reference);
}

Gets the Property Types library which stores all property types you create in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Property Types library in a Kanzi Studio project.

See also
PluginInterface.PropertyTypeLibrary.CreateProperty(System.Type, string, string, string), PluginInterface.PropertyTypeLibrary.ProjectPropertyTypes

Examples

To create your own property type of the integer data type:

public void Execute(PluginCommandParameter parameter)
{
// Get the Property Types library which stores all property types you create in a Kanzi Studio project.
var propertyTypesLibrary = studio.Project.PropertyTypeLibrary;
// Create an integer property type in the Property Types library and set:
// - Name to MyIntProperty
// - Name as it is shown in Kanzi Studio to My Int Property
// - Category in which Kanzi Studio shows the property type to My Properties
// - Lowest value to 0
// - Highest value to 9000
// - The amount by which the property can change to 10
var myIntProperty = studio.Project.PropertyTypeLibrary.CreateIntProperty(
propertyTypesLibrary.GenerateUniqueChildName("MyIntProperty"),
"My Int Property",
"My Properties",
0,
9000,
10);
}

To get all property types in the Property Types library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Property Types library which stores all property types you create in a Kanzi Studio project.
var propertyTypesLibrary = studio.Project.PropertyTypeLibrary;
foreach (Property property in propertyTypesLibrary.ProjectPropertyTypes)
{
// Print the name of all properties which you can remove to the Kanzi Studio Log window.
studio.Log(property.Name);
}
}
RenderPassTypeLibrary RenderPassTypeLibrary
get

Gets the render pass types available in a Kanzi Studio project.

See also
CreateRenderPass

Examples

To get the render pass types available in Kanzi:

public void Execute(PluginCommandParameter parameter)
{
// Get the render pass type library.
var renderPassTypeLibrary = studio.Project.RenderPassTypeLibrary;
// Print the available render pass types to the Kanzi Studio Log window.
studio.Log("These render pass types are available in this Kanzi Studio project:");
foreach (var renderPassType in renderPassTypeLibrary.Items)
{
studio.Log(renderPassType.Name);
}
}

Gets the Screen node in a Kanzi Studio project.

The Screen node is the root node of the scene graph in Kanzi.

The Screen node.

See also
PluginInterface.Screen.RootNode2D

Examples

To get the Screen node:

public void Execute(PluginCommandParameter parameter)
{
// Get the Screen node.
var screen = studio.Project.Screen;
// Add the Screen Color property to the Screen node.
screen.AddProperty(screen.PropertyTypes.ScreenClearColor);
}
ShortcutLibrary ShortcutLibrary
get

Gets the Shortcut library which stores the bookmarks in a Kanzi Studio project.

After you get the library, you can access and create bookmarks.

Examples

To create a bookmark in the Shortcut library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Shortcut library in the Library > Bookmarks which stores the bookmarks in a Kanzi Studio project.
var bookmarkLibrary = studio.Project.ShortcutLibrary;
// Get the Screens/Screen/RootPage node.
var rootPage = studio.Project.GetProjectItem("Screens/Screen/RootPage");
// Create a Button 2D node in the RootPage node.
var button = studio.Project.CreateProjectItem<Button2D>(
rootPage.GenerateUniqueChildName("Button 2D"), rootPage);
// Create a bookmark named Button 2D in the Shortcut library.
var buttonBookmark = studio.Project.CreateProjectItem<Shortcut>(
bookmarkLibrary.GenerateUniqueChildName("Button 2D"),
bookmarkLibrary);
// Set the Target property of the bookmark to the Button 2D node.
buttonBookmark.Set(buttonBookmark.PropertyTypes.ShortcutTarget, button);
}
StateManagerLibrary StateManagerLibrary
get

Gets the State Manager library which stores state managers used in a Kanzi Studio project.

After you get the library, you can access and create state managers in that library.

The State Manager library in a Kanzi Studio project.

See also
StateGroup, State, StateObject, StateTransition, StateBase

Examples

To create a state manager with a state group, state, and a state object in the State Managers library:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.Project.StateManagerLibrary;
// Create a state manager named MyStateManager in the State Managers library.
var myStateManager = studio.Project.CreateProjectItem<StateManager>(
stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Create a state group named MyStateGroup in the MyStateManager state manager.
var myStateGroup = studio.Project.CreateProjectItem<StateGroup>(
myStateManager.GenerateUniqueChildName("MyStateGroup"),
myStateManager);
// Create a state named MyState in the MyStateGroup state group.
var myState = studio.Project.CreateProjectItem<State>(
myStateGroup.GenerateUniqueChildName("MyState"),
myStateGroup);
// Create a state object named MyStateObject in MyState state.
var myStateObject = studio.Project.CreateProjectItem<StateObject>(
myState.GenerateUniqueChildName("MyStateObject"),
myState);
}

To get a state manager from the State Managers library:

public void Execute(PluginCommandParameter parameter)
{
// Get the State Managers library which stores state managers used in a Kanzi Studio project.
var stateManagerLibrary = studio.Project.StateManagerLibrary;
// Create a state manager named MyStateManager in the State Managers library.
studio.Project.CreateProjectItem<StateManager>(stateManagerLibrary.GenerateUniqueChildName("MyStateManager"), stateManagerLibrary);
// Get a state manager named MyStateManager from the State Managers library.
var myStateManager = stateManagerLibrary.GetItemByName("MyStateManager");
}
StyleLibrary StyleLibrary
get

Gets the Styles library which stores styles used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Styles library in a Kanzi Studio project.

See also
ProjectItem.GetChild(string), ProjectItem.GetChild<T>(string), CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem)

Examples

To create a named style in the Styles library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Styles library which stores styles used in a Kanzi Studio project.
var stylesLibrary = studio.Project.StyleLibrary;
// Create a named style named MyNamedStyle in the Styles library.
var myNamedStyle = studio.Project.CreateProjectItem<StyleItem>(
stylesLibrary.GenerateUniqueChildName("MyNamedStyle"), stylesLibrary);
}

To create a typed style in the Styles library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Styles library which stores styles used in a Kanzi Studio project.
var stylesLibrary = studio.Project.StyleLibrary;
// Create a named style named MyTypedStyle in the Styles library.
var myTypedStyle = studio.Project.CreateProjectItem<StyleItem>(
stylesLibrary.GenerateUniqueChildName("MyTypedStyle"), stylesLibrary);
// Convert the named style you just created to a typed style
myTypedStyle.Set(myTypedStyle.PropertyTypes.StyleType, StyleTypeEnum.GENERIC);
}

To get a style from the Styles library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Styles library which stores styles used in a Kanzi Studio project.
var stylesLibrary = studio.Project.StyleLibrary;
// Create a named style named MyNamedStyle in the Styles library.
studio.Project.CreateProjectItem<StyleItem>(stylesLibrary.GenerateUniqueChildName("MyNamedStyle"), stylesLibrary);
// Get the named style named MyNamedStyle from the Styles library.
var myNamedStyle = stylesLibrary.GetItemByName("MyNamedStyle");
}
TagLibrary TagLibrary
get

Gets the Tags library which stores tags used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Tags library in a Kanzi Studio project.

See also
ProjectItem.GetChild(string), ProjectItem.GetChild<T>(string), CreateProjectItem<T>(string, ProjectItem), CreateProjectItem(Type, string, ProjectItem), PipelineItemLibrary

Examples

To get a tag from the Tags library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Tags library which stores tags used in a Kanzi Studio project.
var tagsLibrary = studio.Project.TagLibrary;
// Get the default tag Transparent from the Tags library.
var tagTransparent = tagsLibrary.GetItemByName("Transparent");
}

To create a tag in the Tags library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Tags library which stores tags used in a Kanzi Studio project.
var tagsLibrary = studio.Project.TagLibrary;
// Create a tag named MyTag in the Tags library.
var tag = studio.Project.CreateProjectItem<Tag>(tagsLibrary.GenerateUniqueChildName("MyTag"), tagsLibrary);
}
TextureLibrary TextureLibrary
get

Gets the Textures library which stores textures used in a Kanzi Studio project.

After you get the library, you can access and create resources in that library.

The Textures library in a Kanzi Studio project.

See also
ProjectItem.GetChild

Examples

To get a texture from the Textures library:

public void Execute(PluginCommandParameter parameter)
{
// Get the Textures library which stores all the textures in a Kanzi Studio project.
var texturesLibrary = studio.Project.TextureLibrary;
// Get the DefaultTexture texture from the Textures library.
var defaultTexture = texturesLibrary.GetItemByName("Default Texture");
}