예제 #1
0
        public static void CreateImageGroup()
        {
            // split path name and file name
            var path = EditorUtils.GetSelectedDirectory();

            CreateImageGroup(path, EditorUtils.GetSelectedSpritePaths());
        }
예제 #2
0
        public static void CreateUncroppedStanding()
        {
            const string assetName = "UncroppedStanding";
            var          parent    = new GameObject(assetName);

            ResetTransform(parent.transform);
            parent.AddComponent <UncroppedStanding>();

            foreach (var spritePath in EditorUtils.GetSelectedSpritePaths())
            {
                var go = new GameObject("StandingComponent");
                go.transform.SetParent(parent.transform);
                ResetTransform(go.transform);
                var sprite         = AssetDatabase.LoadAssetAtPath <Sprite>(spritePath);
                var spriteRenderer = go.AddComponent <SpriteRenderer>();
                spriteRenderer.sprite = sprite;
                var texture = sprite.texture;
                var cropper = go.AddComponent <SpriteCropper>();
                cropper.boundRect = new RectInt(0, 0, texture.width, texture.height);
                cropper.cropRect  = new RectInt(0, 0, texture.width, texture.height);
            }

            var currentDir = EditorUtils.GetSelectedDirectory();

            PrefabUtility.SaveAsPrefabAsset(parent,
                                            Path.Combine(currentDir, AssetDatabase.GenerateUniqueAssetPath(assetName + ".prefab")));
            DestroyImmediate(parent);
        }