本文整理汇总了C#中UnityEditor.MenuCommand类的典型用法代码示例。如果您正苦于以下问题:C# MenuCommand类的具体用法?C# MenuCommand怎么用?C# MenuCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MenuCommand类属于UnityEditor命名空间,在下文中一共展示了MenuCommand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BackupTransform
public static void BackupTransform(MenuCommand command)
{
if (command.context is Component) {
var component = (Component)command.context;
fiBackupManager.CreateBackup(component);
}
}
示例2: PasteComponentAsNew
static void PasteComponentAsNew( MenuCommand command )
{
TileComponent component = command.context as TileComponent;
Tile tile = component.tile;
TileComponentUtility.PasteComponentAsNew( tile );
}
示例3: BackupBaseBehavior
public static void BackupBaseBehavior(MenuCommand command)
{
if (command.context is Component) {
var component = (Component)command.context;
fiBackupManager.CreateBackup(component);
}
}
示例4: CreateGameObjectAsChild
static void CreateGameObjectAsChild (MenuCommand command)
{
Transform tr = (Transform)command.context;
GameObject go = new GameObject ("Locator_");
go.transform.parent = tr;
go.transform.localPosition = Vector3.zero;
}
示例5: BatchTargets
private static void BatchTargets(MenuCommand aCommand)
{
BatchingUtil batcher = aCommand.context as BatchingUtil;
if(batcher == null)
{
return;
}
List<GameObject> targets = new List<GameObject>();
IEnumerator iter = batcher.transform.GetEnumerator();
while(iter.MoveNext())
{
Transform transform = iter.Current as Transform;
if(transform == null)
{
DebugUtils.LogWarning("Missing transform while trying to batch targets.");
continue;
}
if(transform.renderer != null)
{
targets.Add(transform.gameObject);
}
}
batcher.m_Targets = targets.ToArray();
EditorUtility.SetDirty(batcher);
}
示例6: SubmitTest
private static bool SubmitTest(MenuCommand cmd)
{
AssetList listFromSelection = Provider.GetAssetListFromSelection();
if (Provider.enabled)
return Provider.SubmitIsValid((ChangeSet) null, listFromSelection);
return false;
}
示例7: CheckOutBothTest
private static bool CheckOutBothTest(MenuCommand cmd)
{
AssetList listFromSelection = Provider.GetAssetListFromSelection();
if (Provider.enabled)
return Provider.CheckoutIsValid(listFromSelection, CheckoutMode.Both);
return false;
}
示例8: PasteMaterialProperties
static void PasteMaterialProperties(MenuCommand command)
{
if (m_copiedProperties == null)
{
Debug.LogWarning("No Material Properties to Paste. Use Copy Material Properties first.");
return;
}
Material mat = (Material)command.context;
Undo.RecordObject(mat, "Paste Material");
if (mat.HasProperty(ShaderUtilities.ID_GradientScale))
{
// Preserve unique SDF properties from destination material.
m_copiedProperties.SetTexture(ShaderUtilities.ID_MainTex, mat.GetTexture(ShaderUtilities.ID_MainTex));
m_copiedProperties.SetFloat(ShaderUtilities.ID_GradientScale, mat.GetFloat(ShaderUtilities.ID_GradientScale));
m_copiedProperties.SetFloat(ShaderUtilities.ID_TextureWidth, mat.GetFloat(ShaderUtilities.ID_TextureWidth));
m_copiedProperties.SetFloat(ShaderUtilities.ID_TextureHeight, mat.GetFloat(ShaderUtilities.ID_TextureHeight));
}
EditorShaderUtilities.CopyMaterialProperties(m_copiedProperties, mat);
// Copy ShaderKeywords from one material to the other.
mat.shaderKeywords = m_copiedProperties.shaderKeywords;
// Let TextMeshPro Objects that this mat has changed.
TMPro_EventManager.ON_MATERIAL_PROPERTY_CHANGED(true, mat);
}
示例9: GetLatestTest
private static bool GetLatestTest(MenuCommand cmd)
{
AssetList listFromSelection = Provider.GetAssetListFromSelection();
if (Provider.enabled)
return Provider.GetLatestIsValid(listFromSelection);
return false;
}
示例10: CreateGameObjectContext
public static void CreateGameObjectContext(MenuCommand menuCommand)
{
var root = new GameObject("GameObjectContext").AddComponent<GameObjectContext>();
Selection.activeGameObject = root.gameObject;
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
示例11: CreateBone
public static void CreateBone(MenuCommand menuCommand)
{
GameObject bone = new GameObject("New bone");
Bone2D boneComponent = bone.AddComponent<Bone2D>();
Undo.RegisterCreatedObjectUndo(bone, "Create bone");
bone.transform.position = GetDefaultInstantiatePosition();
GameObject selectedGO = Selection.activeGameObject;
if(selectedGO)
{
bone.transform.parent = selectedGO.transform;
Vector3 localPosition = bone.transform.localPosition;
localPosition.z = 0f;
bone.transform.localPosition = localPosition;
bone.transform.localRotation = Quaternion.identity;
bone.transform.localScale = Vector3.one;
Bone2D selectedBone = selectedGO.GetComponent<Bone2D>();
if(selectedBone)
{
if(!selectedBone.child)
{
bone.transform.position = selectedBone.endPosition;
selectedBone.child = boneComponent;
}
}
}
Selection.activeGameObject = bone;
}
示例12: ContextCreateSpriteMesh
static void ContextCreateSpriteMesh(MenuCommand menuCommand)
{
GameObject spriteRendererGO = Selection.activeGameObject;
SpriteRenderer spriteRenderer = null;
SpriteMesh spriteMesh = null;
if(spriteRendererGO)
{
spriteRenderer = spriteRendererGO.GetComponent<SpriteRenderer>();
}
if(spriteRenderer &&
spriteRenderer.sprite)
{
SpriteMesh overrideSpriteMesh = SpriteMeshPostprocessor.GetSpriteMeshFromSprite(spriteRenderer.sprite);
if(overrideSpriteMesh)
{
spriteMesh = overrideSpriteMesh;
}else{
spriteMesh = SpriteMeshUtils.CreateSpriteMesh(spriteRenderer.sprite);
}
}
if(spriteMesh)
{
Undo.SetCurrentGroupName("create SpriteMeshInstance");
Undo.DestroyObjectImmediate(spriteRenderer);
SpriteMeshUtils.CreateSpriteMeshInstance(spriteMesh,spriteRendererGO,true);
Selection.activeGameObject = spriteRendererGO;
}else{
Debug.Log("Select a SpriteRenderer with a Sprite to convert to SpriteMesh");
}
}
示例13: CopyAtlas
static void CopyAtlas(MenuCommand command)
{
Material mat = command.context as Material;
m_copiedAtlasProperties = new Material(mat);
m_copiedAtlasProperties.hideFlags = HideFlags.DontSave;
}
示例14: DoFind
private static void DoFind(MenuCommand data)
{
var script = Selection.activeObject as MonoScript;
if (script == null) return;
var klass = script.GetClass();
if (typeof(Component).IsAssignableFrom(klass))
{
if (_window == null)
{
_window = EditorWindow.GetWindow<ComponentSearchWindow>();
_window._mode = 0;
_window._targetScript = script;
_window._forceRefresh = true;
_window.Show();
_window.position = new Rect(20, 80, 500, 300);
}
else
{
_window._mode = 0;
_window._targetScript = script;
_window._forceRefresh = true;
_window.Focus();
}
}
}
示例15: CreatePulse
public static void CreatePulse(MenuCommand menuCommand)
{
var pulse = new GameObject("Pulse", typeof(Pulse));
GameObjectUtility.SetParentAndAlign(pulse, menuCommand.context as GameObject);
Undo.RegisterCreatedObjectUndo(pulse, "Create " + pulse.name);
Selection.activeGameObject = pulse;
}