本文整理汇总了C#中UnityEditor.MonoScript类的典型用法代码示例。如果您正苦于以下问题:C# MonoScript类的具体用法?C# MonoScript怎么用?C# MonoScript使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MonoScript类属于UnityEditor命名空间,在下文中一共展示了MonoScript类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Init
private void Init(MonoScript script)
{
this.m_Initialized = true;
this.m_ScriptClass = script.GetClass();
this.m_NetworkChannelLabel = new GUIContent("Network Channel", "QoS channel used for updates. Use the [NetworkSettings] class attribute to change this.");
this.m_NetworkSendIntervalLabel = new GUIContent("Network Send Interval", "Maximum update rate in seconds. Use the [NetworkSettings] class attribute to change this, or implement GetNetworkSendInterval");
foreach (System.Reflection.FieldInfo info in this.m_ScriptClass.GetFields(BindingFlags.Public | BindingFlags.Instance))
{
Attribute[] customAttributes = (Attribute[]) info.GetCustomAttributes(typeof(SyncVarAttribute), true);
if (customAttributes.Length > 0)
{
this.m_SyncVarNames.Add(info.Name);
}
}
MethodInfo method = script.GetClass().GetMethod("OnSerialize");
if ((method != null) && (method.DeclaringType != typeof(NetworkBehaviour)))
{
this.m_HasOnSerialize = true;
}
int num2 = 0;
foreach (System.Reflection.FieldInfo info3 in base.serializedObject.targetObject.GetType().GetFields())
{
if ((info3.FieldType.BaseType != null) && info3.FieldType.BaseType.Name.Contains("SyncList"))
{
num2++;
}
}
if (num2 > 0)
{
this.m_ShowSyncLists = new bool[num2];
}
}
示例2: ScriptNavigatorItemFor
private ScriptNavigatorItem ScriptNavigatorItemFor(MonoScript script, string path)
{
var fullPath = System.IO.Path.GetFullPath(path); // get extension
var fileName = System.IO.Path.GetFileName(fullPath);
var instanceID = script.GetInstanceID();
return new ScriptNavigatorItem(fileName, instanceID, FileNavigationService);
}
开发者ID:transformersprimeabcxyz,项目名称:_TO-DO-CodeEditor-Unity-Technologies,代码行数:7,代码来源:ScriptNavigatorItemProvider.cs
示例3: OnEnable
void OnEnable() {
if (!Application.isPlaying) {
monoScript = MonoScript.FromMonoBehaviour(script);
int currentExecutionOrder = MonoImporter.GetExecutionOrder(monoScript);
if (currentExecutionOrder != 10200) MonoImporter.SetExecutionOrder(monoScript, 10200);
}
}
示例4: OnInspectorGUI
public override void OnInspectorGUI()
{
var proCamera2DTriggerInfluence = (ProCamera2DTriggerInfluence)target;
if(proCamera2DTriggerInfluence.ProCamera2D == null)
EditorGUILayout.HelpBox("ProCamera2D is not set.", MessageType.Error, true);
serializedObject.Update();
// Show script link
GUI.enabled = false;
_script = EditorGUILayout.ObjectField("Script", _script, typeof(MonoScript), false) as MonoScript;
GUI.enabled = true;
// ProCamera2D
_tooltip = new GUIContent("Pro Camera 2D", "");
EditorGUILayout.PropertyField(serializedObject.FindProperty("ProCamera2D"), _tooltip);
// Update interval
_tooltip = new GUIContent("Update Interval", "Every X seconds detect collision. Smaller frequencies are more precise but also require more processing.");
EditorGUILayout.PropertyField(serializedObject.FindProperty("UpdateInterval"), _tooltip);
if (proCamera2DTriggerInfluence.UpdateInterval <= 0.01f)
proCamera2DTriggerInfluence.UpdateInterval = 0.01f;
// Trigger shape
_tooltip = new GUIContent("Trigger Shape", "");
EditorGUILayout.PropertyField(serializedObject.FindProperty("TriggerShape"), _tooltip);
// Focus point
_tooltip = new GUIContent("Focus Point", "If set, the focus point will be this instead of the center of the trigger");
EditorGUILayout.PropertyField(serializedObject.FindProperty("FocusPoint"), _tooltip);
// Influence smoothness
_tooltip = new GUIContent("Influence Smoothness", "How smoothly should the camera move towards the focus point?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("InfluenceSmoothness"), _tooltip);
if (proCamera2DTriggerInfluence.InfluenceSmoothness < 0f)
proCamera2DTriggerInfluence.InfluenceSmoothness = 0f;
// Exclusive influence percentage
_tooltip = new GUIContent("Exclusive Influence Percentage", "After entering this area the camera will reach it's max zoom value");
EditorGUILayout.PropertyField(serializedObject.FindProperty("ExclusiveInfluencePercentage"), _tooltip);
// Trigger targets
EditorGUILayout.BeginHorizontal();
var tooltip = new GUIContent("Use Targets Mid Point", "If checked, the trigger will use the mid point of all your camera targets");
EditorGUILayout.PropertyField(serializedObject.FindProperty("UseTargetsMidPoint"), tooltip);
if (!proCamera2DTriggerInfluence.UseTargetsMidPoint)
{
tooltip = new GUIContent("Trigger Target", "The target to use instead of the mid point of all camera targets");
EditorGUILayout.PropertyField(serializedObject.FindProperty("TriggerTarget"), tooltip);
}
EditorGUILayout.EndHorizontal();
serializedObject.ApplyModifiedProperties();
}
示例5: OnEnable
void OnEnable()
{
var proCamera2DCameraWindow = (ProCamera2DCameraWindow)target;
if(proCamera2DCameraWindow.ProCamera2D == null && Camera.main != null)
proCamera2DCameraWindow.ProCamera2D = Camera.main.GetComponent<ProCamera2D>();
_script = MonoScript.FromMonoBehaviour((ProCamera2DCameraWindow)target);
}
示例6: OnEnable
void OnEnable()
{
var proCamera2DTriggerInfluence = (ProCamera2DTriggerInfluence)target;
if(proCamera2DTriggerInfluence.ProCamera2D == null && Camera.main != null)
proCamera2DTriggerInfluence.ProCamera2D = Camera.main.GetComponent<ProCamera2D>();
_script = MonoScript.FromMonoBehaviour(proCamera2DTriggerInfluence);
}
示例7: OnEnable
void OnEnable()
{
var proCamera2DForwardFocus = (ProCamera2DForwardFocus)target;
if(proCamera2DForwardFocus.ProCamera2D == null && Camera.main != null)
proCamera2DForwardFocus.ProCamera2D = Camera.main.GetComponent<ProCamera2D>();
_script = MonoScript.FromMonoBehaviour((ProCamera2DForwardFocus)target);
}
示例8: OnEnable
void OnEnable()
{
var proCamera2DPixelPerfectSprite = (ProCamera2DPixelPerfectSprite)target;
if (proCamera2DPixelPerfectSprite.ProCamera2D == null && Camera.main != null)
proCamera2DPixelPerfectSprite.ProCamera2D = Camera.main.GetComponent<ProCamera2D>();
_script = MonoScript.FromMonoBehaviour(proCamera2DPixelPerfectSprite);
}
示例9: OnInspectorGUI
public override void OnInspectorGUI()
{
var proCamera2DForwardFocus = (ProCamera2DForwardFocus)target;
serializedObject.Update();
// Show script link
_script = EditorGUILayout.ObjectField("Script", _script, typeof(MonoScript), false) as MonoScript;
// ProCamera2D
_tooltip = new GUIContent("Pro Camera 2D", "");
EditorGUILayout.PropertyField(serializedObject.FindProperty("ProCamera2D"), _tooltip);
if(proCamera2DForwardFocus.ProCamera2D == null)
EditorGUILayout.HelpBox("ProCamera2D is not set.", MessageType.Error, true);
// Progressive
_tooltip = new GUIContent("Progressive", "Should the forward focus move progressively based on the camera speed or should it transition to the focus based on the direction.");
EditorGUILayout.PropertyField(serializedObject.FindProperty("Progressive"), _tooltip);
// Speed multiplier
if(proCamera2DForwardFocus.Progressive)
{
_tooltip = new GUIContent("Speed Multiplier", "Multiply the camera speed by this number. You probably only want to change this value if the camera speed is not sufficient to reach the target focus.");
EditorGUILayout.PropertyField(serializedObject.FindProperty("SpeedMultiplier"), _tooltip);
}
// Transition smoothness
_tooltip = new GUIContent("Transition smoothness", "How smoothly should the forward focus influence move?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("TransitionSmoothness"), _tooltip);
if(proCamera2DForwardFocus.TransitionSmoothness < 0f) proCamera2DForwardFocus.TransitionSmoothness = 0f;
// Maintain Influence On Stop
_tooltip = new GUIContent("Maintain Influence On Stop", "Should the influence maintain after the camera stops?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("MaintainInfluenceOnStop"), _tooltip);
// Left focus
_tooltip = new GUIContent("Left Focus", "How much should the camera compensate when moving left?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("LeftFocus"), _tooltip);
// Right focus
_tooltip = new GUIContent("Right Focus", "How much should the camera compensate when moving right?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("RightFocus"), _tooltip);
// Up focus
_tooltip = new GUIContent("Up Focus", "How much should the camera compensate when moving up?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("TopFocus"), _tooltip);
// Down focus
_tooltip = new GUIContent("Down Focus", "How much should the camera compensate when moving down?");
EditorGUILayout.PropertyField(serializedObject.FindProperty("BottomFocus"), _tooltip);
serializedObject.ApplyModifiedProperties();
}
示例10: OnGUI
void OnGUI()
{
// CSV
TextAsset newCsv = EditorGUILayout.ObjectField("CSV", csv, typeof(TextAsset), false) as TextAsset;
if(newCsv != csv)
{
csv = newCsv;
if(csv != null)
arr = CsvParser2.Parse(csv.text);
else
arr = null;
}
// Script
script = EditorGUILayout.ObjectField("Script", script, typeof(MonoScript), false) as MonoScript;
// buttons
EditorGUILayout.BeginHorizontal();
if(GUILayout.Button("Refresh") && csv != null)
arr = CsvParser2.Parse(csv.text);
if(GUILayout.Button("Generate Code"))
{
string path = "";
if(script != null)
{
path = AssetDatabase.GetAssetPath(script);
}
else
{
path = EditorUtility.SaveFilePanel("Save Script", "Assets", csv.name + "Table.cs", "cs");
}
if(!string.IsNullOrEmpty(path))
script = CreateScript(csv, path);
}
EditorGUILayout.EndHorizontal();
// columns
if(arr != null)
{
foldout = EditorGUILayout.Foldout(foldout, "Columns");
if(foldout)
{
EditorGUI.indentLevel++;
if(csv != null && arr == null)
arr = CsvParser2.Parse(csv.text);
if(arr != null)
{
for(int i = 0 ; i < arr[0].Length ; i++)
{
EditorGUILayout.LabelField(arr[0][i]);
}
}
EditorGUI.indentLevel--;
}
}
}
示例11: OnEnable
void OnEnable() {
if (serializedObject == null) return;
// Changing the script execution order
if (!Application.isPlaying) {
monoScript = MonoScript.FromMonoBehaviour(script);
int currentExecutionOrder = MonoImporter.GetExecutionOrder(monoScript);
if (currentExecutionOrder != 10000) MonoImporter.SetExecutionOrder(monoScript, 10000);
}
}
示例12: OnInspectorGUI
public override void OnInspectorGUI()
{
var proCamera2DCameraWindow = (ProCamera2DCameraWindow)target;
if (proCamera2DCameraWindow.ProCamera2D == null)
{
EditorGUILayout.HelpBox("ProCamera2D is not set.", MessageType.Error, true);
return;
}
serializedObject.Update();
// Show script link
GUI.enabled = false;
_script = EditorGUILayout.ObjectField("Script", _script, typeof(MonoScript), false) as MonoScript;
GUI.enabled = true;
// ProCamera2D
_tooltip = new GUIContent("Pro Camera 2D", "");
EditorGUILayout.PropertyField(serializedObject.FindProperty("ProCamera2D"), _tooltip);
string hAxis = "";
string vAxis = "";
switch (proCamera2DCameraWindow.ProCamera2D.Axis)
{
case MovementAxis.XY:
hAxis = "X";
vAxis = "Y";
break;
case MovementAxis.XZ:
hAxis = "X";
vAxis = "Z";
break;
case MovementAxis.YZ:
hAxis = "Y";
vAxis = "Z";
break;
}
_tooltip = new GUIContent("Width", "Window width");
EditorGUILayout.Slider(serializedObject.FindProperty("CameraWindowRect.width"), 0f, 1f, _tooltip);
_tooltip = new GUIContent("Height", "Window height");
EditorGUILayout.Slider(serializedObject.FindProperty("CameraWindowRect.height"), 0f, 1f, _tooltip);
_tooltip = new GUIContent(hAxis, "Window horizontal offset");
EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraWindowRect.x"), _tooltip);
_tooltip = new GUIContent(vAxis, "Window vertical offset");
EditorGUILayout.PropertyField(serializedObject.FindProperty("CameraWindowRect.y"), _tooltip);
serializedObject.ApplyModifiedProperties();
}
示例13: OnEnable
void OnEnable()
{
ProCamera2DEditorHelper.AssignProCamera2D(target as BasePC2D);
_script = MonoScript.FromMonoBehaviour((ProCamera2DTriggerRails)target);
var proCamera2DTriggerRails = (ProCamera2DTriggerRails)target;
if(proCamera2DTriggerRails.ProCamera2D != null && proCamera2DTriggerRails.ProCamera2DRails == null)
proCamera2DTriggerRails.ProCamera2DRails = proCamera2DTriggerRails.ProCamera2D.GetComponentInChildren<ProCamera2DRails>();
}
示例14: IsCustomizableScript
private static bool IsCustomizableScript(MonoScript script)
{
bool isCustomizable = false;
Type scriptClass = script.GetClass();
if (scriptClass != null)
{
isCustomizable = scriptClass.IsSubclassOf(typeof(MonoBehaviour)) || scriptClass.IsSubclassOf(typeof(ScriptableObject));
}
return isCustomizable;
}
示例15: LoadMonoScript
static MonoScript _mono_pe; ///< MonoScript assets
/**
* Load the pb_Object and pb_Entity classes to MonoScript assets. Saves us from having to fall back on Reflection.
*/
static void LoadMonoScript()
{
GameObject go = new GameObject();
pb_Object pb = go.AddComponent<pb_Object>();
pb_Entity pe = go.AddComponent<pb_Entity>();
_mono_pb = MonoScript.FromMonoBehaviour( pb );
_mono_pe = MonoScript.FromMonoBehaviour( pe );
DestroyImmediate(go);
}