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; }
private static void AnchorFitPoint(UnityEditor.MenuCommand menuCommand, bool undo = true) { RectTransform r = menuCommand.context as RectTransform; if (r != null && r.parent != null) { if (undo) { UnityEditor.Undo.RecordObject(r, "AnchorFitPoint"); } RectTransform parentRt = r.parent.GetComponent <RectTransform>(); Vector2 newAnchorMin, newAnchorMax; Vector3 position = r.position; Vector2 sizeDelta = new Vector2(r.rect.width, r.rect.height); r.anchorMin = Vector2.zero; r.anchorMax = Vector2.zero; r.position = position; { //Debug.Log(r.anchoredPosition); //Debug.Log(parentRt.anchoredPosition); newAnchorMin.x = r.anchoredPosition.x / parentRt.rect.width; newAnchorMax.x = newAnchorMin.x; newAnchorMin.y = r.anchoredPosition.y / parentRt.rect.height; newAnchorMax.y = newAnchorMin.y; } r.anchorMin = newAnchorMin; r.anchorMax = newAnchorMax; r.sizeDelta = sizeDelta; r.position = position; } }
public static void PastePosition(UnityEditor.MenuCommand command) { Transform transform = (command.context as Transform); Undo.RecordObject(transform, "Paste position"); (command.context as Transform).position = position; }
internal static bool EditSplatCheck(MenuCommand item) { Terrain context = (Terrain) item.context; if (item.userData >= 0) return item.userData < context.terrainData.splatPrototypes.Length; return false; }
internal static bool RemoveDetailCheck(MenuCommand item) { Terrain context = (Terrain) item.context; if (item.userData >= 0) return item.userData < context.terrainData.detailPrototypes.Length; return false; }
public static void PasteRotation(UnityEditor.MenuCommand command) { Transform transform = (command.context as Transform); Undo.RecordObject(transform, "Paste rotation"); transform.rotation = rotation; }
static void PasteComponentAsNew( MenuCommand command ) { TileComponent component = command.context as TileComponent; Tile tile = component.tile; TileComponentUtility.PasteComponentAsNew( tile ); }
static void CreateGameObjectAsChild (MenuCommand command) { Transform tr = (Transform)command.context; GameObject go = new GameObject ("Locator_"); go.transform.parent = tr; go.transform.localPosition = Vector3.zero; }
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); }
private static bool SubmitTest(MenuCommand cmd) { AssetList listFromSelection = Provider.GetAssetListFromSelection(); if (Provider.enabled) return Provider.SubmitIsValid((ChangeSet) null, listFromSelection); return false; }
private static bool CheckOutBothTest(MenuCommand cmd) { AssetList listFromSelection = Provider.GetAssetListFromSelection(); if (Provider.enabled) return Provider.CheckoutIsValid(listFromSelection, CheckoutMode.Both); return false; }
private static void Create(UnityEditor.MenuCommand command) { GameObject widget = new GameObject("Text Widget"); widget.AddComponent <TextWidget>(); widget.CreateFromEditor(command); }
private static bool GetLatestTest(MenuCommand cmd) { AssetList listFromSelection = Provider.GetAssetListFromSelection(); if (Provider.enabled) return Provider.GetLatestIsValid(listFromSelection); return false; }
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); }
public static void CreateGameObjectContext(MenuCommand menuCommand) { var root = new GameObject("GameObjectContext").AddComponent<GameObjectContext>(); Selection.activeGameObject = root.gameObject; EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); }
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; }
internal static void EditDetail(MenuCommand item) { if (((Terrain) item.context).terrainData.detailPrototypes[item.userData].usePrototypeMesh) TerrainWizard.DisplayTerrainWizard<DetailMeshWizard>("Edit Detail Mesh", "Apply").InitializeDefaults((Terrain) item.context, item.userData); else TerrainWizard.DisplayTerrainWizard<DetailTextureWizard>("Edit Grass Texture", "Apply").InitializeDefaults((Terrain) item.context, item.userData); }
public static void CreatePattern(MenuCommand menuCommand) { var pattern = new GameObject("Pattern", typeof(Pattern)); GameObjectUtility.SetParentAndAlign(pattern, menuCommand.context as GameObject); Undo.RegisterCreatedObjectUndo(pattern, "Create " + pattern.name); Selection.activeGameObject = pattern; }
static void initializeARScene(MenuCommand cmd) { GameObject go = new GameObject("ARScene"); go.AddComponent<ARSceneBehaviour>(); go.transform.position = Vector3.zero; go.transform.rotation = Quaternion.identity; }
private static void AnchorFit(UnityEditor.MenuCommand menuCommand) { RectTransform r = menuCommand.context as RectTransform; if (r != null && r.parent != null) { UnityEditor.Undo.RecordObject(r, "AnchorFit"); AnchorFitPoint(menuCommand, false); RectTransform parentRt = r.parent.GetComponent <RectTransform>(); Vector2 newAnchorMin, newAnchorMax; Vector3 position = r.position; r.anchorMin = Vector2.zero; r.anchorMax = Vector2.zero; r.position = position; { //Debug.Log(r.anchoredPosition); //Debug.Log(parentRt.anchoredPosition); //Debug.Log(r.anchoredPosition.x / parentRt.rect.width); //Debug.Log(r.anchoredPosition.y / parentRt.rect.height); // FINALLY FIXED PIVOT PROBLEM ! :D newAnchorMin.x = (r.anchoredPosition.x - (r.rect.width * r.pivot.x)) / parentRt.rect.width; newAnchorMax.x = (r.anchoredPosition.x + (r.rect.width * (1f - r.pivot.x))) / parentRt.rect.width; newAnchorMin.y = (r.anchoredPosition.y - (r.rect.height * r.pivot.y)) / parentRt.rect.height; newAnchorMax.y = (r.anchoredPosition.y + (r.rect.height * (1f - r.pivot.y))) / parentRt.rect.height; } r.anchorMin = newAnchorMin; r.anchorMax = newAnchorMax; r.sizeDelta = Vector2.zero; r.position = position; } }
public static void PasteScale(UnityEditor.MenuCommand command) { Transform transform = (command.context as Transform); Undo.RecordObject(transform, "Paste scale"); transform.localScale = localScale; }
static void CopyAtlas(MenuCommand command) { Material mat = command.context as Material; m_copiedAtlasProperties = new Material(mat); m_copiedAtlasProperties.hideFlags = HideFlags.DontSave; }
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(); } } }
public static void BackupTransform(MenuCommand command) { if (command.context is Component) { var component = (Component)command.context; fiBackupManager.CreateBackup(component); } }
public static void AddInputField(MenuCommand menuCommand) { GameObject inputFieldGO = DefaultControls.CreateInputField(GetStandardResources()); InputField inputField = inputFieldGO.GetComponent<InputField>(); var textChild = inputFieldGO.transform.FindChild("Text").gameObject; var text = textChild.GetComponent<Text>(); Object.DestroyImmediate(text); UnivText unvText = textChild.AddComponent<UnivText>(); unvText.text = ""; unvText.color = Color.black; unvText.supportRichText = false; inputField.textComponent = unvText; var placeholderChild = inputFieldGO.transform.FindChild("Placeholder").gameObject; var placeholderText = placeholderChild.GetComponent<Text>(); Object.DestroyImmediate(placeholderText); UnivText placeholderUnvText = placeholderChild.AddComponent<UnivText>(); placeholderUnvText.text = "הכנס טקסט..."; placeholderUnvText.fontStyle = FontStyle.Italic; // Make placeholder color half as opaque as normal text color. Color placeholderColor = unvText.color; placeholderColor.a *= 0.5f; placeholderUnvText.color = placeholderColor; inputField.placeholder = placeholderUnvText; PlaceUIElementRoot(inputFieldGO, menuCommand); }
private static void UpdateNames(UnityEditor.MenuCommand command) { MainUI context = (MainUI)command.context; List <string> scenes = new List <string>(); foreach (UnityEditor.EditorBuildSettingsScene scene in UnityEditor.EditorBuildSettings.scenes) { if (scene == null || !scene.enabled) { continue; } string name = Path.GetFileNameWithoutExtension(scene.path); if (name == MAIN_SCENE) { continue; } scenes.Add(name); } scenes.Sort(); context.m_Scenes = new MenuScene[scenes.Count]; for (int i = 0; i < scenes.Count; i++) { context.m_Scenes[i] = new MenuScene(); context.m_Scenes[i].m_SceneName = scenes[i]; context.m_Scenes[i].m_SceneDesc = scenes[i]; } }
public static void BackupBaseBehavior(MenuCommand command) { if (command.context is Component) { var component = (Component)command.context; fiBackupManager.CreateBackup(component); } }
private static void UpdateSceneTable(UnityEditor.MenuCommand command) { GameEngine context = (GameEngine)command.context; List <string> scenes = new List <string>(); string path; foreach (UnityEditor.EditorBuildSettingsScene s in UnityEditor.EditorBuildSettings.scenes) { if (s.enabled) { int sep = s.path.IndexOf("Assets/Resources/"); if (sep == 0) { path = s.path.Substring(17, s.path.IndexOf('/', 17) - 17) + ":"; } else { path = ""; } sep = s.path.LastIndexOf('/'); scenes.Add(path + s.path.Substring(sep + 1, s.path.LastIndexOf('.') - sep - 1)); } } context.sceneTable = scenes.ToArray(); }
public static void BuildScenes(UnityEditor.MenuCommand command) { var scenes = EditorBuildSettings.scenes; for (int i = 0; i < scenes.Length; i++) { EditorBuildSettingsScene[] scene = new EditorBuildSettingsScene[] { scenes[i] }; if (!scene[0].enabled) { continue; } var buildDir = Path.GetFullPath("Builds"); if (!Directory.Exists(buildDir)) { Directory.CreateDirectory(buildDir); } var buildPath = Path.Combine(buildDir, Application.productName); if (!Directory.Exists(buildPath)) { Directory.CreateDirectory(buildPath); } var sceneName = Path.GetFileNameWithoutExtension(scenes[i].path); Debug.Log(sceneName); BuildPipeline.BuildPlayer(scene, Path.Combine(buildPath, sceneName), BuildTarget.WebGL, BuildOptions.Development); } }
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"); } }
private static void UpdateNames(UnityEditor.MenuCommand command) { SceneLoader context = (SceneLoader)command.context; context.PopulateExclusions(); context.scenes = ReadNames(context.excludeList); context.SaveNameFile(); }
public static void ConvertToPersian(UnityEditor.MenuCommand command) { UnityEngine.UI.Text uit = command.context as UnityEngine.UI.Text; if (uit != null) { uit.text = Commands.ConvertToPersian(uit.text); } }
public static void BackupBaseBehavior(MenuCommand command) { var unityObject = command.context; if (unityObject != null) { fiPersistentMetadata.Reset(new fiUnityObjectReference(unityObject, /*tryRestore:*/false)); } }
private static void MenuCommand(MenuCommand menuCommand) { var go = new GameObject("Editor Camera"); GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); go.AddComponent<EditorCamera>(); Undo.RegisterCreatedObjectUndo(go, "Create " + go.name); Selection.activeObject = go; }
private static void UpdateNames(UnityEditor.MenuCommand command) { ReadSceneNames context = (ReadSceneNames)command.context; var allSceneNames = ReadNames(); var testSceneNames = allSceneNames.GetRange(1, allSceneNames.Count - 1); context.testSceneNames = testSceneNames; }
static void CopyTransformGlobal_Transform(MenuCommand cmnd) { var tr = cmnd.context as Transform; if (tr == null) return; _currentTrans = Trans.GetGlobal(tr); _local = false; }
private static void UpdateComponents(MenuCommand aCommand) { UILabel label = aCommand.context as UILabel; if (label != null) { label.UpdateComponents(); } }
private static void CollapseAll(MenuCommand cmd) { var component = cmd.context as Component; if (component) { FoldAllOnGameObject(component.gameObject, false); } }
private static void ExpandAll(MenuCommand cmd) { var component = cmd.context as Component; if (component) { FoldAllOnGameObject(component.gameObject, true); } }
public static void AddPanel(MenuCommand menuCommand) { GameObject element = DefaultControls.CreatePanel(GetStandardResources()); PlaceUIElementRoot(element, menuCommand); RectTransform component = element.GetComponent<RectTransform>(); component.anchoredPosition = Vector2.zero; component.sizeDelta = Vector2.zero; }
public static void BackupBaseBehavior(MenuCommand command) { var unityObject = command.context; if (unityObject != null) { fiPersistentMetadata.Reset(unityObject); } }
public static void BringToGround(UnityEditor.MenuCommand command) { Transform transform = command.context as Transform; if (transform != null) { Commands.BringToGround(transform); } }
static void ClearCachePools(UnityEditor.MenuCommand cmd) { if (Application.isPlaying) { return; } UICachePoolManager.ClearCachePool(); }
static void SpaceOut(UnityEditor.MenuCommand menuCommand) { var tra = UnityEditor.Selection.transforms; for (int i = 0; i < tra.Length; i++) { tra[i].position = Vector3.right * i * 20f; } }
static void RemoveCacheUIItems(UnityEditor.MenuCommand cmd) { //2017/11/27注释掉 // if (Application.isPlaying && Editor_ApplicationPause.IsUICacheEnableWhenPlaying == false) return; UICacheItemMark current = cmd.context as UICacheItemMark; if (current != null) { current.UnLoadItem(); } }
public static void CenterPivot(UnityEditor.MenuCommand command) { BoxCollider collider = command.context as BoxCollider; if (collider != null) { Commands.CenterPivot(collider); } }
/// <summary> /// 保存当前视图 /// </summary> private static void SaveCurrentView(UnityEditor.MenuCommand cmd) { UITextLocalization current = cmd.context as UITextLocalization; if (current != null) { current.SaveView(current.currentLanguageType); } }
private static void CopyAllEffectToSnapshots(MenuCommand command) { AudioMixerGroupController context = command.context as AudioMixerGroupController; AudioMixerController controller = context.controller; if ((Object) controller == (Object) null) return; Undo.RecordObject((Object) controller, "Copy all effect settings to all snapshots"); controller.CopyAllSettingsToAllSnapshots(context, controller.TargetSnapshot); }
public static void CreateTrait(UnityEditor.MenuCommand menuCommand) { string name = "SceneParameter (0)"; GameObject instance = new GameObject(name); GameObjectUtility.SetParentAndAlign(instance, menuCommand.context as GameObject); Undo.RegisterCreatedObjectUndo(instance, "Create " + instance.name); Selection.activeObject = instance; instance.AddComponent <SceneParameter>(); }
static void ShowCacheUIItems(UnityEditor.MenuCommand cmd) { //2017/11/27注释掉 // if (Application.isPlaying&&Editor_ApplicationPause.IsUICacheEnableWhenPlaying==false) return; UICacheItemMark current = cmd.context as UICacheItemMark; if (current != null) { current.LoadCacheUIItem(current.m_AdditionalOperate, current.m_AdditialParameter); } }
static void DoReset(UnityEditor.MenuCommand command) { ((BaseAction)command.context).CleanSupportedTriggers(); GameObject g = new GameObject("temp"); BaseAction b = (BaseAction)g.AddComponent(command.context.GetType()); UnityEditor.EditorUtility.CopySerialized(b, command.context); DestroyImmediate(g); ((BaseAction)command.context).Reset(); }
private static void CreateColorPicker(UnityEditor.MenuCommand menuCommand) { GameObject go = new GameObject("Color Picker"); go.AddComponent <ColorPicker>(); UnityEditor.GameObjectUtility.SetParentAndAlign(go, menuCommand.context as GameObject); UnityEditor.Undo.RegisterCreatedObjectUndo(go, "Create " + go.name); UnityEditor.Selection.activeObject = go; }
private static void MakeDestructible(UnityEditor.MenuCommand mc) { if (mc != null && mc.context != null) { var spriteRenderer = mc.context as SpriteRenderer; if (spriteRenderer != null) { D2D_Helper.GetOrAddComponent<D2D_DestructibleSprite>(spriteRenderer.gameObject); } } }
private static void SaveCurrentView(UnityEditor.MenuCommand cmd) { LocalizationBase current = cmd.context as LocalizationBase; if (current == null) { return; } current.SaveView(current.currentLanguageType); EditorUtility.DisplayDialog("", "保存当前语言下的配置完成!", "OK"); }
private static void RemoveConfigKey(UnityEditor.MenuCommand cmd) { UITextLocalization current = cmd.context as UITextLocalization; if (current == null) { return; } current.RemoveConfigKey(); Debug.Log("移除配置表关键字完成!"); }
private static void RemoveTextLocalization(UnityEditor.MenuCommand cmd) { UITextLocalizationManager current = cmd.context as UITextLocalizationManager; if (current == null) { return; } current.RemoveTextLocalization(); EditorUtility.DisplayDialog("移除Text本地化组件", "移除Text本地化组件完成!", "OK"); }
private static void GetAllLocalizations(UnityEditor.MenuCommand cmd) { LocalizationManager current = cmd.context as LocalizationManager; if (current == null) { Debug.LogError("统计失败!"); return; } current.GetAllLocalizations(); EditorUtility.DisplayDialog("", "统计所有本地化组件完成!", "OK"); }
private static void GenTextLocalization(UnityEditor.MenuCommand cmd) { UITextLocalization current = cmd.context as UITextLocalization; if (current == null) { return; } current.GenTextLocalization(); AssetDatabase.Refresh(); Debug.Log("生成配置表关键字完成!"); }
private static void GetAllUITextLocalizations(UnityEditor.MenuCommand cmd) { UITextLocalizationManager current = cmd.context as UITextLocalizationManager; if (current == null) { Debug.LogError("统计失败!"); return; } current.GetAllUITextLocalizations(); Debug.Log("统计所有的Text本地化组件完成!"); }
static void UpdateMarkTransTag(UnityEditor.MenuCommand cmd) { if (Application.isPlaying) { return; } UICacheView current = cmd.context as UICacheView; if (current != null) { current.UpdateUIMarkTransTagState(); } }