블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2795)
Unity3D (852)
Programming (478)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (61)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday

[ErrorMessage] Unexpected character encountered while parsing value: . Path '', line 0, position 0.

 

[Solved] In my case, the file containing JSON string had BOM. Once I removed BOM the problem was solved.

 

[추가] 로드 할 파일 인코딩 타입을 확인해보자.

 

[출처] https://stackoverflow.com/questions/23259173/unexpected-character-encountered-while-parsing-value

 

Unexpected character encountered while parsing value

Currently, I have some issues. I'm using C# with Json.NET. The issue is that I always get: {"Unexpected character encountered while parsing value: e. Path '', line 0, position 0."} So t...

stackoverflow.com

 

반응형
Posted by blueasa
, |

출처 : https://qiita.com/kuuki_yomenaio/items/00d74762e930d037ad27

Spine 오브젝트는?

Spine 개체는 Unity에서 말하는 MeshRenderer로 렌더링되고 있습니다. 
(spine-unity의 SkeletonRenderer.cs가 해당 소스입니다) 
즉, MeshRenderer의 Mask 처리를 만들 수 있다면, Mask를 사용할 수 있게 됩니다. 


(왜 이런 엄한 부분을 가지고 예제를 만든 걸까...)

Mask 처리에 대해

요는 Renderer를 Mask하면 되는 것이지만, 
SpriteRenderer 자체를 Mask하는 처리는 Unity에는 없는 것 같습니다. 
그래서, 간단히 자작하기로 했습니다.

Shader로 실제 제작

간단한 것은 역시 스텐실 테스트를 사용하는 것이군요. 
아주 간단하게 설명하면, 스텐실이란 모양을 도려낸다는 의미로 
픽셀 렌더링을 할 때 이 점을 찍는가 찍지 않는다인지를 판정하는 테스트입니다. 
이것을 이용합니다.

Spine 쪽에 적용하는 shader

SpineShader.shader
Shader "Custom/SpineShader"{
Properties
{
        _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader
{
        Tags {"Queue"="Transparent+2" "IgnoreProjector"="True" "RenderType"="Transparent"}
        ZWrite Off
        Blend SrcAlpha OneMinusSrcAlpha

        Stencil {
                                Ref 1
                                Comp Equal
        }

        Pass
        {
                CGPROGRAM
                        #pragma vertex vert
                        #pragma fragment frag

                        #include "UnityCG.cginc"

                        struct appdata_t
                        {
                                float4 vertex : POSITION;
                                float2 texcoord : TEXCOORD0;
                        };

                        struct v2f
                        {
                                float4 vertex : SV_POSITION;
                                half2 texcoord : TEXCOORD0;
                        };

                        sampler2D _MainTex;
                        float4 _MainTex_ST;

                        v2f vert (appdata_t v)
                        {
                                v2f o;
                                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                                o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                                return o;
                        }

                        fixed4 frag (v2f i) : COLOR
                        {
                                fixed4 col = tex2D(_MainTex, i.texcoord);
                                return col;
                        }
                ENDCG
        }
}

}

Mask할 Sprite에 설정하는 Shader

SpineSoriteMask.shader
Shader "Custom/SpineSpriteMask"{
Properties
{
        _MainTex ("Base (RGB)", 2D) = "white" {}
}

SubShader
{
        Tags {"Queue"="Transparent+1" "IgnoreProjector"="True"}
        ZWrite Off
        AlphaTest Greater 0.5
        ColorMask 0
        ZTest Always


        Stencil {
                                Ref 1
                                Comp always
                                Pass replace
                        }


        Pass
        {
                CGPROGRAM
                        #pragma vertex vert
                        #pragma fragment frag

                        #include "UnityCG.cginc"

                        struct appdata_t
                        {
                                float4 vertex : POSITION;
                                float2 texcoord : TEXCOORD0;
                        };

                        struct v2f
                        {
                                float4 vertex : SV_POSITION;
                                half2 texcoord : TEXCOORD0;
                        };

                        sampler2D _MainTex;
                        float4 _MainTex_ST;

                        v2f vert (appdata_t v)
                        {
                                v2f o;
                                o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
                                o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                                return o;
                        }

                        fixed4 frag (v2f i) : COLOR
                        {
                                fixed4 col = tex2D(_MainTex, i.texcoord);
                                if(col.a<0.1)discard;
                                return col;
                        }
                ENDCG
        }
}

}

해설

SpineShader.shader
   Stencil {
             Ref 1
             Comp Equal
   }
SpineSoriteMask.shader
   ColorMask 0
   Stencil {
             Ref 1
             Comp always
             Pass replace
   }

Stencil

해설에 대해서는 
edo_m18 씨의 [Unity] Unity의 Shader 스텐실 버퍼를 시도
를 참고하십시오.

먼저, SpineSpriteMask 입니다만, 
"참조 값 1의 것과 비교하고, 모두 OK로 해서,
참조 값을 버퍼에 기록하고, ColorMask 0 으로 묘화는 하지 않음" 
이 됩니다.

그리고 SpineShader. 
"참조 값은 1, 값의 일치를 체크" 
가 됩니다.

이 설정을 함으로써 
SpineShader 측의 묘화는  StencilTest 를 받게 되고, 
SpineSpriteMask 측에서 설정한 모양대로 도려내지도록 그려집니다.

Unity에서 사용할 때에는 Material화 시킬 필요가 있습니다만, 
그에 대해서는
github
여기를 참고하십시오.

---

* 스파인측 설정

 

* 마스크이미지측 설정

* 매터리얼 설정은 이렇게(특별히 이미지는 지정하지 않고 쉐이더만 넣음)



출처: https://devdata.tistory.com/166 [CH:Windship DevDATA Center]

 

[Unity] Spine 오브젝트를 Mask하기

출처 : https://qiita.com/kuuki_yomenaio/items/00d74762e930d037ad27 Spine 오브젝트는? Spine 개체는 Unity에서 말하는 MeshRenderer로 렌더링되고 있습니다. (spine-unity의 SkeletonRenderer.cs가 해당 소스..

devdata.tistory.com

[참조] https://rainyrizzle.github.io/kr/AdvancedManual/AD_SpriteMask.html

 

Sprite Mask 적용하기

유니티의 "스프라이트 마스크(Sprite Mask)"를 이용하면 다른 Sprite Renderer의 일부를 숨기면서 렌더링을 할 수 있습니다. - 스프라이트 마스크 (유니티 공식 메뉴얼) AnyPortrait에서 제작된 캐릭터들은 S

rainyrizzle.github.io

 

반응형

'Unity3D > Shader' 카테고리의 다른 글

[링크] Unity Toon Shader(with Outline)  (0) 2023.02.22
[링크] Unity-Chan Toon Shader 2.0 (UTS2)  (0) 2021.11.30
[펌] Celery - Toon/Cel shader  (0) 2021.03.30
[펌] Toon Shader  (0) 2021.03.30
[링크] Unity Cel Shading - 카툰렌더링  (0) 2021.03.30
Posted by blueasa
, |

[NGUI 2020.2.2 사용 중..]

 

NGUI에서 UI가 가릴 때 Game 내 일반 오브젝트에 영향을 안주게 막기 위해서

예전에는 UICamea.hoveredObject를 사용했는데, 이번에 사용해보니 값이 이상하다.

그래서 좀 찾아보니 UICamea.IsOverUI가 있다.

참조 링크의 내용에는 문제가 있는 것처럼 말하긴 하는데 빌드해서 봐도 별다른 문제점은 없어보여서 일단 쓰기로 함.

 

[참조] http://www.tasharen.com/forum/index.php?topic=13282.0

 

UICamea.hoveredObject, UICamera.fallThrough, IsOver UI Problem.

When 3D Object and NGUI Object located same position on viewPort, "if(UICamera.hoveredObject != null)" code only touched NGUI Object. This code is no problem NGUI 3.0.2 version, Editor and Mobile too. But, latest version "UICamera.hoveredObject" is pointed

www.tasharen.com

[다른방식] https://blueasa.tistory.com/2549

 

[펌] NGUI와 일반 오브젝트 구분 피킹법

NGUI 를 사용하면서 GUI에 가린 오브젝트들이 GUI와 같이 클릭되는 현상을 게임 제작하면 많이들 보게됩니다. 그럴때는 아래 소스에서 작동하는 녀석으로 쓰면됩니다. if (UICamera.Raycast (Input.mousePosit

blueasa.tistory.com

 

반응형
Posted by blueasa
, |

NGUI 를 사용하면서 GUI에 가린 오브젝트들이 GUI와 같이 클릭되는 현상을 게임 제작하면 많이들 보게됩니다. 그럴때는 아래 소스에서 작동하는 녀석으로 쓰면됩니다.

 

if (UICamera.Raycast (Input.mousePosition) == true) 
{

        // NGUI 오브젝트가 선택되었음
} else

{

       // 해당 일반 오브젝트 선택되었음

}

 

or

 

if(null == UICamera.hoveredObject)

{

    // 게임쪽 클릭 처리

}

 

본인은 2번째 소스로 쓰다가 최근에 들어서 모바일에서 작동이 잘 안하는 관계로 1번을 사용하고 있습니다.



출처: https://sjcy.tistory.com/entry/NGUI와-일반-오브젝트-구분-피킹법 [Charlotte's web]

 

NGUI와 일반 오브젝트 구분 피킹법

NGUI 를 사용하면서 GUI에 가린 오브젝트들이 GUI와 같이 클릭되는 현상을 게임 제작하면 많이들 보게됩니다. 그럴때는 아래 소스에서 작동하는 녀석으로 쓰면됩니다. if (UICamera.Raycast (Input.mousePosit

sjcy.tistory.com

 

반응형
Posted by blueasa
, |

짓궃다vs 짖궃다

작성자 서주혜 등록일 2016. 11. 23. 조회수 11,119

짓궃다와 짖궃다중 어느 표현이 맞는 표현 입니까?

비밀번호  삭제

[답변]'짓궂다'

답변자 온라인 가나다 답변일 2016. 11. 25.

안녕하십니까?

 

'장난스럽게 남을 괴롭고 귀찮게 하여 달갑지 아니하다'를 의미하는 말은 '짓궂다'로 표기하는 것이 올바릅니다. '짓궃다/짖궃다'는 모두 틀린 표기입니다.

----
<참고>
짓-궂다 [짇ː꾿따]
「형용사」
 장난스럽게 남을 괴롭고 귀찮게 하여 달갑지 아니하다.
¶ 짓궂은 웃음/짓궂은 장난/짓궂은 질문/짓궂은 아이/짓궂게 놀리다/왕은 짓궂게 빙글빙글 웃으며 젊은 왕비를 놀려 본다.≪박종화, 다정불심≫

 

 

[출처] https://www.korean.go.kr/front/onlineQna/onlineQnaView.do?mn_id=216&qna_seq=108834

 

국립국어원

축소 확대 온라인가나다 상세보기 짓궃다vs 짖궃다 작성자 서주혜 등록일 2016. 11. 23. 조회수 11,120 짓궃다와 짖궃다중 어느 표현이 맞는 표현 입니까? [답변]'짓궂다' 답변자 온라인 가나다 답변일

www.korean.go.kr

 

반응형
Posted by blueasa
, |

Here are two small tricks that can help if you’re making an isometric 2D game in Unity. Ok, so not actually isometric, but that’s the term we’re used to in videogames, so we’ll go with it. These are quite basic and if you’re working on such a game you’ve probably already tackled them your own way. This is our take on it, hopefully it’s useful to someone.

Sprite Ordering

Normally in a 2D game there is no concept of depth, so if you simply place the sprites in the world, you’ll most likely have objects appearing in the wrong order than what you’d expect in an isometric game.

 

Thankfully Unity exposes Sorting Layer and Order In Layer properties for Renderers.
A quick fix is to set the value of Order in Layer to depend on the Y position of the object.

 

[ExecuteInEditMode]
[RequireComponent(typeof(Renderer))]
public class DepthSortByY : MonoBehaviour
{

    private const int IsometricRangePerYUnit = 100;

    void Update()
    {
        Renderer renderer = GetComponent();
        renderer.sortingOrder = -(int)(transform.position.y * IsometricRangePerYUnit);
    }
}

This solves the problem for the simplest case, when we assume all objects rest on the ground.

 

Let’s assume we want to have an object that is above the ground in the world, like placing a bird house on that tree. Just trying to place it in the world will treat the pivot of the object as being at ground level, with no way to both place it at a proper height and sort it correctly.

 

There are several options for this. Just to get it out of the system, the first option is to add empty space to the texture below the bird house to make sure the pivot is at ground level (in Unity, the pivot can’t be outside of the sprite). This is baaaad! This is wasting texture space, and all instances of that object will need to be at the same height in the game. There are other, less insane, options.

One is having a height property in the DepthSortByY behavior and subtract it from transform.position.y when computing the sorting order.
Another solution (which we went with) is allowing the DepthSortByY behavior to make the depth computation based on another object’s transform. This way, the objects will be considered to be at the same point in space as their target and they’ll have the same depth order, even if they’re at different Y positions in the scene. In the bird house example, the bird house uses the tree’s world position for its depth computations.
This solution works better for our game, because it allows artists to move the item freely while staying at the depth (and not have to deal with editing the “height” parameter). And mainly because all the gameplay takes place in the ground’s 2D plane anyway so all objects are guaranteed to have a root object that has the ground position. In your own game, it might be easier to just use the first option.

[ExecuteInEditMode]
[RequireComponent(typeof(Renderer))]
public class IsometricObject : MonoBehaviour
{
   private const int IsometricRangePerYUnit = 100;
   
   [Tooltip("Will use this object to compute z-order")]
    public Transform Target;
    
    [Tooltip("Use this to offset the object slightly in front or behind the Target object")]
    public int TargetOffset = 0;
    
    void Update()
    {
        if (Target == null)
            Target = transform;
        Renderer renderer = GetComponent();
        renderer.sortingOrder = -(int)(Target.position.y * IsometricRangePerYUnit) + TargetOffset;
    }
}

This is how this example is set up in Unity:

The birdhouse references the tree for its depth.

 

And this is how it behaves in practice:

 

Ground Projection

For certain visual elements and effect, we wanted them to look properly projected on the ground, but also not spend too much time on making art for them. The ‘isometric’ view of the game means that anything that is horizontally on the ground should look squashed vertically.
For simple sprites, this is quite easy. Just draw them directly with the correct perspective and place them in the game.

Things get more complicated when you need something that should be able to rotate in any direction. Like something to show the direction the character is moving in, or some visual effect sweeping the ground towards your attacking direction. Especially if these are things that are animated, drawing them manually for all possible orientations is out of the question (or so the artists claim).

Our solution is: the artists draw and animate these effects as if viewed top-down, and the programmers take care of transforming them at runtime to look as if they were projected on the ground. Without any transformation, just taken from the artists and placed in the game rotating them to match the player’s direction they look like below.

 

We need to squash them vertically. For a sprite that doesn’t rotate, just scaling on the Y dimension does the job. But for a rotating sprite this doesn’t work, and it’s even worse for animations. The first thing we tried was a custom shader that transformed the vertices in the local space to squash them vertically (naturally, we went with the most complex solution first), but this needed to break batching to work properly with all sprites and animations. Or I was just bad at writing that shader, maybe…

The final solution is absurdly simple. Just rotate the object around the X axis, and it works!
However, we also wanted to:

  • apply the rotation automatically and consistently, and not have to remember or care about setting the X component of the rotation ourselves
  • be able to set the Z component of the rotation (to make the effect rotate towards any game world direction)
  • not have to visit all ‘ground projected’ effects when changing the amount of squashing

Basically, the game should not have to know that a rotation on X axis is happening. If an object has the ProjectOnGround behavior attached, it should just draw properly without additional effort. So we do the math just before rendering, and restore the rotation to its normal value right after. This hides the rotation around the X axis from the rest of the code.

[ExecuteInEditMode]
    public class ProjectOnGround : MonoBehaviour
    {
        private Quaternion savedRotation;

        // called before rendering the object        
        void OnWillRenderObject()
        {
            savedRotation = transform.rotation;
            var eulers = transform.rotation.eulerAngles;
            transform.rotation = Quaternion.Euler(Constants.Isometric.PerspectiveAngle, eulers.y, eulers.z);
        }

        //called right after rendering the object
        void OnRenderObject()
        {
            transform.rotation = savedRotation;
        }
    }

Simple and easy. Too bad I wasted time trying to write a shader for this. The result looks good and we can simple ‘project’ any object by just adding this behavior to it.

 

 

 

[출처] https://breadcrumbsinteractive.com/two-unity-tricks-isometric-games/

 

Two Unity tricks for isometric games - Breadcrumbs

Here are two small tricks that can help if you’re making an isometric 2D game in Unity. Ok, so not actually isometric, but that’s the term we’re used to in videogames, so we’ll go with it. These are quite basic and if you’re working on such a gam

breadcrumbsinteractive.com

 

반응형
Posted by blueasa
, |

1. 큰 텍스쳐 로드 시 문제

  -> 텍스쳐 사이즈 줄이기

----

We found out that this problem was caused by big textures loaded at the same time.

After removing these big textures the game started up without any problems.

So for everyone that has the same problem.

Check your big textures and check when they are being loaded and try to load.

----

 

2. 동시에 2번의 File IO

  -> 동시에 File IO 안되도록 수정

----

We found out that this problem was caused by using PlayerPrefs.Save() twice at the same time on two different functions, also we had used File.write() at that time. when we save and write files at a different time, this issue solved.

----

 

[출처] https://stackoverflow.com/questions/37279027/java-lang-error-signal-11-sigsegv-code-1-segv-maperr-unity-spine-android

 

java.lang.Error: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR) Unity Spine Android

Hi I currently have a problem on a app I made where the app crashes on startup or after the intro video. I am working with Unity3D and Spine to create a 2D game for Android and IOS. I have searched

stackoverflow.com

 

반응형
Posted by blueasa
, |

[링크] https://ddusi-dod.tistory.com/20

 

[Android] Firebase setCurrentScreen 지원중단

앞선 포스팅에 이어, Firebase SDK가 업데이트되면서 수동화면추적을 위한 setCurrentScreen도 곧 지원중단 되므로, 함수를 변경해주도록 합니다. 수동화면추적이란? 자동 추적 사용 설정 여부와 관계없

ddusi-dod.tistory.com

 

반응형
Posted by blueasa
, |

Hidden Assets

During the import process, Unity ignores the following files and folders in the Assets folder (or a sub-folder within it):

  • Hidden folders.
  • Files and folders which start with ‘.’.
  • Files and folders which end with ‘~’.
  • Files and folders named cvs.
  • Files with the extension .tmp.

This prevents importing special and temporary files created by the operating system or other applications.

 

[출처] https://forum.unity.com/threads/exclude-files-or-folders-from-importing.48090/

 

Exclude files or folders from importing

Is there any way to exclude psd, jpg, max file (or whole folder) in Assets folder from being imported to Unity as texture or model? I keep my...

forum.unity.com

 

[참조] https://docs.unity3d.com/Manual/SpecialFolders.html?_gl=1*f8onwh*_ga*MTUzMjkzMTA0MC4xNjIyNzEzNDM4*_ga_1S78EFL1W5*MTYyNDg3MTc4MS41LjEuMTYyNDg3MjE4OC4xMA..&_ga=2.190280226.821848530.1624841162-1532931040.1622713438 

 

Unity - Manual: Special folder names

Reusing assets between projects How do you use documentation throughout your workflow? Share your experience with us by taking this survey. Special folder names You can usually choose any name you like for the folders you create to organise your Unity proj

docs.unity3d.com

 

반응형
Posted by blueasa
, |

[링크] https://developstudy.tistory.com/74

 

C# 자주 쓰는 Collection 집계 함수

자주 쓰는 컬렉션 집계함수들을 모아서 간단하게 사용법을 정리해보았다. 아래에서 사용한 함수는 아래와 같다. 0. Foreach 1. FindAll(찾기) 2. Except(차집합) 3. ToDictionary(사전화) 4. Select(골라내기) 5...

developstudy.tistory.com

 

반응형
Posted by blueasa
, |