本文整理汇总了C#中UnityEditor类的典型用法代码示例。如果您正苦于以下问题:C# UnityEditor类的具体用法?C# UnityEditor怎么用?C# UnityEditor使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UnityEditor类属于命名空间,在下文中一共展示了UnityEditor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetFiltered
public static UnityEngine.Object[] GetFiltered(System.Type type, UnityEditor.SelectionMode mode)
{
ArrayList list = new ArrayList();
if ((type == typeof(Component)) || type.IsSubclassOf(typeof(Component)))
{
foreach (Transform transform in GetTransforms(mode))
{
Component component = transform.GetComponent(type);
if (component != null)
{
list.Add(component);
}
}
}
else if ((type == typeof(GameObject)) || type.IsSubclassOf(typeof(GameObject)))
{
foreach (Transform transform2 in GetTransforms(mode))
{
list.Add(transform2.gameObject);
}
}
else
{
foreach (UnityEngine.Object obj2 in GetObjectsMode(mode))
{
if ((obj2 != null) && ((obj2.GetType() == type) || obj2.GetType().IsSubclassOf(type)))
{
list.Add(obj2);
}
}
}
return (UnityEngine.Object[]) list.ToArray(typeof(UnityEngine.Object));
}
示例2: Connect
public override void Connect(UnityEditor.Graphs.AnimationStateMachine.Node toNode, UnityEditor.Graphs.Edge edge)
{
if (toNode is StateNode)
{
base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineTransition(this.stateMachine, (toNode as StateNode).state);
base.graphGUI.stateMachineGraph.RebuildGraph();
}
else if (toNode is StateMachineNode)
{
UnityEditor.Graphs.AnimationStateMachine.Node.GenericMenuForStateMachineNode(toNode as StateMachineNode, true, delegate (object data) {
if (data is AnimatorState)
{
base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineTransition(this.stateMachine, data as AnimatorState);
}
else
{
base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineTransition(this.stateMachine, data as AnimatorStateMachine);
}
base.graphGUI.stateMachineGraph.RebuildGraph();
});
}
else if (toNode is ExitNode)
{
base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineExitTransition(this.stateMachine);
base.graphGUI.stateMachineGraph.RebuildGraph();
}
}
示例3: NodeUI
public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
{
base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
Assert.NotNull(base.graphGUI);
if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
{
host.edgeGUI.EndSlotDragging(Enumerable.First<Slot>(base.inputSlots), true);
}
if (UnityEditor.Graphs.AnimationStateMachine.Node.IsDoubleClick())
{
if (this.stateMachine == base.graphGUI.stateMachineGraph.parentStateMachine)
{
base.graphGUI.tool.GoToBreadCrumbTarget(this.stateMachine);
}
else
{
base.graphGUI.tool.AddBreadCrumb(this.stateMachine);
}
Event.current.Use();
}
if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick() && (this.stateMachine != base.graphGUI.stateMachineGraph.parentStateMachine))
{
GenericMenu menu = new GenericMenu();
menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
menu.AddItem(new GUIContent("Copy"), false, new GenericMenu.MenuFunction(this.CopyStateMachineCallback));
menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction(this.DeleteStateMachineCallback));
menu.ShowAsContext();
Event.current.Use();
}
}
示例4: GenerateObjectTypeGroups
private static List<MemoryElement> GenerateObjectTypeGroups(UnityEditor.ObjectInfo[] memory, ObjectTypeFilter filter)
{
List<MemoryElement> list = new List<MemoryElement>();
MemoryElement item = null;
foreach (UnityEditor.ObjectInfo info in memory)
{
if (GetObjectTypeFilter(info) == filter)
{
if ((item == null) || (info.className != item.name))
{
item = new MemoryElement(info.className);
list.Add(item);
}
item.AddChild(new MemoryElement(info, true));
}
}
list.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
foreach (MemoryElement element2 in list)
{
element2.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
if ((filter == ObjectTypeFilter.Other) && !HasValidNames(element2.children))
{
element2.children.Clear();
}
}
return list;
}
示例5: SceneEntry
/// <summary>
/// Construct from a Unity SceneSetup
/// </summary>
public SceneEntry( UnityEditor.SceneManagement.SceneSetup sceneSetup )
{
scene = new AmsSceneReference( sceneSetup.path );
loadInEditor = sceneSetup.isLoaded;
loadMethod = LoadMethod.Additive;
}
示例6: Connect
public override void Connect(UnityEditor.Graphs.AnimationStateMachine.Node toNode, UnityEditor.Graphs.Edge edge)
{
if (toNode is StateNode)
{
base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition((toNode as StateNode).state);
base.graphGUI.stateMachineGraph.RebuildGraph();
}
if (toNode is StateMachineNode)
{
StateMachineNode node = toNode as StateMachineNode;
if (node.stateMachine != base.graphGUI.parentStateMachine)
{
UnityEditor.Graphs.AnimationStateMachine.Node.GenericMenuForStateMachineNode(toNode as StateMachineNode, true, delegate (object data) {
if (data is AnimatorState)
{
base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition(data as AnimatorState);
}
else if (data is AnimatorStateMachine)
{
base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition(data as AnimatorStateMachine);
}
base.graphGUI.stateMachineGraph.RebuildGraph();
});
}
}
if (toNode is EntryNode)
{
base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition(base.graphGUI.activeStateMachine);
}
}
示例7: NodeUI
public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
{
if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
{
host.edgeGUI.EndSlotDragging(Enumerable.First<Slot>(base.inputSlots), true);
}
}
示例8: SaveToIndex
private static void SaveToIndex(UnityEditor.MenuCommand mc, int index) {
PositionSwapper ps = mc.context as PositionSwapper;
while (ps.Positions.Length <= index) {
UnityEditor.ArrayUtility.Add<Vector3>(ref ps.Positions, Vector3.zero);
}
ps.Positions[index] = ps.transform.localPosition;
}
示例9: SetAttribute
public static void SetAttribute( UnityEditor.PropertyDrawer drawer, PropertyAttribute attribute )
{
FieldInfo fi = TargetType.GetField( "m_Attribute", BindingFlags.NonPublic | BindingFlags.Instance );
if( fi == null ){
Debug.Log( "Error, FieldInfo not found" );
return;
}
fi.SetValue( drawer, attribute );
}
示例10: OnGUI
public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
{
string fieldName;
bool notifyPropertyChanged;
{
var attr = this.attribute as InspectorDisplayAttribute;
fieldName = (attr == null) ? "value" : attr.FieldName;
notifyPropertyChanged = (attr == null) ? true : attr.NotifyPropertyChanged;
}
if (notifyPropertyChanged)
{
EditorGUI.BeginChangeCheck();
}
var targetSerializedProperty = property.FindPropertyRelative(fieldName);
if (targetSerializedProperty == null)
{
UnityEditor.EditorGUI.LabelField(position, label, new GUIContent() { text = "InspectorDisplay can't find target:" + fieldName });
if (notifyPropertyChanged)
{
EditorGUI.EndChangeCheck();
}
return;
}
else
{
EmitPropertyField(position, targetSerializedProperty, label);
}
if (notifyPropertyChanged)
{
if (EditorGUI.EndChangeCheck())
{
var propInfo = fieldInfo.FieldType.GetProperty(fieldName, BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
property.serializedObject.ApplyModifiedProperties(); // deserialize to field
var paths = property.propertyPath.Split('.'); // X.Y.Z...
var attachedComponent = property.serializedObject.targetObject;
var targetProp = (paths.Length == 1)
? fieldInfo.GetValue(attachedComponent)
: GetValueRecursive(attachedComponent, 0, paths);
var modifiedValue = propInfo.GetValue(targetProp, null); // retrieve new value
var methodInfo = fieldInfo.FieldType.GetMethod("SetValueAndForceNotify", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (methodInfo != null)
{
methodInfo.Invoke(targetProp, new object[] { modifiedValue });
}
}
else
{
property.serializedObject.ApplyModifiedProperties();
}
}
}
示例11: OnContextMenu
////////////////////////////////////////
///////////GUI AND EDITOR STUFF/////////
////////////////////////////////////////
#if UNITY_EDITOR
protected override UnityEditor.GenericMenu OnContextMenu(UnityEditor.GenericMenu menu){
menu.AddItem( new GUIContent("Breakpoint"), isBreakpoint, ()=> { isBreakpoint = !isBreakpoint; } );
menu.AddItem (new GUIContent ("Convert to SubTree"), false, ()=> { MakeNestedSubTree(this); });
if (outConnections.Count > 0){
menu.AddItem (new GUIContent ("Delete Branch"), false, ()=> { DeleteBranch(this); } );
menu.AddItem(new GUIContent("Duplicate Branch"), false, ()=> { DuplicateBranch(this, graph); });
}
return menu;
}
示例12: GetInspectedType
public static Type GetInspectedType( UnityEditor.CustomEditor editor )
{
if( m_InspectedType == null )
m_InspectedType = TargetType.GetField( "m_InspectedType", BindingFlags.NonPublic | BindingFlags.Instance );
if( m_InspectedType == null ){
Debug.Log( "FieldInfo Not Found" );
return null;
}
return m_InspectedType.GetValue( editor ) as Type;
}
示例13: FindAnimationClips
// AnimatorController内のステートを取得する
private List<UnityEditor.Animations.AnimatorState> FindAnimationClips(
UnityEditor.Animations.AnimatorController animatorController)
{
var stateList = new List<UnityEditor.Animations.AnimatorState> ();
foreach (var layer in animatorController.layers) {
foreach (var state in layer.stateMachine.states) {
stateList.Add (state.state);
}
}
return stateList;
}
示例14: OnContextMenu
////////////////////////////////////////
///////////GUI AND EDITOR STUFF/////////
////////////////////////////////////////
protected override UnityEditor.GenericMenu OnContextMenu(UnityEditor.GenericMenu menu)
{
menu.AddItem( new GUIContent("Breakpoint"), isBreakpoint, ()=> { isBreakpoint = !isBreakpoint; } );
menu.AddItem (new GUIContent ("Convert to SubTree"), false, ()=> { MakeNestedSubTree(this); });
if (outConnections.Count > 0){
menu.AddItem (new GUIContent ("Delete Branch"), false, ()=> { DeleteBranch(this); } );
menu.AddItem(new GUIContent("Duplicate Branch"), false, ()=> { DuplicateBranch(this, graph); });
}
menu = EditorUtils.GetTypeSelectionMenu(typeof(BTComposite), (t)=>{ ReplaceWith(t); }, menu, "Replace");
return menu;
}
示例15: SetSerializedObject
public static void SetSerializedObject( UnityEditor.Editor editor, UnityEditor.SerializedObject obj )
{
if( m_SerializedObjectFieldInfo == null )
m_SerializedObjectFieldInfo = TargetType.GetField( "m_SerializedObject",
BindingFlags.NonPublic | BindingFlags.Instance );
if( m_SerializedObjectFieldInfo == null ){
Debug.Log( "FieldInfo Not Found" );
return;
}
m_SerializedObjectFieldInfo.SetValue( editor, obj );
}