예제 #1
0
        public static GameObject Instantiate(GameObject prefabGo, Transform parent = null,
                                             TransformUtil.StayOption stayOption   = TransformUtil.StayOption.Local)
        {
            if (prefabGo == null)
            {
                return(null);
            }

            switch (stayOption)
            {
            case TransformUtil.StayOption.Local:
                return(Object.Instantiate(prefabGo, parent, false));

            case TransformUtil.StayOption.World:
                return(Object.Instantiate(prefabGo, parent, true));

            default:             // Reset
                var go = Object.Instantiate(prefabGo, parent, false);
                TransformUtil.Reset(go.transform);
                return(go);
            }
        }
예제 #2
0
        public static T Instantiate <T> (T prefabCom, Transform parent = null, TransformUtil.StayOption stayOption = TransformUtil.StayOption.Local)
            where T : Component
        {
            if (prefabCom == null)
            {
                return(null);
            }

            switch (stayOption)
            {
            case TransformUtil.StayOption.Local:
                return(Object.Instantiate(prefabCom, parent, false));

            case TransformUtil.StayOption.World:
                return(Object.Instantiate(prefabCom, parent, true));

            default:             // Reset
                var com = Object.Instantiate(prefabCom, parent, false);
                TransformUtil.Reset(com.transform);
                return(com);
            }
        }