示例#1
0
        public override void OnInspectorGUI()
        {
            var dummyMono = target as UIDummy;

            if (dummyMono == null)
            {
                return;
            }

            if (PrefabUtil.IsPrefab(dummyMono.gameObject))
            {
                EditorGUILayout.LabelField("请前往Prefab实例内编辑锚点");
                return;
            }

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("锚点列表");
            if (GUILayout.Button("添加"))
            {
                dummyMono.Dummys.Add(new DummyDefine());
            }

            EditorGUILayout.EndHorizontal();

            var pos = new Vector2(0, 20);

            EditorGUILayout.BeginScrollView(pos);
            {
                var dummyArr = new List <DummyDefine>(dummyMono.Dummys.ToArray());
                var index    = 1;
                foreach (var define in dummyArr)
                {
                    define.Offset    = EditorGUILayout.Vector2Field("偏移", define.Offset);
                    define.Type      = (DummyType)EditorGUILayout.EnumPopup("类型", define.Type);
                    define.AliasName = EditorGUILayout.TextField("别名", define.AliasName);
                    if (GUILayout.Button("删除"))
                    {
                        dummyArr.Remove(define);
                    }

                    EditorGUILayout.Separator();
                    index++;
                }
                dummyMono.Dummys = dummyArr;
            }
            EditorGUILayout.EndScrollView();
        }
示例#2
0
        private void Unpack(object arg)
        {
            var gameObj   = (GameObject)arg;
            var currTrans = gameObj.transform;
            var toTrans   = gameObj.transform.parent;

            if (PrefabUtil.IsPrefab(gameObj))
            {
                PrefabUtility.UnpackPrefabInstance(gameObj, PrefabUnpackMode.OutermostRoot, InteractionMode.AutomatedAction);
            }

            var childrenTransform = gameObj.transform.GetComponentsInChildren <Transform>(true);

            foreach (var trans in childrenTransform)
            {
                if (trans.parent != currTrans || trans == currTrans)
                {
                    continue;
                }
                trans.SetParent(toTrans, true);
            }

            GameObject.DestroyImmediate(gameObj);
        }