Skip to content

Instantly share code, notes, and snippets.

@whaison
Last active August 29, 2015 14:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save whaison/2f6da5641b4904a3c39c to your computer and use it in GitHub Desktop.
Save whaison/2f6da5641b4904a3c39c to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
using System.Collections;
using System.Collections.Generic;
using System;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Reflection;
using System.IO;
using System.Text;
using System.Runtime.CompilerServices;
//namespace UnityEditor{
//public class AnimationWindowExtends : UnityEditor.AnimationWindow {
//Assets/SD_Chara/Editor/AnimationWindowExtends.cs(10,59): error CS0234: The type or namespace name `AnimationWindow' does not exist in the namespace `UnityEditor'. Are you missing an assembly reference?
public class RefrectionHideClassToText : UnityEditor.EditorWindow {
/*
using UnityEngine.Internal;
namespace UnityEngine
{
public sealed class ParticleSystem : Component
{
//
// Properties
//
public extern float duration {
[WrapperlessIcall]
[MethodImpl ()]
get;
}
public extern float emissionRate {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern bool enableEmission {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern float gravityModifier {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern bool isPaused {
[WrapperlessIcall]
[MethodImpl ()]
get;
}
public extern bool isPlaying {
[WrapperlessIcall]
[MethodImpl ()]
get;
}
public extern bool isStopped {
[WrapperlessIcall]
[MethodImpl ()]
get;
}
public extern bool loop {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern int maxParticles {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern int particleCount {
[WrapperlessIcall]
[MethodImpl ()]
get;
}
public extern float playbackSpeed {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern bool playOnAwake {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern uint randomSeed {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
[Obsolete ()]
public extern int safeCollisionEventSize {
[WrapperlessIcall]
[MethodImpl ()]
get;
}
public extern ParticleSystemSimulationSpace simulationSpace {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public Color startColor {
get {
Color result;
this.INTERNAL_get_startColor (out result);
return result;
}
set {
this.INTERNAL_set_startColor (ref value);
}
}
public extern float startDelay {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern float startLifetime {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern float startRotation {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern float startSize {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern float startSpeed {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
public extern float time {
[WrapperlessIcall]
[MethodImpl ()]
get;
[WrapperlessIcall]
[MethodImpl ()]
set;
}
//
// Static Methods
//
private static void GetDirectParticleSystemChildrenRecursive (Transform transform, List<ParticleSystem> particleSystems)
{
IEnumerator enumerator = transform.GetEnumerator ();
try {
while (enumerator.MoveNext ()) {
Transform transform2 = (Transform)enumerator.get_Current ();
ParticleSystem component = transform2.gameObject.GetComponent<ParticleSystem> ();
if (component != ) {
particleSystems.Add (component);
ParticleSystem.GetDirectParticleSystemChildrenRecursive (transform2, particleSystems);
}
}
}
finally {
IDisposable disposable = enumerator as IDisposable;
if (disposable != ) {
disposable.Dispose ();
}
}
}
internal static ParticleSystem[] GetParticleSystems (ParticleSystem root)
{
if (!root) {
return ;
}
List<ParticleSystem> list = new List<ParticleSystem> ();
list.Add (root);
ParticleSystem.GetDirectParticleSystemChildrenRecursive (root.transform, list);
return list.ToArray ();
}
[WrapperlessIcall]
[MethodImpl ()]
private static extern void INTERNAL_CALL_Emit (ParticleSystem self, int count);
//
// Methods
//
[ExcludeFromDocs]
public void Clear ()
{
bool withChildren = ;
this.Clear (withChildren);
}
public void Clear ([DefaultValue ()] bool withChildren)
{
if (withChildren) {
ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems (this);
ParticleSystem[] array = particleSystems;
for (int i = ; i < array.Length; i++) {
ParticleSystem particleSystem = array [i];
particleSystem.Internal_Clear ();
}
}
else {
this.Internal_Clear ();
}
}
public void Emit (int count)
{
ParticleSystem.INTERNAL_CALL_Emit (this, count);
}
public void Emit (Vector3 position, Vector3 velocity, float size, float lifetime, Color32 color)
{
ParticleSystem.Particle particle = default(ParticleSystem.Particle);
particle.position = position;
particle.velocity = velocity;
particle.lifetime = lifetime;
particle.startLifetime = lifetime;
particle.size = size;
particle.rotation = ;
particle.angularVelocity = ;
particle.color = color;
particle.randomSeed = ;
this.Internal_Emit (ref particle);
}
public void Emit (ParticleSystem.Particle particle)
{
this.Internal_Emit (ref particle);
}
[WrapperlessIcall]
[MethodImpl ()]
public extern int GetParticles (ParticleSystem.Particle[] particles);
[WrapperlessIcall]
[MethodImpl ()]
private extern void Internal_Clear ();
[WrapperlessIcall]
[MethodImpl ()]
private extern void Internal_Emit (ref ParticleSystem.Particle particle);
[WrapperlessIcall]
[MethodImpl ()]
private extern void INTERNAL_get_startColor (out Color value);
[WrapperlessIcall]
[MethodImpl ()]
private extern bool Internal_IsAlive ();
[WrapperlessIcall]
[MethodImpl ()]
private extern void Internal_Pause ();
[WrapperlessIcall]
[MethodImpl ()]
private extern void Internal_Play ();
[WrapperlessIcall]
[MethodImpl ()]
private extern void INTERNAL_set_startColor (ref Color value);
[WrapperlessIcall]
[MethodImpl ()]
private extern void Internal_Simulate (float t, bool restart);
[WrapperlessIcall]
[MethodImpl ()]
private extern void Internal_Stop ();
[ExcludeFromDocs]
public bool IsAlive ()
{
bool withChildren = ;
return this.IsAlive (withChildren);
}
public bool IsAlive ([DefaultValue ()] bool withChildren)
{
if (withChildren) {
ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems (this);
ParticleSystem[] array = particleSystems;
for (int i = ; i < array.Length; i++) {
ParticleSystem particleSystem = array [i];
if (particleSystem.Internal_IsAlive ()) {
return ;
}
}
return ;
}
return this.Internal_IsAlive ();
}
[ExcludeFromDocs]
public void Pause ()
{
bool withChildren = ;
this.Pause (withChildren);
}
public void Pause ([DefaultValue ()] bool withChildren)
{
if (withChildren) {
ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems (this);
ParticleSystem[] array = particleSystems;
for (int i = ; i < array.Length; i++) {
ParticleSystem particleSystem = array [i];
particleSystem.Internal_Pause ();
}
}
else {
this.Internal_Pause ();
}
}
[ExcludeFromDocs]
public void Play ()
{
bool withChildren = ;
this.Play (withChildren);
}
public void Play ([DefaultValue ()] bool withChildren)
{
if (withChildren) {
ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems (this);
ParticleSystem[] array = particleSystems;
for (int i = ; i < array.Length; i++) {
ParticleSystem particleSystem = array [i];
particleSystem.Internal_Play ();
}
}
else {
this.Internal_Play ();
}
}
[WrapperlessIcall]
[MethodImpl ()]
public extern void SetParticles (ParticleSystem.Particle[] particles, int size);
[WrapperlessIcall]
[MethodImpl ()]
internal extern void SetupDefaultType (int type);
[ExcludeFromDocs]
public void Simulate (float t, bool withChildren)
{
bool restart = ;
this.Simulate (t, withChildren, restart);
}
[ExcludeFromDocs]
public void Simulate (float t)
{
bool restart = ;
bool withChildren = ;
this.Simulate (t, withChildren, restart);
}
public void Simulate (float t, [DefaultValue ()] bool withChildren, [DefaultValue ()] bool restart)
{
if (withChildren) {
ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems (this);
ParticleSystem[] array = particleSystems;
for (int i = ; i < array.Length; i++) {
ParticleSystem particleSystem = array [i];
particleSystem.Internal_Simulate (t, restart);
}
}
else {
this.Internal_Simulate (t, restart);
}
}
[ExcludeFromDocs]
public void Stop ()
{
bool withChildren = ;
this.Stop (withChildren);
}
public void Stop ([DefaultValue ()] bool withChildren)
{
if (withChildren) {
ParticleSystem[] particleSystems = ParticleSystem.GetParticleSystems (this);
ParticleSystem[] array = particleSystems;
for (int i = ; i < array.Length; i++) {
ParticleSystem particleSystem = array [i];
particleSystem.Internal_Stop ();
}
}
else {
this.Internal_Stop ();
}
}
//
// Nested Types
//
[Obsolete (, )]
[StructLayout (LayoutKind.Sequential, Size = )]
public struct CollisionEvent
{
}
public struct Particle
{
public Vector3 position {
get {
return this.m_Position;
}
set {
this.m_Position = value;
}
}
public Vector3 velocity {
get {
return this.m_Velocity;
}
set {
this.m_Velocity = value;
}
}
public float lifetime {
get {
return this.m_Lifetime;
}
set {
this.m_Lifetime = value;
}
}
public float startLifetime {
get {
return this.m_StartLifetime;
}
set {
this.m_StartLifetime = value;
}
}
public float size {
get {
return this.m_Size;
}
set {
this.m_Size = value;
}
}
public Vector3 axisOfRotation {
get {
return this.m_AxisOfRotation;
}
set {
this.m_AxisOfRotation = value;
}
}
public float rotation {
get {
return this.m_Rotation * ;
}
set {
this.m_Rotation = value * ;
}
}
public float angularVelocity {
get {
return this.m_AngularVelocity * ;
}
set {
this.m_AngularVelocity = value * ;
}
}
public Color32 color {
get {
return this.m_Color;
}
set {
this.m_Color = value;
}
}
[Obsolete ()]
public float randomValue {
get {
return BitConverter.ToSingle (BitConverter.GetBytes (this.m_RandomSeed), );
}
set {
this.m_RandomSeed = BitConverter.ToUInt32 (BitConverter.GetBytes (value), );
}
}
public uint randomSeed {
get {
return this.m_RandomSeed;
}
set {
this.m_RandomSeed = value;
}
}
}
}
}
*/
void OnGUI ()
{
GUILayout.Label ("RefrectionHideClassToText v0.0.6 ", EditorStyles.boldLabel);
GUILayout.Space (10f);
GUILayout.Space (20f);
if (GUILayout.Button ("01 : RefrectionHideClassToText", GUILayout.Width (300f))) {
RefrectionHideClassToTextFunc ();
//countTime = 0;
}
}
void RefrectionHideClassToTextFunc(){
Debug.Log ("RefrectionHideClassToTextFunc");
//Init0 ();
GetParticleSystem();
//Init1 ();
//Init2 ();
}
public List<string> fileWriterLine_List = new List<string>();
/*
void Init0(){
EditorWindow[] windows = Resources.FindObjectsOfTypeAll(typeof(EditorWindow)) as EditorWindow[];
foreach (EditorWindow w in windows)
{
//Debug.Log(w.title);
if (w.title == "Animation") {
fileWriterLine_List = new List<string>();
Debug.Log("------------------Animation----------------");
fileWriterLine_List.Add ("------------------Animation----------------START");
Init1 (w);
Debug.Log("------------------Animation-----------------");
fileWriterLine_List.Add ("------------------Animation----------------END");
logSave ();
//HideMethodTest1 (w);
}
}
}
*/
void GetParticleSystem(){
//GameObject gameObject = FindObjectOfType<ParticleSystem> ().transform.parent.gameObject;]
ParticleSystem gameObject = FindObjectOfType<ParticleSystem> ();
Debug.Log("調べるゲームオブジェクト名: "+gameObject.name);
UnityEngine.Object w=gameObject;
//foreach (GameObject w in gameObject)
//{
//Debug.Log(w.title);
//if (w.name == "ParticleSystem") {
fileWriterLine_List = new List<string>();
Debug.Log("------------------ParticleSystem----------------");
fileWriterLine_List.Add ("------------------ParticleSystem----------------START");
Init1 (w);
Debug.Log("------------------ParticleSystem-----------------");
fileWriterLine_List.Add ("------------------ParticleSystem----------------END");
logSave ();
//HideMethodTest1 (w);
//}
//}
}
void Init1(UnityEngine.Object w){
Debug.Log("------------------publicメッソドを列挙----------------");
fileWriterLine_List.Add ("------------------publicメッソドを列挙----------------");
//
MethodInfo[] methods = w.GetType().GetMethods(); // w は AnimationWindow
foreach (MethodInfo m in methods)
{
string str = "";
if(m.IsPublic) str += "public ";
if(m.IsStatic) str += "static ";
str += m.ReturnType.ToString() + " ";
str += m.Name + "\n";
// 引数
ParameterInfo[] param = m.GetParameters();
for (int i = 0; i < param.Length; i++)
{
str += param[i].ParameterType.ToString() + " " + param[i].Name + (i < param.Length - 1 ? ", " : "");
}
Debug.Log(str);
fileWriterLine_List.Add (str);
}
Debug.Log("------------------privateメッソドを列挙----------------");
fileWriterLine_List.Add ("------------------privateメッソドを列挙----------------");
//
methods = w.GetType().GetMethods(BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Instance);
foreach (MethodInfo m in methods)
{
string str = "";
if (m.IsPrivate) str += "private ";
str += m.ReturnType.ToString() + " ";
str += m.Name + "\n";
// 引数
ParameterInfo[] param = m.GetParameters();
for (int i = 0; i < param.Length; i++)
{
str += param[i].ParameterType.ToString() + " " + param[i].Name + (i < param.Length - 1 ? ", " : "");
}
//Debug.Log(str);
Debug.Log(str);
fileWriterLine_List.Add (str);
}
}
/* output
------------------Animation----------------
----method----
public static System.Collections.Generic.List`1[UnityEditor.AnimationWindow] GetAllAnimationWindows;
public System.Void OnEnable;
public System.Void OnDisable;
public System.Void Update;
public System.Void OnGUI;
public System.Void OnSelectionChange;
public System.Void BeginWindows;
public System.Void EndWindows;
-----Propaty-----
public System.Boolean get_wantsMouseMove;
public System.Void set_wantsMouseMove;
public System.Void ShowNotification;
public System.Void RemoveNotification;
public System.Boolean get_autoRepaintOnSceneChange;
public System.Void set_autoRepaintOnSceneChange;
------------------Animation----------------
*/
//メソッド呼び出し
//以下のコードは、AnimationClipをセットしたGameObjectをHierarchy上で選択した状態であることを前提に動作させています。
void HideMethodTest1(EditorWindow w){
System.Type t = w.GetType(); // w は AnimationWindow
// アニメーション編集モード(?)にする
t.InvokeMember("set_autoRepaintOnSceneChange", BindingFlags.InvokeMethod, null, w, new object[] { true });
// タイムラインを 1:00 に合わせる
t.InvokeMember("UpdateTime", BindingFlags.InvokeMethod, null, w, new object[] { 1.0f });
}
/////////////////////////////////////
public void logSave(){
Debug.Log ("///////////////////////////////////////////////");
Debug.Log ("///////////////////////////////////////////////");
Debug.Log ("////////////////LOG SAVE //////////////////");
Debug.Log ("///////////////////////////////////////////////");
Debug.Log ("///////////////////////////////////////////////");
string filepass = "";
filepass="/works/unity3d/UnityParticleScriptTestProject/Assets/Editor/RefrectionHideClassToText.txt";
//filepass = saveDirPath;
StreamWriter sw = new StreamWriter (filepass, false, Encoding.UTF8);
//sw.WriteLine ("CN,effectId,assetBundleName,prefabName,assetPass");
//sw.WriteLine ("//,アセットID,アセットバンドル名.unity3d,prefab名,assetのパス");
for (int i = 0; i < fileWriterLine_List.Count; i++) {
//string url = fileWriterLine_List [i];
//string oneline = "1"+","+"id" + "," + url+ "," + "prefab_name"+ "," + "asset_pass";
string oneline=fileWriterLine_List [i];
Debug.Log("oneline= "+oneline);
//Debug.Log (oneline);
sw.WriteLine(oneline);
}
//sw.Fluse();
sw.Close();
Debug.Log ("///////////////////////////////////////////////");
Debug.Log ("///////////////////////////////////////////////");
Debug.Log ("////////////////LOG SAVE //////////////////");
Debug.Log ("///////////////////////////////////////////////");
Debug.Log ("///////////////////////////////////////////////");
AssetDatabase.Refresh();
}
//////////////////////////////////////////
#region Static
/// <summary>
/// Open the tool window
/// </summary>
[MenuItem("Tools/RefrectionHideClassToText")]
static public void AnimationWindowExtendsOpen ()
{
EditorWindow.GetWindow<RefrectionHideClassToText> (true, "RefrectionHideClassToText", true);
}
#endregion
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment