Skip to content

Instantly share code, notes, and snippets.

/*==== DebugConsole.cs ====================================================
* Class for handling multi-line, multi-color debugging messages.
* Original Author: Jeremy Hollingsworth
* Based On: Version 1.2.1 Mar 02, 2006
*
* Modified: Simon Waite
* Date: 22 Feb 2007
*
* Modification to original script to allow pixel-correct line spacing
*
@cnsoft
cnsoft / 鼠标拖动物体.js
Created November 28, 2013 08:59
鼠标拖动物体.js
var mouseOverColor = Color.blue;//声明变量为蓝色
private var originalColor : Color;//声明变量存储本来颜色
function Start () {
originalColor = renderer.sharedMaterial.color;//开始时得到物体本来着色
}
function OnMouseEnter () {
renderer.material.color = mouseOverColor;//当鼠标滑过时改变物体颜色为蓝色
}
function OnMouseExit () {
@cnsoft
cnsoft / PunEvent.cs
Last active December 29, 2015 01:39
Pun是如何处理 RPC的 通过 RaiseEvent 消息. 筛选接收者.(按id group ) NetworkPeer.onSerializedRead() > // Use incoming data according to observed type if (view.observed is MonoBehaviour) { object[] contents = data[(byte)1] as object[]; PhotonStream pStream = new PhotonStream(false, contents); PhotonMessageInfo info = new PhotonMessageInfo(sender, networkTime, view…
case PunEvent.RPC:
//ts: each event now contains a single RPC. execute this
this.ExecuteRPC(photonEvent[ParameterCode.Data] as Hashtable, originatingPlayer);
break;
case PunEvent.SendSerialize:
case PunEvent.SendSerializeReliable:
Hashtable serializeData = (Hashtable)photonEvent[ParameterCode.Data];
//Debug.Log(serializeData.ToStringFull());
@cnsoft
cnsoft / NetworkInterpolatedTransform.cs
Created November 22, 2013 02:41
> CoreTech 这部分应该才是核心的点. 插槽式同步. 客户端预测.服务器端纠正. >发送过来的都进缓冲.带时间戳. 本地更新时 依次取有效缓冲点,做Lerp 插值. 延迟太高的话, 服务器发过来的会直接把一些过时的插槽去掉. 客户端更新时依旧是Lerp. 可以拉回到某位置.不会超出太多.
using UnityEngine;
using System.Collections;
public class NetworkInterpolatedTransform : Photon.MonoBehaviour
{
//
// NOTE: Network interpolation is afffected by the network sendRate.
// By default this is 10 times/second for OnSerialize. (See PhotonNetwork.sendIntervalOnSerialize)
// Raise the sendrate if you want to lower the interpolationBackTime.
@cnsoft
cnsoft / uLinkStrictCharacter.cs
Last active December 28, 2015 23:09
StrictCharacter Logic . (use timestamp slots to store and cache the movement data.
// (c)2011 MuchDifferent. All Rights Reserved.
using System;
using System.Collections.Generic;
using UnityEngine;
using uLink;
/// 检查是否移动过快.并进行纠正. :)
/// <summary>
/// A script example that can be use for players' objects in a 3d game without gravity.
@cnsoft
cnsoft / SmoothCharacter.cs
Last active December 28, 2015 22:59
Reference MuchDIfferent SnowBox Case. SmoothCharacter.cs smooth and synchronize character state .
// (c)2011 MuchDifferent. All Rights Reserved.
using UnityEngine;
using uLink;
/// <summary>
/// A script example that can be use for players' avatars in a game where the server is authoritative or non-authoritative.
/// </summary>
/// <remarks>
/// When using this example script, it should be added as a component to the game object that a player controls.
@cnsoft
cnsoft / PhotonView_ExecuteOnSerialize.cs
Last active December 28, 2015 20:29
Dynamic GetMethod and call it!
//client.Photon.SupportClass.
public static List<MethodInfo> GetMethods (Type type, Type attribute)
{
List<MethodInfo> list = new List<MethodInfo> ();
List<MethodInfo> result;
if (type == null)
{
result = list;
}
else
@cnsoft
cnsoft / GameRoom.cs
Last active October 6, 2021 07:46
Set Custom Propertites.
PhotonNetwork.isMessageQueueRunning = true;
isPaused = true;
resolutions = Screen.resolutions;
resolutionIndex = (resolutions.Length-1)/2;
QualityNames = QualitySettings.names;
playerList = true;
enableHelper = GameObject.FindWithTag("EnableHelper").gameObject;
//Setup team names ********************************
team_1.teamName = "Team A";
@cnsoft
cnsoft / AutoEnterRoom.cs
Created November 15, 2013 10:20
Auto Enter Room Viking Demo!!
using UnityEngine;
using System.Collections;
public class MainMenuVik : MonoBehaviour
{
void Awake()
{
//PhotonNetwork.logLevel = NetworkLogLevel.Full;
@cnsoft
cnsoft / Preloader.cs
Created November 15, 2013 08:01
Photon Network Library Preloader.cs show how to implement loading progress ui.
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Preloader : Photon.MonoBehaviour
{
public GUISkin skin;
void Update()
{