Upload project files

This commit is contained in:
Misaki
2024-09-16 00:08:10 +09:00
commit 0a4745662a
218 changed files with 13387 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<engine:VisualElement name="Root" data-source-type="Misaki.ArtToolEditor.SourcePrefab, Misaki.ArtTool.Editor" style="flex-grow: 1; flex-direction: row; height: 50px;">
<engine:Toggle style="margin-right: 8px; margin-top: 3px;">
<Bindings>
<engine:DataBinding property="value" data-source-path="Enabled" binding-mode="TwoWay" />
</Bindings>
</engine:Toggle>
<engine:VisualElement name="Icon" style="width: 50px;">
<Bindings>
<engine:DataBinding property="style.backgroundImage" data-source-path="Icon" binding-mode="TwoWay" />
</Bindings>
</engine:VisualElement>
<engine:VisualElement style="flex-grow: 1; margin-top: 2px; margin-right: 2px; margin-bottom: 2px; margin-left: 8px; justify-content: center;">
<editor:ObjectField type="UnityEngine.GameObject, UnityEngine.CoreModule">
<Bindings>
<engine:DataBinding property="value" data-source-path="Prefab" binding-mode="TwoWay" />
</Bindings>
</editor:ObjectField>
<engine:Slider value="0.5" high-value="1" show-input-field="true">
<Bindings>
<engine:DataBinding property="value" data-source-path="Frequency" binding-mode="TwoWay" />
</Bindings>
</engine:Slider>
</engine:VisualElement>
</engine:VisualElement>
</engine:UXML>

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 05d16995f16706d48957fd51a6f23988
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}

View File

@@ -0,0 +1,166 @@
using Misaki.ArtToolEditor;
using System.Linq;
using UnityEditor;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UIElements;
public class PrefabPainterWindow : EditorWindow
{
public PrefabPainterWindow()
{
ViewModel = PrefabPainterViewModel.Instance;
}
public PrefabPainterViewModel ViewModel;
[SerializeField]
private VisualTreeAsset visualTreeAsset = default;
[SerializeField]
private VisualTreeAsset listViewItemTemplate = default;
[MenuItem("Tools/Prefab Painter")]
public static void ShowExample()
{
var wnd = GetWindow<PrefabPainterWindow>();
var icon = EditorGUIUtility.IconContent("Prefab Icon");
wnd.titleContent = new GUIContent("Prefab Painter", icon.image);
}
public void CreateGUI()
{
var root = rootVisualElement;
VisualElement visualAsset = visualTreeAsset.Instantiate();
var visualAssetRoot = visualAsset.Q<VisualElement>("Root");
visualAssetRoot.dataSource = this;
SetupModeButton(visualAsset);
SetupListView(visualAsset);
root.Add(visualAsset);
}
private void OnEnable()
{
SceneView.duringSceneGui += OnSceneGUI;
ViewModel.OnNavigatedTo();
}
private void OnDisable()
{
SceneView.duringSceneGui -= OnSceneGUI;
}
private void OnSceneGUI(SceneView sceneView)
{
ViewModel.DrawBrush();
}
private void SetupModeButton(VisualElement visualAsset)
{
var disableModeButton = visualAsset.Q<Button>("Disable-Mode-Button");
var paintModeButton = visualAsset.Q<Button>("Paint-Mode-Button");
var eraseModeButton = visualAsset.Q<Button>("Erase-Mode-Button");
disableModeButton.clicked += () =>
{
disableModeButton.AddToClassList("Selected");
paintModeButton.RemoveFromClassList("Selected");
eraseModeButton.RemoveFromClassList("Selected");
ViewModel.CurrentPaintType = PaintType.Disable;
};
paintModeButton.clicked += () =>
{
paintModeButton.AddToClassList("Selected");
disableModeButton.RemoveFromClassList("Selected");
eraseModeButton.RemoveFromClassList("Selected");
ViewModel.CurrentPaintType = PaintType.Paint;
};
eraseModeButton.clicked += () =>
{
eraseModeButton.AddToClassList("Selected");
disableModeButton.RemoveFromClassList("Selected");
paintModeButton.RemoveFromClassList("Selected");
ViewModel.CurrentPaintType = PaintType.Erase;
};
}
private void SetupListView(VisualElement visualAsset)
{
var listView = visualAsset.Q<ListView>("SourcePrefabs-ListView");
var PrefabSettingSection = visualAsset.Q<VisualElement>("Prefab-Setting");
PrefabSettingSection.style.display = DisplayStyle.None;
listView.makeItem = () => listViewItemTemplate.CloneTree();
listView.selectionChanged += objects =>
{
if (objects.Count() <= 0)
{
return;
}
if (objects.First() is not SourcePrefab sourcePrefab)
{
return;
}
ViewModel.CurrentSelection = sourcePrefab;
PrefabSettingSection.style.display = DisplayStyle.Flex;
};
listView.bindItem = (element, i) =>
{
var objectField = element.Q<ObjectField>();
objectField.RegisterValueChangedCallback((evt) =>
{
if (evt.newValue == null)
{
return;
}
var icon = AssetPreview.GetAssetPreview(evt.newValue);
while (icon == null)
{
icon = AssetPreview.GetAssetPreview(evt.newValue);
}
ViewModel.SourcePrefabs[i].Icon = icon;
});
};
listView.itemsAdded += (items) =>
{
for (var i = 0; i < items.Count(); i++)
{
var index = listView.itemsSource.Count - i - 1;
ViewModel.SourcePrefabs[index] = new SourcePrefab();
}
listView.Rebuild();
};
listView.itemsRemoved += (items) =>
{
if (ViewModel.SourcePrefabs.Count - items.Count() <= 0)
{
PrefabSettingSection.style.display = DisplayStyle.None;
return;
}
listView.Rebuild();
};
listView.itemIndexChanged += (from, to) =>
{
listView.Rebuild();
};
}
}

View File

@@ -0,0 +1,16 @@
fileFormatVersion: 2
guid: 09eefec055820c24785d451ce8c3c2eb
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences:
- m_ViewDataDictionary: {instanceID: 0}
- visualTreeAsset: {fileID: 9197481963319205126, guid: a4196f221910b5442bc80d8305ee937e,
type: 3}
- listViewItemTemplate: {fileID: 9197481963319205126, guid: 05d16995f16706d48957fd51a6f23988,
type: 3}
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,45 @@
.Header {
-unity-font-style: bold;
margin-top: 16px;
margin-bottom: 12px;
font-size: 14px;
}
.SubHeader {
margin-bottom: 6px;
-unity-font-style: bold;
font-size: 12px;
margin-top: 8px;
}
.SmallHeader {
margin-top: 6px;
margin-bottom: 4px;
}
.PropertyContainer {
flex-grow: 1;
margin-left: 8px;
}
#Root > .unity-tab-view > #unity-tab-view__header-container {
align-self: center;
}
#unity-tab__content-container {
padding-top: 16px;
padding-right: 5px;
padding-bottom: 5px;
padding-left: 5px;
}
.Selected {
border-top-width: 1px;
border-right-width: 1px;
border-bottom-width: 1px;
border-left-width: 1px;
border-left-color: rgb(186, 186, 186);
border-right-color: rgb(186, 186, 186);
border-top-color: rgb(186, 186, 186);
border-bottom-color: rgb(186, 186, 186);
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1d93d96e22cd7f1429707b56e9402af2
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}
disableValidation: 0

View File

@@ -0,0 +1,181 @@
<engine:UXML xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:engine="UnityEngine.UIElements" xmlns:editor="UnityEditor.UIElements" noNamespaceSchemaLocation="../../../../../UIElementsSchema/UIElements.xsd" editor-extension-mode="True">
<Style src="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/View/PrefabPainterWindow.uss?fileID=7433441132597879392&amp;guid=1d93d96e22cd7f1429707b56e9402af2&amp;type=3#PrefabPainterWindow" />
<engine:VisualElement name="Root" data-source-type="PrefabPainterWindow, Misaki.ArtTool.Editor" style="flex-grow: 1; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px;">
<engine:VisualElement name="Title" style="flex-grow: 0;">
<engine:Label text="Prefab Painter" style="align-self: center; font-size: 28px; margin-top: 32px; margin-bottom: 24px;" />
</engine:VisualElement>
<engine:VisualElement name="Toolbar" style="flex-grow: 0; flex-direction: row; justify-content: center; margin-bottom: 16px;">
<engine:Button icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/unavailable.png?fileID=2800000&amp;guid=89f753d5e2b91c842a8de6447e3fe8b3&amp;type=3#unavailable" name="Disable-Mode-Button" tooltip="Paint" class="Selected" style="width: 30px; height: 30px;" />
<engine:Button icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/Paint.png?fileID=2800000&amp;guid=a36d0148cfebe8c428c95a88eae0819a&amp;type=3#Paint" name="Paint-Mode-Button" tooltip="Paint" style="width: 30px; height: 30px;" />
<engine:Button icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/erase.png?fileID=2800000&amp;guid=937646d041ffb2c4c8b4139900477869&amp;type=3#erase" name="Erase-Mode-Button" tooltip="Erase" style="width: 30px; height: 30px;" />
</engine:VisualElement>
<engine:TabView style="flex-grow: 1;">
<engine:Tab label="Prefab" name="Prefab-Tab" icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/object.png?fileID=2800000&amp;guid=a61bfbad022af42448490799093b2d97&amp;type=3#object" style="flex-grow: 1;">
<engine:VisualElement name="Prefab-List" style="padding-top: 0; padding-right: 0; padding-bottom: 0; padding-left: 0;">
<editor:Toolbar style="margin-top: 0; margin-right: 0; margin-bottom: 8px; margin-left: 0;">
<editor:ToolbarButton icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/import.png?fileID=2800000&amp;guid=bc1c9a2da21fe83448b139a8a35aa32e&amp;type=3#import" tooltip="Import prefab list" style="width: 30px; padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px;" />
<editor:ToolbarButton icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/export.png?fileID=2800000&amp;guid=c87abe98330a0ef46b5bbf5b784e8bc3&amp;type=3#export" tooltip="Export prefab list" style="padding-top: 2px; padding-right: 2px; padding-bottom: 2px; padding-left: 2px; width: 30px;" />
<editor:ToolbarSpacer style="flex-grow: 1;" />
<editor:ToolbarSearchField style="width: 50%;" />
</editor:Toolbar>
<engine:ListView reorderable="true" reorder-mode="Animated" show-border="true" fixed-item-height="50" item-template="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/View/PrefabListItemTemplate.uxml?fileID=9197481963319205126&amp;guid=05d16995f16706d48957fd51a6f23988&amp;type=3#PrefabListItemTemplate" name="SourcePrefabs-ListView" data-source-path="ViewModel" show-add-remove-footer="true" binding-source-selection-mode="AutoAssign" virtualization-method="DynamicHeight" style="max-height: 1000px;">
<Bindings>
<engine:DataBinding property="itemsSource" data-source-path="SourcePrefabs" binding-mode="TwoWay" />
</Bindings>
</engine:ListView>
<engine:VisualElement name="List-Setting" class="SettingContainer PropertyContainer">
<engine:Label text="List setting" name="List-Setting-Header" class="SubHeader" />
<engine:VisualElement name="Scatter-Properties" class="PropertyContainer" style="flex-grow: 1;">
<engine:DropdownField label="Random Order" choices="Disable,Enable" index="1" data-source-path="ViewModel">
<Bindings>
<engine:DataBinding property="index" data-source-path="RandomOrder" binding-mode="TwoWay" />
</Bindings>
</engine:DropdownField>
</engine:VisualElement>
</engine:VisualElement>
</engine:VisualElement>
<engine:VisualElement name="Prefab-Setting" data-source-path="ViewModel" style="flex-grow: 1;">
<engine:Label text="Prefab setting" class="Header" />
<engine:VisualElement class="PropertyContainer">
<engine:VisualElement name="Scatter-Setting" class="SettingContainer">
<engine:Label text="Scatter setting" name="Scatter-Header" class="SubHeader" />
<engine:VisualElement name="Scatter-Properties" class="PropertyContainer" style="flex-grow: 1;">
<engine:EnumField label="Align To" type="Misaki.ArtToolEditor.AlignmentType, Misaki.ArtTool.Editor" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="Alignment" binding-mode="TwoWay" />
</Bindings>
</engine:EnumField>
<engine:EnumField label="Set Parent To" value="Center" type="Misaki.ArtToolEditor.ParentType, Misaki.ArtTool.Editor" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="Parent" binding-mode="TwoWay" />
</Bindings>
</engine:EnumField>
<editor:ObjectField label="Parent Object" type="UnityEngine.GameObject, UnityEngine.CoreModule" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="ParentObject" binding-mode="TwoWay" />
</Bindings>
</editor:ObjectField>
<engine:Slider label="Object Spacing" value="1" high-value="100" show-input-field="true" data-source-path="CurrentSelection" low-value="0.01">
<Bindings>
<engine:DataBinding property="value" data-source-path="ObjectSpacing" binding-mode="TwoWay" />
</Bindings>
</engine:Slider>
<engine:EnumField label="Reference Point" type="Misaki.ArtToolEditor.ReferencePointType, Misaki.ArtTool.Editor" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="ReferencePoint" binding-mode="TwoWay" />
</Bindings>
</engine:EnumField>
<engine:Slider label="Slop Filter" value="45" high-value="90" show-input-field="true" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="SlopeFilter" binding-mode="TwoWay" />
</Bindings>
</engine:Slider>
</engine:VisualElement>
</engine:VisualElement>
<engine:VisualElement name="Randomness-Setting" class="SettingContainer">
<engine:Label text="Randomness" name="Randomness-Header" class="SubHeader" />
<engine:VisualElement name="Randomness-Properties" class="PropertyContainer" style="flex-grow: 1;">
<editor:EnumFlagsField label="Enable" value="None" type="Misaki.ArtToolEditor.RandomnessType, Misaki.ArtTool.Editor" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="Randomness" binding-mode="TwoWay" />
</Bindings>
</editor:EnumFlagsField>
<engine:Label text="Position" class="SmallHeader" />
<engine:VisualElement class="PropertyContainer" style="flex-grow: 1;">
<engine:Vector3Field label="Min" value="0,0,0" name="Randomness-Position-Min" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="PositionMin" binding-mode="TwoWay" />
</Bindings>
</engine:Vector3Field>
<engine:Vector3Field label="Max" value="0,0,0" name="Randomness-Position-Min" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="PositionMax" binding-mode="TwoWay" />
</Bindings>
</engine:Vector3Field>
</engine:VisualElement>
<engine:Label text="Rotation" class="SmallHeader" />
<engine:VisualElement class="PropertyContainer" style="flex-grow: 1;">
<engine:Vector3Field label="Min" value="0,0,0" name="Randomness-Rotation-Min" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="RotationMin" binding-mode="TwoWay" />
</Bindings>
</engine:Vector3Field>
<engine:Vector3Field label="Max" value="0,0,0" name="Randomness-Rotation-Min" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="RotationMax" binding-mode="TwoWay" />
</Bindings>
</engine:Vector3Field>
</engine:VisualElement>
<engine:Label text="Scale" class="SmallHeader" />
<engine:VisualElement class="PropertyContainer" style="flex-grow: 1;">
<engine:Vector3Field label="Min" value="1,1,1" name="Randomness-Scale-Min" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="ScaleMin" binding-mode="TwoWay" />
</Bindings>
</engine:Vector3Field>
<engine:Vector3Field label="Max" value="1,1,1" name="Randomness-Scale-Max" data-source-path="CurrentSelection">
<Bindings>
<engine:DataBinding property="value" data-source-path="ScaleMax" binding-mode="TwoWay" />
</Bindings>
</engine:Vector3Field>
</engine:VisualElement>
</engine:VisualElement>
</engine:VisualElement>
</engine:VisualElement>
</engine:VisualElement>
</engine:Tab>
<engine:Tab label="Brush" name="Brush-Tab" icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/brush.png?fileID=2800000&amp;guid=08654cfbeb927194e962e78c4aa830c8&amp;type=3#brush" data-source-path="ViewModel.CurrentBrushSetting">
<engine:VisualElement name="Brush-Shape" style="flex-grow: 1;">
<engine:Label text="Brush Shape" class="SubHeader" />
<engine:VisualElement class="PropertyContainer" style="flex-grow: 1;">
<engine:DropdownField label="Shape" choices="Circle,Grid,Spline" index="0" />
<engine:Slider label="Size" value="1" high-value="10" show-input-field="true">
<Bindings>
<engine:DataBinding property="value" data-source-path="BrushSize" binding-mode="TwoWay" />
</Bindings>
</engine:Slider>
<engine:FloatField label="Splat Spacing" value="0">
<Bindings>
<engine:DataBinding property="value" data-source-path="SplatSpacing" binding-mode="TwoWay" />
</Bindings>
</engine:FloatField>
<engine:Slider label="Density" value="0.5" high-value="1" show-input-field="true">
<Bindings>
<engine:DataBinding property="value" data-source-path="Density" binding-mode="TwoWay" />
</Bindings>
</engine:Slider>
</engine:VisualElement>
</engine:VisualElement>
<engine:VisualElement name="Brush-Feature" style="flex-grow: 1;">
<engine:Label text="Brush Feature" class="SubHeader" />
<engine:VisualElement class="PropertyContainer" style="flex-grow: 1;">
<engine:HelpBox message-type="Warning" text="You need to set a GPU instancing drawer to let GPU instancing work properly" />
<engine:DropdownField label="Use GPU Instancing" choices="Disable,Enable" index="0">
<Bindings>
<engine:DataBinding property="index" data-source-path="GpuInstancing" binding-mode="TwoWay" />
</Bindings>
</engine:DropdownField>
<engine:DropdownField label="Use Gravity" choices="Disable,Enable" index="0">
<Bindings>
<engine:DataBinding property="index" data-source-path="Gravity" binding-mode="TwoWay" />
</Bindings>
</engine:DropdownField>
<editor:LayerMaskField label="Paint Layer" value="1">
<Bindings>
<engine:DataBinding property="value" data-source-path="PaintLayer" binding-mode="TwoWay" />
</Bindings>
</editor:LayerMaskField>
<engine:DropdownField label="Avoid Overlap" choices="Disable,Enable" index="1">
<Bindings>
<engine:DataBinding property="index" data-source-path="AvoidOverlap" binding-mode="TwoWay" />
</Bindings>
</engine:DropdownField>
</engine:VisualElement>
</engine:VisualElement>
</engine:Tab>
<engine:Tab label="Setting" name="Setting-Tab" icon-image="project://database/Packages/com.misaki.art-tools/Editor/PrefabPainter/Icon/setting.png?fileID=2800000&amp;guid=1517c386de843a742afb10e4d9f20241&amp;type=3#setting">
<editor:ObjectField label="Instance Drawer" type="Misaki.ArtTool.InstanceDrawer, Misaki.ArtTool" />
</engine:Tab>
</engine:TabView>
</engine:VisualElement>
</engine:UXML>

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: a4196f221910b5442bc80d8305ee937e
ScriptedImporter:
internalIDToNameTable: []
externalObjects: {}
serializedVersion: 2
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}