testss
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D.IK;
|
||||
|
||||
namespace UnityEditor.U2D.IK
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Inspector for CCDSolver2D.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(CCDSolver2D))]
|
||||
[CanEditMultipleObjects]
|
||||
public class CCDSolver2DEditor : Solver2DEditor
|
||||
{
|
||||
private static class Contents
|
||||
{
|
||||
public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
|
||||
public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
|
||||
public static readonly GUIContent chainLengthLabel = new GUIContent("Chain Length", "Number of Transforms handled by the IK");
|
||||
public static readonly GUIContent iterationsLabel = new GUIContent("Iterations", "Number of iterations the IK solver is run per frame");
|
||||
public static readonly GUIContent toleranceLabel = new GUIContent("Tolerance", "How close the target is to the goal to be considered as successful");
|
||||
public static readonly GUIContent velocityLabel = new GUIContent("Velocity", "How fast the chain elements rotate to the effector per iteration");
|
||||
}
|
||||
|
||||
private SerializedProperty m_TargetProperty;
|
||||
private SerializedProperty m_EffectorProperty;
|
||||
private SerializedProperty m_TransformCountProperty;
|
||||
|
||||
private SerializedProperty m_IterationsProperty;
|
||||
private SerializedProperty m_ToleranceProperty;
|
||||
private SerializedProperty m_VelocityProperty;
|
||||
private CCDSolver2D m_Solver;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Solver = target as CCDSolver2D;
|
||||
var chainProperty = serializedObject.FindProperty("m_Chain");
|
||||
m_TargetProperty = chainProperty.FindPropertyRelative("m_TargetTransform");
|
||||
m_EffectorProperty = chainProperty.FindPropertyRelative("m_EffectorTransform");
|
||||
m_TransformCountProperty = chainProperty.FindPropertyRelative("m_TransformCount");
|
||||
m_IterationsProperty = serializedObject.FindProperty("m_Iterations");
|
||||
m_ToleranceProperty = serializedObject.FindProperty("m_Tolerance");
|
||||
m_VelocityProperty = serializedObject.FindProperty("m_Velocity");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom Inspector OnInspectorGUI override.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
IKChain2D chain = m_Solver.GetChain(0);
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_EffectorProperty, Contents.effectorLabel);
|
||||
EditorGUILayout.PropertyField(m_TargetProperty, Contents.targetLabel);
|
||||
EditorGUILayout.IntSlider(m_TransformCountProperty, 0, IKUtility.GetMaxChainCount(chain), Contents.chainLengthLabel);
|
||||
EditorGUILayout.PropertyField(m_IterationsProperty, Contents.iterationsLabel);
|
||||
EditorGUILayout.PropertyField(m_ToleranceProperty, Contents.toleranceLabel);
|
||||
EditorGUILayout.PropertyField(m_VelocityProperty, Contents.velocityLabel);
|
||||
|
||||
DrawCommonSolverInspector();
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D.IK;
|
||||
|
||||
namespace UnityEditor.U2D.IK
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Inspector for FabrikSolver2D.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(FabrikSolver2D))]
|
||||
[CanEditMultipleObjects]
|
||||
public class FabrikSolver2DEditor : Solver2DEditor
|
||||
{
|
||||
private static class Contents
|
||||
{
|
||||
public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
|
||||
public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
|
||||
public static readonly GUIContent chainLengthLabel = new GUIContent("Chain Length", "Number of Transforms handled by the IK");
|
||||
public static readonly GUIContent iterationsLabel = new GUIContent("Iterations", "Number of iterations the IK solver is run per frame");
|
||||
public static readonly GUIContent toleranceLabel = new GUIContent("Tolerance", "How close the target is to the goal to be considered as successful");
|
||||
}
|
||||
|
||||
private SerializedProperty m_TargetProperty;
|
||||
private SerializedProperty m_EffectorProperty;
|
||||
private SerializedProperty m_TransformCountProperty;
|
||||
private SerializedProperty m_IterationsProperty;
|
||||
private SerializedProperty m_ToleranceProperty;
|
||||
private FabrikSolver2D m_Solver;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Solver = target as FabrikSolver2D;
|
||||
var chainProperty = serializedObject.FindProperty("m_Chain");
|
||||
m_TargetProperty = chainProperty.FindPropertyRelative("m_TargetTransform");
|
||||
m_EffectorProperty = chainProperty.FindPropertyRelative("m_EffectorTransform");
|
||||
m_TransformCountProperty = chainProperty.FindPropertyRelative("m_TransformCount");
|
||||
m_IterationsProperty = serializedObject.FindProperty("m_Iterations");
|
||||
m_ToleranceProperty = serializedObject.FindProperty("m_Tolerance");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom Inspector OnInspectorGUI override.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
IKChain2D chain = m_Solver.GetChain(0);
|
||||
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_EffectorProperty, Contents.effectorLabel);
|
||||
EditorGUILayout.PropertyField(m_TargetProperty, Contents.targetLabel);
|
||||
EditorGUILayout.IntSlider(m_TransformCountProperty, 0, IKUtility.GetMaxChainCount(chain), Contents.chainLengthLabel);
|
||||
EditorGUILayout.PropertyField(m_IterationsProperty, Contents.iterationsLabel);
|
||||
EditorGUILayout.PropertyField(m_ToleranceProperty, Contents.toleranceLabel);
|
||||
|
||||
DrawCommonSolverInspector();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,219 @@
|
||||
using UnityEditorInternal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D.IK;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Linq;
|
||||
using UnityEditor.U2D.Animation;
|
||||
|
||||
namespace UnityEditor.U2D.IK
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Inspector for IKManager2D.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(IKManager2D))]
|
||||
[CanEditMultipleObjects]
|
||||
class IKManager2DEditor : Editor
|
||||
{
|
||||
private class Contents
|
||||
{
|
||||
public static readonly GUIContent findAllSolversLabel = new GUIContent("Find Solvers", "Find all applicable solvers handled by this manager");
|
||||
public static readonly GUIContent weightLabel = new GUIContent("Weight", "Blend between Forward and Inverse Kinematics");
|
||||
public static readonly string listHeaderLabel = "IK Solvers";
|
||||
public static readonly string createSolverString = "Create Solver";
|
||||
public static readonly string restoreDefaultPoseString = "Restore Default Pose";
|
||||
public static readonly GUIContent gizmoColorTooltip = new GUIContent("","Customizes the IK Chain's Gizmo color");
|
||||
public static int showGizmoPropertyWidth = 20;
|
||||
public static int solverPropertyWidth = 100;
|
||||
public static int solverColorPropertyWidth = 40;
|
||||
public static readonly GUIContent gizmoVisibilityToolTip = new GUIContent("",L10n.Tr("Show/Hide Gizmo"));
|
||||
public readonly GUIStyle visibilityToggleStyle;
|
||||
|
||||
public Contents()
|
||||
{
|
||||
visibilityToggleStyle = new GUIStyle();
|
||||
visibilityToggleStyle.fixedWidth = EditorGUIUtility.singleLineHeight;
|
||||
visibilityToggleStyle.onNormal.background = IconUtility.LoadIconResource("Visibility_Tool", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath);
|
||||
visibilityToggleStyle.normal.background = IconUtility.LoadIconResource("Visibility_Hidded", IconUtility.k_LightIconResourcePath, IconUtility.k_DarkIconResourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
static Contents k_Contents;
|
||||
private ReorderableList m_ReorderableList;
|
||||
private Solver2D m_SelectedSolver;
|
||||
private Editor m_SelectedSolverEditor;
|
||||
|
||||
SerializedProperty m_SolversProperty;
|
||||
SerializedProperty m_SolverEditorDataProperty;
|
||||
SerializedProperty m_WeightProperty;
|
||||
List<Type> m_SolverTypes;
|
||||
IKManager2D m_Manager;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_Manager = target as IKManager2D;
|
||||
m_SolverTypes = GetDerivedTypes<Solver2D>();
|
||||
m_SolversProperty = serializedObject.FindProperty("m_Solvers");
|
||||
m_SolverEditorDataProperty = serializedObject.FindProperty("m_SolverEditorData");
|
||||
m_WeightProperty = serializedObject.FindProperty("m_Weight");
|
||||
SetupReordeableList();
|
||||
}
|
||||
|
||||
void SetupReordeableList()
|
||||
{
|
||||
m_ReorderableList = new ReorderableList(serializedObject, m_SolversProperty, true, true, true, true);
|
||||
m_ReorderableList.drawHeaderCallback = (Rect rect) =>
|
||||
{
|
||||
GUI.Label(rect, Contents.listHeaderLabel);
|
||||
};
|
||||
m_ReorderableList.elementHeightCallback = (int index) =>
|
||||
{
|
||||
return EditorGUIUtility.singleLineHeight + 6;
|
||||
};
|
||||
m_ReorderableList.drawElementCallback = (Rect rect, int index, bool isactive, bool isfocused) =>
|
||||
{
|
||||
rect.y += 2f;
|
||||
rect.height = EditorGUIUtility.singleLineHeight;
|
||||
SerializedProperty element = m_SolversProperty.GetArrayElementAtIndex(index);
|
||||
SerializedProperty elementData = m_SolverEditorDataProperty.GetArrayElementAtIndex(index);
|
||||
var width = rect.width;
|
||||
rect.width = width > Contents.showGizmoPropertyWidth ? Contents.showGizmoPropertyWidth : width;
|
||||
var showGizmoProperty = elementData.FindPropertyRelative("showGizmo");
|
||||
showGizmoProperty.boolValue = GUI.Toggle(rect, showGizmoProperty.boolValue, Contents.gizmoVisibilityToolTip, k_Contents.visibilityToggleStyle);
|
||||
rect.x += rect.width;
|
||||
width -= rect.width;
|
||||
rect.width = width > Contents.solverPropertyWidth ? width - Contents.solverColorPropertyWidth : Contents.solverPropertyWidth;
|
||||
EditorGUI.PropertyField(rect, element, GUIContent.none);
|
||||
rect.x += rect.width;
|
||||
width -= 100;
|
||||
rect.width = width > Contents.solverColorPropertyWidth ? Contents.solverColorPropertyWidth : width;
|
||||
EditorGUI.PropertyField(rect, elementData.FindPropertyRelative("color"), Contents.gizmoColorTooltip);
|
||||
};
|
||||
m_ReorderableList.onAddCallback = (ReorderableList list) =>
|
||||
{
|
||||
var menu = new GenericMenu();
|
||||
|
||||
foreach (Type type in m_SolverTypes)
|
||||
{
|
||||
Solver2DMenuAttribute attribute = Attribute.GetCustomAttribute(type, typeof(Solver2DMenuAttribute)) as Solver2DMenuAttribute;
|
||||
|
||||
if (attribute != null)
|
||||
menu.AddItem(new GUIContent(attribute.menuPath), false, OnSelectMenu, type);
|
||||
else
|
||||
menu.AddItem(new GUIContent(type.Name), false, OnSelectMenu, type);
|
||||
}
|
||||
|
||||
menu.ShowAsContext();
|
||||
};
|
||||
m_ReorderableList.onRemoveCallback = (ReorderableList list) =>
|
||||
{
|
||||
Solver2D solver = m_Manager.solvers[list.index];
|
||||
if (solver)
|
||||
{
|
||||
Undo.RegisterCompleteObjectUndo(m_Manager, Undo.GetCurrentGroupName());
|
||||
|
||||
m_Manager.RemoveSolver(solver);
|
||||
|
||||
GameObject solverGO = solver.gameObject;
|
||||
|
||||
if (solverGO.transform.childCount == 0)
|
||||
Undo.DestroyObjectImmediate(solverGO);
|
||||
else
|
||||
Undo.DestroyObjectImmediate(solver);
|
||||
|
||||
EditorUtility.SetDirty(m_Manager);
|
||||
}
|
||||
else
|
||||
{
|
||||
ReorderableList.defaultBehaviours.DoRemoveButton(list);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void OnSelectMenu(object param)
|
||||
{
|
||||
Type solverType = param as Type;
|
||||
|
||||
GameObject solverGO = new GameObject(GameObjectUtility.GetUniqueNameForSibling(m_Manager.transform, "New " + solverType.Name));
|
||||
solverGO.transform.SetParent(m_Manager.transform);
|
||||
solverGO.transform.localPosition = Vector3.zero;
|
||||
solverGO.transform.rotation = Quaternion.identity;
|
||||
solverGO.transform.localScale = Vector3.one;
|
||||
|
||||
Solver2D solver = solverGO.AddComponent(solverType) as Solver2D;
|
||||
|
||||
Undo.RegisterCreatedObjectUndo(solverGO, Contents.createSolverString);
|
||||
Undo.RegisterCompleteObjectUndo(m_Manager, Contents.createSolverString);
|
||||
m_Manager.AddSolver(solver);
|
||||
EditorUtility.SetDirty(m_Manager);
|
||||
|
||||
Selection.activeGameObject = solverGO;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom Inspector OnInspectorGUI override.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
if(k_Contents == null)
|
||||
k_Contents = new Contents();
|
||||
|
||||
serializedObject.Update();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
m_ReorderableList.DoLayoutList();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.PropertyField(m_WeightProperty, Contents.weightLabel);
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
DoRestoreDefaultPoseButton();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void DoRestoreDefaultPoseButton()
|
||||
{
|
||||
if (GUILayout.Button(Contents.restoreDefaultPoseString, GUILayout.MaxWidth(150f)))
|
||||
{
|
||||
foreach (var l_target in targets)
|
||||
{
|
||||
var manager = l_target as IKManager2D;
|
||||
|
||||
IKEditorManager.instance.Record(manager, Contents.restoreDefaultPoseString);
|
||||
|
||||
foreach(var solver in manager.solvers)
|
||||
{
|
||||
for(int i = 0; i < solver.chainCount; ++i)
|
||||
{
|
||||
var chain = solver.GetChain(i);
|
||||
chain.RestoreDefaultPose(solver.constrainRotation);
|
||||
|
||||
if(chain.target)
|
||||
{
|
||||
chain.target.position = chain.effector.position;
|
||||
chain.target.rotation = chain.effector.rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IKEditorManager.instance.UpdateManagerImmediate(manager, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<Type> GetDerivedTypes<T>() where T : class
|
||||
{
|
||||
List<Type> types = Assembly.GetAssembly(typeof(T)).GetTypes().Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(T))).ToList();
|
||||
return types;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D.IK;
|
||||
|
||||
namespace UnityEditor.U2D.IK
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Inspector for LimbSolver2D.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(LimbSolver2D))]
|
||||
[CanEditMultipleObjects]
|
||||
public class LimbSolver2DEditor : Solver2DEditor
|
||||
{
|
||||
private static class Contents
|
||||
{
|
||||
public static readonly GUIContent effectorLabel = new GUIContent("Effector", "The last Transform of a hierarchy constrained by the target");
|
||||
public static readonly GUIContent targetLabel = new GUIContent("Target", "Transfrom which the effector will follow");
|
||||
public static readonly GUIContent flipLabel = new GUIContent("Flip", "Select between the two possible solutions of the solver");
|
||||
}
|
||||
|
||||
private SerializedProperty m_ChainProperty;
|
||||
private SerializedProperty m_FlipProperty;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
m_ChainProperty = serializedObject.FindProperty("m_Chain");
|
||||
m_FlipProperty = serializedObject.FindProperty("m_Flip");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom Inspector OnInspectorGUI override.
|
||||
/// </summary>
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(m_ChainProperty.FindPropertyRelative("m_EffectorTransform"), Contents.effectorLabel);
|
||||
EditorGUILayout.PropertyField(m_ChainProperty.FindPropertyRelative("m_TargetTransform"), Contents.targetLabel);
|
||||
EditorGUILayout.PropertyField(m_FlipProperty, Contents.flipLabel);
|
||||
|
||||
DrawCommonSolverInspector();
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,164 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.U2D.IK;
|
||||
|
||||
namespace UnityEditor.U2D.IK
|
||||
{
|
||||
/// <summary>
|
||||
/// Custom Inspector for Solver2D.
|
||||
/// </summary>
|
||||
[CustomEditor(typeof(Solver2D))]
|
||||
[CanEditMultipleObjects]
|
||||
public class Solver2DEditor : Editor
|
||||
{
|
||||
private static class Contents
|
||||
{
|
||||
public static readonly GUIContent constrainRotationLabel = new GUIContent("Constrain Rotation", "Set Effector's rotation to Target");
|
||||
public static readonly GUIContent solveFromDefaultPoseLabel = new GUIContent("Solve from Default Pose", "Restore transform's rotation to default value before solving the IK");
|
||||
public static readonly GUIContent weightLabel = new GUIContent("Weight", "Blend between Forward and Inverse Kinematics");
|
||||
public static readonly string restoreDefaultPoseString = "Restore Default Pose";
|
||||
public static readonly string createTargetString = "Create Target";
|
||||
}
|
||||
|
||||
private SerializedProperty m_ConstrainRotationProperty;
|
||||
private SerializedProperty m_SolveFromDefaultPoseProperty;
|
||||
private SerializedProperty m_WeightProperty;
|
||||
private SerializedProperty m_SolverColorProperty;
|
||||
|
||||
private void SetupProperties()
|
||||
{
|
||||
if(m_ConstrainRotationProperty == null || m_SolveFromDefaultPoseProperty == null || m_WeightProperty == null)
|
||||
{
|
||||
m_ConstrainRotationProperty = serializedObject.FindProperty("m_ConstrainRotation");
|
||||
m_SolveFromDefaultPoseProperty = serializedObject.FindProperty("m_SolveFromDefaultPose");
|
||||
m_WeightProperty = serializedObject.FindProperty("m_Weight");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Custom Inspector GUI for Solver2D.
|
||||
/// </summary>
|
||||
protected void DrawCommonSolverInspector()
|
||||
{
|
||||
SetupProperties();
|
||||
|
||||
EditorGUILayout.PropertyField(m_ConstrainRotationProperty, Contents.constrainRotationLabel);
|
||||
EditorGUILayout.PropertyField(m_SolveFromDefaultPoseProperty, Contents.solveFromDefaultPoseLabel);
|
||||
EditorGUILayout.PropertyField(m_WeightProperty, Contents.weightLabel);
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
EditorGUILayout.BeginHorizontal();
|
||||
GUILayout.FlexibleSpace();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!EnableCreateTarget());
|
||||
DoCreateTargetButton();
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
EditorGUI.BeginDisabledGroup(!EnableRestoreDefaultPose());
|
||||
DoRestoreDefaultPoseButton();
|
||||
EditorGUI.EndDisabledGroup();
|
||||
|
||||
GUILayout.FlexibleSpace();
|
||||
EditorGUILayout.EndHorizontal();
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
private bool EnableRestoreDefaultPose()
|
||||
{
|
||||
foreach (var l_target in targets)
|
||||
{
|
||||
var solver = l_target as Solver2D;
|
||||
|
||||
if (!solver.isValid || IKEditorManager.instance.FindManager(solver) == null)
|
||||
continue;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool EnableCreateTarget()
|
||||
{
|
||||
foreach (var l_target in targets)
|
||||
{
|
||||
var solver = l_target as Solver2D;
|
||||
|
||||
if (!solver.isValid)
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < solver.chainCount; ++i)
|
||||
{
|
||||
var chain = solver.GetChain(i);
|
||||
|
||||
if(chain.target == null)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void DoRestoreDefaultPoseButton()
|
||||
{
|
||||
if (GUILayout.Button(Contents.restoreDefaultPoseString, GUILayout.MaxWidth(150f)))
|
||||
{
|
||||
foreach (var l_target in targets)
|
||||
{
|
||||
var solver = l_target as Solver2D;
|
||||
|
||||
if (!solver.isValid)
|
||||
continue;
|
||||
|
||||
IKEditorManager.instance.Record(solver, Contents.restoreDefaultPoseString);
|
||||
|
||||
for(int i = 0; i < solver.chainCount; ++i)
|
||||
{
|
||||
var chain = solver.GetChain(i);
|
||||
chain.RestoreDefaultPose(solver.constrainRotation);
|
||||
|
||||
if(chain.target)
|
||||
{
|
||||
chain.target.position = chain.effector.position;
|
||||
chain.target.rotation = chain.effector.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
IKEditorManager.instance.UpdateSolverImmediate(solver, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void DoCreateTargetButton()
|
||||
{
|
||||
if (GUILayout.Button(Contents.createTargetString, GUILayout.MaxWidth(125f)))
|
||||
{
|
||||
foreach (var l_target in targets)
|
||||
{
|
||||
var solver = l_target as Solver2D;
|
||||
|
||||
if (!solver.isValid)
|
||||
continue;
|
||||
|
||||
for(int i = 0; i < solver.chainCount; ++i)
|
||||
{
|
||||
var chain = solver.GetChain(i);
|
||||
|
||||
if(chain.target == null)
|
||||
{
|
||||
Undo.RegisterCompleteObjectUndo(solver, Contents.createTargetString);
|
||||
|
||||
chain.target = new GameObject(GameObjectUtility.GetUniqueNameForSibling(solver.transform, solver.name + "_Target")).transform;
|
||||
chain.target.SetParent(solver.transform);
|
||||
chain.target.position = chain.effector.position;
|
||||
chain.target.rotation = chain.effector.rotation;
|
||||
|
||||
Undo.RegisterCreatedObjectUndo(chain.target.gameObject, Contents.createTargetString);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user