1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- using UnityEngine;
- using System.Collections;
- using UnityEditor;
- using UnityEngine.UI;
- namespace UnityEditor.UI {
-
-
-
-
- public class ProceduralImageEditorUtility {
- [MenuItem("GameObject/UI/Procedural Image")]
- public static void AddProceduralImage(){
- GameObject o = new GameObject ();
- o.AddComponent<ProceduralImage> ();
- o.name = "Procedural Image";
- if (Selection.activeGameObject != null && Selection.activeGameObject.GetComponentInParent<Canvas> () != null) {
- o.transform.SetParent (Selection.activeGameObject.transform, false);
- Selection.activeGameObject = o;
- }
-
- else {
- if(GameObject.FindObjectOfType<Canvas>()==null) {
- EditorApplication.ExecuteMenuItem("GameObject/UI/Canvas");
- }
- Canvas c = GameObject.FindObjectOfType<Canvas>();
- o.transform.SetParent (c.transform, false);
- Selection.activeGameObject = o;
- }
- }
-
-
-
- [MenuItem("CONTEXT/Image/Replace with Procedural Image")]
- public static void ReplaceWithProceduralImage(MenuCommand command){
- Image image = (Image)command.context;
- GameObject obj = image.gameObject;
- GameObject.DestroyImmediate (image);
- obj.AddComponent<ProceduralImage> ();
- }
- }
- }
|