Skip to content

Instantly share code, notes, and snippets.

@haramakoto
haramakoto / gist:10a4bafe42d99e2d61ded608089cb9ab
Last active June 7, 2023 20:44
UIAttachTo3DObjectSimple.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(RectTransform))]
/// <summary>
/// 3DオブジェクトにUI張り付かせるやつ、ScreenSpace-Overay用
/// </summary>
public class UIAttachTo3DObject : MonoBehaviour
@haramakoto
haramakoto / BoundsSetter.cs
Created February 10, 2023 02:18
RendererのBoundsを設定する
namespace hoge.hoge
{
using UnityEngine;
public class BoundsSetter : MonoBehaviour
{
[SerializeField]
private Vector3 targetBoundsSize;
private void Start()
@haramakoto
haramakoto / MaterialFader.cs
Created February 8, 2023 06:34
単純にマテリアルをDoTweenでフェードさせる
namespace hoge.hoge
{
using System;
using DG.Tweening;
using UnityEngine;
public class MaterialFader : MonoBehaviour
{
[SerializeField]
private Material[] alphaMaterials;
@haramakoto
haramakoto / ImageNumViewer.cs
Last active January 25, 2023 02:29
画像で数字を表示する(3桁)
namespace com.etc.utility
{
using UnityEngine;
public class ImageNumViewer : MonoBehaviour
{
[SerializeField]
private ImageNumViewUnit[] numViewUnits;
private int currentNum;
@haramakoto
haramakoto / ImageNumViewUnit.cs
Created January 25, 2023 01:59
画像で数字を表示する・1桁分
namespace com.etc.utility
{
using UnityEngine;
using UnityEngine.UI;
public class ImageNumViewUnit : MonoBehaviour
{
[SerializeField]
private Sprite[] numSprites;
[SerializeField]
@haramakoto
haramakoto / GetNearest.cs
Created December 8, 2022 20:48
Linqを用いて一番近いオブジェクトを取り出す
using System.Linq;
List<Transform> targetList;
Transform nearestTrans = targetList.OrderBy( x => (x.position - this.position).magnitude).First();
@haramakoto
haramakoto / MakeA3DObjectDraggable.cs
Last active December 31, 2021 22:41 — forked from SimonDarksideJ/MakeA3DObjectDraggable.cs
How to make a 3D object draggable in Unity3D
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
/*
MAKE A 3D OBJECT DRAGGABLE
Riccardo Stecca
http://www.riccardostecca.net
@haramakoto
haramakoto / ParamPrefsSetter
Created July 7, 2014 08:04
ローカルアプリ用の調整パラメータをPlayerPrefsに保存して取り出すやつ
using UnityEngine;
using System.Collections;
public class ParamPrefsSetter : MonoBehaviour {
#region singleton
static ParamPrefsSetter instance;
public static ParamPrefsSetter Instance
{
@haramakoto
haramakoto / OVRMoveCheckAndDoSomething.cs
Last active August 29, 2015 13:59
Riftが動いたら何かするコンポーネント
using UnityEngine;
using System.Collections;
/// <summary>
/// Riftが動いたら何かするコンポーネント。OculusUnityIntegrationに含まれる、OVRDevice.csもAddComponentされている必要があります。
/// </summary>
public class OVRMoveCheckAndDoSomething : MonoBehaviour {
#region parameters
float preRotX;
Quaternion ovrRot;
@haramakoto
haramakoto / agentLocomotion.cs
Created January 28, 2013 14:14
NavMeshのサンプルコードagentLocomotionのCS化
using UnityEngine;
using System.Collections;
[RequireComponent (typeof (NavMeshAgent))]
public class agentLocomotion : MonoBehaviour {
private string locoState_ = "Locomotion_Stand";
private NavMeshAgent agent_;
private Animation anim_;
private Vector3 linkStart_;