Added VR libraries
This commit is contained in:
71
Assets/GoogleVR/Scripts/PropertyDrawers/GvrInfoDrawer.cs
Normal file
71
Assets/GoogleVR/Scripts/PropertyDrawers/GvrInfoDrawer.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
// Copyright 2017 Google Inc. All rights reserved.
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using System;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif // UNITY_EDITOR
|
||||
|
||||
/// Use to display an Info box in the inspector for a Monobehaviour or ScriptableObject.
|
||||
[AttributeUsage(AttributeTargets.Field, AllowMultiple = true, Inherited = true)]
|
||||
public class GvrInfo : PropertyAttribute {
|
||||
public string text;
|
||||
public int numLines;
|
||||
|
||||
public GvrInfo(string text, int numLines) {
|
||||
this.text = text;
|
||||
this.numLines = numLines;
|
||||
}
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomPropertyDrawer(typeof(GvrInfo))]
|
||||
public class GvrInfoDrawer : DecoratorDrawer {
|
||||
GvrInfo info {
|
||||
get { return ((GvrInfo)attribute); }
|
||||
}
|
||||
|
||||
public override float GetHeight() {
|
||||
return GetHeightForLines(info.numLines);
|
||||
}
|
||||
|
||||
public override void OnGUI(Rect position) {
|
||||
Draw(position, info.text);
|
||||
}
|
||||
|
||||
public static float GetHeightForLines(int numLines) {
|
||||
return EditorGUIUtility.singleLineHeight * numLines;
|
||||
}
|
||||
|
||||
public static void Draw(Rect position, string text) {
|
||||
position.height -= EditorGUIUtility.standardVerticalSpacing;
|
||||
|
||||
int oldFontSize = EditorStyles.helpBox.fontSize;
|
||||
EditorStyles.helpBox.fontSize = 11;
|
||||
FontStyle oldFontStyle = EditorStyles.helpBox.fontStyle;
|
||||
EditorStyles.helpBox.fontStyle = FontStyle.Bold;
|
||||
bool oldWordWrap = EditorStyles.helpBox.wordWrap;
|
||||
EditorStyles.helpBox.wordWrap = false;
|
||||
|
||||
EditorGUI.HelpBox(position, text, MessageType.Info);
|
||||
|
||||
EditorStyles.helpBox.fontSize = oldFontSize;
|
||||
EditorStyles.helpBox.fontStyle = oldFontStyle;
|
||||
EditorStyles.helpBox.wordWrap = oldWordWrap;
|
||||
}
|
||||
}
|
||||
#endif // UNITY_EDITOR
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c173d28b2a4224c52a4c8ea503f4e2b9
|
||||
timeCreated: 1496357031
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user