private static void CleanUpSelection()
        {
            string _path = Application.dataPath;

            string[] _files = Directory.GetFiles(Application.dataPath, "*.prefab", SearchOption.AllDirectories);

            List <GameObject> _objs = new List <GameObject>();

            for (int i = 0; i < _files.Length; i++)
            {
                string _one = "Assets" + Utility.MakeUnifiedDirectory(_files[i]).Replace(Application.dataPath, string.Empty);
                _objs.Add(AssetDatabase.LoadAssetAtPath <GameObject>(_one));
            }

            for (int i = 0; i < _objs.Count; ++i)
            {
                EditorUtility.DisplayProgressBar("Checking", _objs[i].name, (float)i / (float)_objs.Count);
                GameObject   _gameObject = _objs[i] as GameObject;
                GameObject[] _gs         = UtilityUnity.GetAllChild(_gameObject);
                for (int j = 0; j < _gs.Length; j++)
                {
                    CleanUpAsset(_gs[j]);
                }
                AssetDatabase.SaveAssets();
            }
            EditorUtility.ClearProgressBar();
            AssetDatabase.Refresh();
        }
예제 #2
0
 private void Awake()
 {
     if (string.IsNullOrEmpty(eventKeyName))
     {
         eventKeyName = name;
     }
     tempFather = UtilityUnity.FindParentByName(gameObject, "UI");
 }
예제 #3
0
        public void Init()
        {
            autoListener = new GameObject("GameFramework.MusicModule");
            Object.DontDestroyOnLoad(autoListener);
            autoListener.AddComponent <AudioListener>();

            audios = new List <AudioSource>();

            GameObject _bgm = new GameObject("bgm");

            UtilityUnity.SetParent(_bgm, autoListener);
            bgm      = _bgm.AddComponent <AudioSource>();
            bgm.loop = true;

            Refresh();
        }
        //新添加的一律放顶层
        internal void AddChild(GameObject _obj)
        {
            IAutoAnimation _autoAnimation;

            //页面层级以下会自动关闭上一次的显示
            if (lastShow && layer <= (int)UILayers.Page)
            {
                _autoAnimation = lastShow.GetComponent <IAutoAnimation>();
                if (_autoAnimation == null)
                {
                    lastShow.SetActive(false);
                }
                else
                {
                    _autoAnimation.Play(null);
                }
            }

            _obj.transform.SetParent(rectTransform);
            _obj.transform.localPosition = Vector3.zero;
            _obj.transform.localScale    = Vector3.one;
            _obj.transform.SetAsLastSibling();
            //适配
            IAdaptation[] _adaptation = UtilityUnity.GetAllComponents <IAdaptation>(_obj);
            if (_adaptation != null)
            {
                for (int i = 0; i < _adaptation.Length; i++)
                {
                    _adaptation[i].scaleType = 0;
                    _adaptation[i].Refresh(UGUILayerSolution.canvasScaler.referenceResolution.x, UGUILayerSolution.canvasScaler.referenceResolution.y);
                }
            }
            //动画
            _autoAnimation = _obj.GetComponent <IAutoAnimation>();
            if (_autoAnimation == null)
            {
                _obj.SetActive(true);
                Refresh();
            }
            else
            {
                _autoAnimation.Play(Refresh);
            }
            lastShow = _obj;
        }
        public void Refresh()
        {
            GameObject[] _gs     = UtilityUnity.GetAllChild(this.gameObject);
            Renderer     _render = null;

            for (int i = 0; i < _gs.Length; i++)
            {
                _render = _gs[i].GetComponent <Renderer>();
                if (_render)
                {
                    if (relyon != UILayers.Base)
                    {
                        _render.sortingOrder = (int)relyon + order;
                    }
                    else
                    {
                        _render.sortingOrder = order;
                    }
                }
            }
        }
예제 #6
0
        public void PlayAudio(AudioClip _audio)
        {
            AudioSource _as  = null;
            GameObject  _new = PoolModule.instance.Pop <GameObject>("AUDIO_PLAYER");

            if (_new == null)
            {
                _new = new GameObject(_audio.name);
                _as  = _new.AddComponent <AudioSource>();
            }
            else
            {
                _new.SetActive(true);
                _as = _new.GetComponent <AudioSource>();
            }
            UtilityUnity.SetParent(_new, autoListener);
            _as.clip = _audio;
            _as.mute = !PersistenceData.GetPrefsDataBool(CommonKey.SWITCH_AUDIO, true);
            _as.Play();
            Refresh();
            audios.Add(_as);
        }
예제 #7
0
 public void OnEndDrag(PointerEventData eventData)
 {
     UtilityUnity.SetParent(gameObject, lastFather);
     MessageModule.instance.Recevive(eventKeyName, MessageType.EventEndDrag, gameObject);
 }
예제 #8
0
 public void OnBeginDrag(PointerEventData eventData)
 {
     MessageModule.instance.Recevive(eventKeyName, MessageType.EventBeginDrag, gameObject);
     lastFather = parent.gameObject;
     UtilityUnity.SetParent(gameObject, tempFather);
 }
예제 #9
0
 public void Destroy()
 {
     UtilityUnity.DestroyGameObject(autoListener);
 }