Exemplo n.º 1
0
 public static void BackupTransform(MenuCommand command)
 {
     if (command.context is Component) {
         var component = (Component)command.context;
         fiBackupManager.CreateBackup(component);
     }
 }
        static void PasteComponentAsNew( MenuCommand command )
        {
            TileComponent component = command.context as TileComponent;
            Tile tile = component.tile;

            TileComponentUtility.PasteComponentAsNew( tile );
        }
Exemplo n.º 3
0
 public static void BackupBaseBehavior(MenuCommand command)
 {
     if (command.context is Component) {
         var component = (Component)command.context;
         fiBackupManager.CreateBackup(component);
     }
 }
Exemplo n.º 4
0
		static void CreateGameObjectAsChild (MenuCommand command)
		{
			Transform tr = (Transform)command.context;
			GameObject go = new GameObject ("Locator_");
			go.transform.parent = tr;
			go.transform.localPosition = Vector3.zero;
		}
Exemplo n.º 5
0
        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;
 }
Exemplo n.º 8
0
        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);
        }
 private static bool GetLatestTest(MenuCommand cmd)
 {
   AssetList listFromSelection = Provider.GetAssetListFromSelection();
   if (Provider.enabled)
     return Provider.GetLatestIsValid(listFromSelection);
   return false;
 }
Exemplo n.º 10
0
        public static void CreateGameObjectContext(MenuCommand menuCommand)
        {
            var root = new GameObject("GameObjectContext").AddComponent<GameObjectContext>();
            Selection.activeGameObject = root.gameObject;

            EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
        }
Exemplo n.º 11
0
		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;
		}
Exemplo n.º 12
0
		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");
			}
		}
Exemplo n.º 13
0
        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 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;
 }
 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;
 }
Exemplo n.º 17
0
 static void initializeARScene(MenuCommand cmd)
 {
     GameObject go = new GameObject("ARScene");
     go.AddComponent<ARSceneBehaviour>();
     go.transform.position = Vector3.zero;
     go.transform.rotation = Quaternion.identity;
 }
 internal static bool RemoveDetailCheck(MenuCommand item)
 {
   Terrain context = (Terrain) item.context;
   if (item.userData >= 0)
     return item.userData < context.terrainData.detailPrototypes.Length;
   return false;
 }
Exemplo n.º 19
0
        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);
        }
 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);
 }
 internal static bool EditSplatCheck(MenuCommand item)
 {
   Terrain context = (Terrain) item.context;
   if (item.userData >= 0)
     return item.userData < context.terrainData.splatPrototypes.Length;
   return false;
 }
Exemplo n.º 22
0
 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;
 }
        static void CopyTransformGlobal_Transform(MenuCommand cmnd)
        {
            var tr = cmnd.context as Transform;
            if (tr == null) return;

            _currentTrans = Trans.GetGlobal(tr);
            _local = false;
        }
Exemplo n.º 24
0
 private static void UpdateComponents(MenuCommand aCommand)
 {
     UILabel label = aCommand.context as UILabel;
     if (label != null)
     {
         label.UpdateComponents();
     }
 }
 private static void ExpandAll(MenuCommand cmd)
 {
     var component = cmd.context as Component;
     if (component)
     {
         FoldAllOnGameObject(component.gameObject, true);
     }
 }
 private static void CollapseAll(MenuCommand cmd)
 {
     var component = cmd.context as Component;
     if (component)
     {
         FoldAllOnGameObject(component.gameObject, false);
     }
 }
Exemplo n.º 27
0
 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;
 }
Exemplo n.º 28
0
        public static void BackupBaseBehavior(MenuCommand command)
        {
            var unityObject = command.context;

            if (unityObject != null) {
                fiPersistentMetadata.Reset(unityObject);
            }
        }
Exemplo n.º 29
0
        public static void BackupBaseBehavior(MenuCommand command)
        {
            var unityObject = command.context;

            if (unityObject != null) {
                fiPersistentMetadata.Reset(new fiUnityObjectReference(unityObject, /*tryRestore:*/false));
            }
        }
 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);
 }