@echo off
setlocal Enabledelayedexpansion
set var=value
if %var%==value (
set var=another value
echo !var!
)
endlocal & (
set "var2=%var%"
)
File2.bat
call "File1.bat" echo %var2%
@echo off
setlocal Enabledelayedexpansion
set var=value
if %var%==value (
set var=another value
echo !var!
)
endlocal & (
set "var2=%var%"
)
File2.bat
call "File1.bat" echo %var2%
using UnityEngine;
public class flipMesh : MonoBehaviour {
// Use this for initialization
void Start () {
Mesh mesh = GetComponent().mesh;
Vector2[] uv = mesh.uv;
int szV = uv.Length;
Vector2[] newUv = new Vector2[szV];
for (int j = 0; j < szV; j++)
{
newUv[j] = new Vector2(uv[szV - j - 1].x, uv[j].y);
}
mesh.uv = newUv;
}
}
using UnityEngine;
using System.Collections;
public class doubleSideShader : MonoBehaviour {
// Use this for initialization
void Start () {
Mesh mesh = GetComponent().mesh;
Vector3[] vertices = mesh.vertices;
Vector2[] uv = mesh.uv;
Vector3[] normals = mesh.normals;
int szV = vertices.Length;
Vector3[] newVerts = new Vector3[szV * 2];
Vector2[] newUv = new Vector2[szV * 2];
Vector3[] newNorms = new Vector3[szV * 2];
for (int j = 0; j < szV; j++)
{
// duplicate vertices and uvs:
newVerts[j] = newVerts[j + szV] = vertices[j];
newUv[j] = newUv[j + szV] = uv[j];
// copy the original normals...
newNorms[j] = normals[j];
// and revert the new ones
newNorms[j + szV] = -normals[j];
}
int[] triangles = mesh.triangles;
int szT = triangles.Length;
int[] newTris = new int[szT * 2]; // double the triangles
for (int i = 0, j = 0; i < szT; i += 3)
{
// copy the original triangle
newTris[i] = triangles[i];
newTris[i + 1] = triangles[i + 1];
newTris[i + 2] = triangles[i + 2];
// save the new reversed triangle
j = i + szT;
newTris[j] = triangles[i] + szV;
newTris[j + 2] = triangles[i + 1] + szV;
newTris[j + 1] = triangles[i + 2] + szV;
}
mesh.vertices = newVerts;
mesh.uv = newUv;
mesh.normals = newNorms;
mesh.triangles = newTris; // assign triangles last!
}
// Update is called once per frame
void Update () {
}
}
using UnityEngine;
using UnityEditor;
[CustomEditor (typeof(customIns))]
class customIns : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
Texture txture = Resources.Load("file_name_without_extension");
GUILayout.Label(txture);
if (GUILayout.Button("Button"))
{
Debug.Log("It's alive: " + target.name);
}
}
}
using UnityEngine;
using System.Collections;
public class inputInGame : MonoBehaviour {
public int editNum;
public Color color;
public Vector3 position;
public bool check;
public enum customExpand {choose1, choose2 }
public customExpand expand;
// Update is called once per frame
void Update () {
}
}
using UnityEngine;
using System.Collections;
using UnityEditor;
public class LaserProject : MonoBehaviour {
public GameObject pointer;
private Light spotlight;
private LineRenderer lineRenderer;
public enum ProjectTypes {SpotLightTangent, SpotLightNormal, PatchObject};
public ProjectTypes projectTypes;
//是否顯示光線
public bool showLight = true;
//光源移動離目標距離
private float minDistance = 1f;
//定義一個Vector3,用來儲存物件原點位置
private Vector3 originalPosition;
//從螢幕射出的光線
private Ray rayFromCam;
//沿著螢幕射線慢慢移動的光線
private Ray ray;
//a RaycastHit variable, to gather informartion about the ray's collision
private RaycastHit hitFromCam, hit;
//用來索引端點
private int index = 0;
// Use this for initialization
void Awake () {
if (projectTypes != ProjectTypes.PatchObject)
{
//取得燈光物件
spotlight = gameObject.GetComponent();
spotlight.enabled = false;
//貼圖設為看不見
pointer.active = false;
}
//紀錄原點位置
originalPosition = transform.position;
if (showLight) //顯示光線
{
//添加LineRenderer組件
lineRenderer = gameObject.AddComponent();
//設置材質
lineRenderer.material = new Material(Shader.Find("Particles/Additive"));
//設置顏色
lineRenderer.SetColors(Color.white, Color.white);
//設置寬度
lineRenderer.SetWidth(0.01f, 0.05f);
//設置起點與終點,若不設置終點會自動產生線段
lineRenderer.SetPosition(0, originalPosition);
lineRenderer.SetPosition(1, originalPosition);
}
}
// Update is called once per frame
void Update () {
if (Input.GetMouseButton(0)) //點擊左鍵
{
if (projectTypes != ProjectTypes.PatchObject)
spotlight.enabled = false; //關閉光源
//從攝像機發出到點擊坐標的射線
rayFromCam = Camera.main.ScreenPointToRay(Input.mousePosition);
// 如果有射到物體
if (Physics.Raycast(rayFromCam, out hitFromCam))
{
//取得投影點與對應物體名稱
//Debug.Log("" + hitFromCam.point.x + ", " + hitFromCam.point.y + ", " + hitFromCam.point.z);
//GameObject gameObj = hitFromCam.collider.gameObject;
//Debug.Log("click object name is " + gameObj.name);
Vector3 direction = hitFromCam.point - originalPosition;
ray = new Ray(originalPosition, direction);
//發射一條100個單位長的射線
if (Physics.Raycast(ray.origin, ray.direction, out hit, 100))
{
if (showLight)
{
//獲取LineRenderer組件
lineRenderer = GetComponent();
lineRenderer.SetPosition(index + 1, hit.point);
}
//計算距離
float distance = Vector3.Distance(originalPosition, hit.point);
//Debug.Log("normal " + hit.normal);
switch (projectTypes)
{
//1. 光源移動到沿射線距離物件minDistance上
case ProjectTypes.SpotLightTangent:
if (distance > minDistance)
{
transform.LookAt(hit.point);
spotlight.spotAngle = 60;
spotlight.range = minDistance * 2;
spotlight.transform.position =
Vector3.MoveTowards(originalPosition, hit.point, distance - minDistance);
spotlight.enabled = true;
}
else
spotlight.enabled = false;
break;
//2. 光源移動至法向量上
case ProjectTypes.SpotLightNormal:
if (distance > minDistance)
{
transform.LookAt(hit.point);
spotlight.spotAngle = 70;
spotlight.range = minDistance * 3;
spotlight.transform.position = hit.point + hit.normal * minDistance;
spotlight.enabled = true;
}
else
spotlight.enabled = false;
break;
//3.使用半透明物件作為標示物
case ProjectTypes.PatchObject:
pointer.transform.position = hit.point;
pointer.transform.rotation =
Quaternion.FromToRotation(pointer.transform.up, hit.normal) * pointer.transform.rotation;
break;
default:
break;
}
}
}
}
}
}