升级obi

This commit is contained in:
2026-01-22 22:08:21 +08:00
parent 120b8cda26
commit 20f14322bc
1067 changed files with 149894 additions and 29583 deletions

View File

@@ -4,6 +4,7 @@ using UnityEngine.SceneManagement;
using UnityEditor;
using UnityEditor.SceneManagement;
using System.IO;
using UnityEngine.Rendering;
namespace Obi{
@@ -127,17 +128,7 @@ namespace Obi{
public static GameObject CreateNewSolver()
{
// Root for the actors.
var root = new GameObject("Obi Solver");
ObiSolver solver = root.AddComponent<ObiSolver>();
// Try to find a fixed updater in the scene (though other kinds of updaters can exist, updating in FixedUpdate is the preferred option).
ObiFixedUpdater updater = StageUtility.GetCurrentStageHandle().FindComponentOfType<ObiFixedUpdater>();
// If we could not find an fixed updater in the scene, add one to the solver object.
if (updater == null)
updater = root.AddComponent<ObiFixedUpdater>();
// Add the solver to the updater:
updater.solvers.Add(solver);
var root = new GameObject("Obi Solver", typeof(ObiSolver));
// Works for all stages.
StageUtility.PlaceGameObjectInCurrentStage(root);
@@ -230,7 +221,34 @@ namespace Obi{
// Return the currently selected item's index
return selected;
}
}
public static void DrawArrowHandle(Vector3 posA, Vector3 posB, float headAngle = 30, float headLength = 0.18f)
{
Handles.DrawLine(posA, posB);
var look = Quaternion.LookRotation(posA - posB, Camera.current.transform.forward);
var one = look * Quaternion.Euler(0, 180 + headAngle, 0) * new Vector3(0, 0, 1);
var two = look * Quaternion.Euler(0, 180 - headAngle, 0) * new Vector3(0, 0, 1);
var sizeA = HandleUtility.GetHandleSize(posA) * headLength;
Handles.DrawLine(posA, posA + one * sizeA);
Handles.DrawLine(posA, posA + two * sizeA);
var sizeB = HandleUtility.GetHandleSize(posB) * headLength;
Handles.DrawLine(posB, posB - one * sizeB);
Handles.DrawLine(posB, posB - two * sizeB);
}
public static Material GetDefaultMaterial()
{
if (GraphicsSettings.defaultRenderPipeline != null)
{
return GraphicsSettings.defaultRenderPipeline.defaultMaterial;
}
else
{
return AssetDatabase.GetBuiltinExtraResource<Material>("Default-Diffuse.mat");
}
}
}
}

View File

@@ -0,0 +1,24 @@
using UnityEditor;
using UnityEngine;
namespace Obi
{
[CustomEditor(typeof(ObiFoamGenerator)), CanEditMultipleObjects]
public class ObiFoamGeneratorEditor : Editor
{
public override void OnInspectorGUI()
{
serializedObject.UpdateIfRequiredOrScript();
DrawPropertiesExcluding(serializedObject, "m_Script");
// Apply changes to the serializedProperty
if (GUI.changed)
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b9656e2c54d9e4c478c74ca6d97428f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -15,6 +15,7 @@ namespace Obi
SerializedProperty targetTransform;
SerializedProperty particleGroup;
SerializedProperty attachmentType;
SerializedProperty projectPosition;
SerializedProperty constrainOrientation;
SerializedProperty compliance;
SerializedProperty breakThreshold;
@@ -28,9 +29,10 @@ namespace Obi
targetTransform = serializedObject.FindProperty("m_Target");
particleGroup = serializedObject.FindProperty("m_ParticleGroup");
attachmentType = serializedObject.FindProperty("m_AttachmentType");
projectPosition = serializedObject.FindProperty("m_Projection");
constrainOrientation = serializedObject.FindProperty("m_ConstrainOrientation");
compliance = serializedObject.FindProperty("m_Compliance");
breakThreshold = serializedObject.FindProperty("m_BreakThreshold");
breakThreshold = serializedObject.FindProperty("breakThreshold");
}
public override void OnInspectorGUI()
@@ -55,7 +57,16 @@ namespace Obi
}
}
EditorGUILayout.PropertyField(targetTransform, new GUIContent("Target"));
EditorGUI.BeginChangeCheck();
Transform trget = EditorGUILayout.ObjectField("Target", attachment.target, typeof(Transform), true) as Transform;
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(attachment, "Set target");
attachment.target = trget;
PrefabUtility.RecordPrefabInstancePropertyModifications(attachment);
}
var blueprint = attachment.actor.sourceBlueprint;
if (blueprint != null)
@@ -89,6 +100,7 @@ namespace Obi
if (attachment.attachmentType == ObiParticleAttachment.AttachmentType.Dynamic)
{
EditorGUILayout.PropertyField(projectPosition, new GUIContent("Projection"));
EditorGUILayout.PropertyField(compliance, new GUIContent("Compliance"));
EditorGUILayout.PropertyField(breakThreshold, new GUIContent("Break threshold"));
}