Here are the examples of the csharp api UnityEngine.Resources.Load(string) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
147 Examples
19
Source : CharacterMaterials.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Init()
{
if (initialized)
{
return;
}
initialized = true;
Materials = new Dictionary<string, Material>();
NewMaterial("AOTTG_HERO_3DMG");
NewMaterial("aottg_hero_AHSS_3dmg");
NewMaterial("aottg_hero_annie_cap_causal");
NewMaterial("aottg_hero_annie_cap_uniform");
NewMaterial("aottg_hero_brand_sc");
NewMaterial("aottg_hero_brand_mp");
NewMaterial("aottg_hero_brand_g");
NewMaterial("aottg_hero_brand_ts");
NewMaterial("aottg_hero_skin_1");
NewMaterial("aottg_hero_skin_2");
NewMaterial("aottg_hero_skin_3");
NewMaterial("aottg_hero_casual_fa_1");
NewMaterial("aottg_hero_casual_fa_2");
NewMaterial("aottg_hero_casual_fa_3");
NewMaterial("aottg_hero_casual_fb_1");
NewMaterial("aottg_hero_casual_fb_2");
NewMaterial("aottg_hero_casual_ma_1");
NewMaterial("aottg_hero_casual_ma_1_ahss");
NewMaterial("aottg_hero_casual_ma_2");
NewMaterial("aottg_hero_casual_ma_3");
NewMaterial("aottg_hero_casual_mb_1");
NewMaterial("aottg_hero_casual_mb_2");
NewMaterial("aottg_hero_casual_mb_3");
NewMaterial("aottg_hero_casual_mb_4");
NewMaterial("aottg_hero_uniform_fa_1");
NewMaterial("aottg_hero_uniform_fa_2");
NewMaterial("aottg_hero_uniform_fa_3");
NewMaterial("aottg_hero_uniform_fb_1");
NewMaterial("aottg_hero_uniform_fb_2");
NewMaterial("aottg_hero_uniform_ma_1");
NewMaterial("aottg_hero_uniform_ma_2");
NewMaterial("aottg_hero_uniform_ma_3");
NewMaterial("aottg_hero_uniform_mb_1");
NewMaterial("aottg_hero_uniform_mb_2");
NewMaterial("aottg_hero_uniform_mb_3");
NewMaterial("aottg_hero_uniform_mb_4");
NewMaterial("hair_annie");
NewMaterial("hair_armin");
NewMaterial("hair_boy1");
NewMaterial("hair_boy2");
NewMaterial("hair_boy3");
NewMaterial("hair_boy4");
NewMaterial("hair_eren");
NewMaterial("hair_girl1");
NewMaterial("hair_girl2");
NewMaterial("hair_girl3");
NewMaterial("hair_girl4");
NewMaterial("hair_girl5");
NewMaterial("hair_hanji");
NewMaterial("hair_jean");
NewMaterial("hair_levi");
NewMaterial("hair_marco");
NewMaterial("hair_mike");
NewMaterial("hair_petra");
NewMaterial("hair_rico");
NewMaterial("hair_sasha");
NewMaterial("hair_mikasa");
Texture mainTexture = (Texture)Object.Instantiate(Resources.Load("NewTexture/aottg_hero_eyes"));
Material material = (Material)Object.Instantiate(Resources.Load("NewTexture/MaterialGLreplaced"));
material.mainTexture = mainTexture;
Materials.Add("aottg_hero_eyes", material);
}
19
Source : CharacterMaterials.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private static void NewMaterial(string pref)
{
Texture mainTexture = (Texture)Object.Instantiate(Resources.Load("NewTexture/" + pref));
Material material = (Material)Object.Instantiate(Resources.Load("NewTexture/MaterialCharacter"));
material.mainTexture = mainTexture;
Materials.Add(pref, material);
}
19
Source : ClothFactory.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private static GameObject GenerateCloth(GameObject go, string res)
{
bool flag = go.GetComponent<SkinnedMeshRenderer>() == null;
if (flag)
{
go.AddComponent<SkinnedMeshRenderer>();
}
Transform[] bones = go.GetComponent<SkinnedMeshRenderer>().bones;
SkinnedMeshRenderer component = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load(res))).GetComponent<SkinnedMeshRenderer>();
component.transform.localScale = Vector3.one;
component.bones = bones;
component.quality = SkinQuality.Bone4;
return component.gameObject;
}
19
Source : CharacterMaterials.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void Init()
{
if (initialized)
{
return;
}
initialized = true;
Materials = new Dictionary<string, Material>();
NewMaterial("AOTTG_HERO_3DMG");
NewMaterial("aottg_hero_AHSS_3dmg");
NewMaterial("aottg_hero_annie_cap_causal");
NewMaterial("aottg_hero_annie_cap_uniform");
NewMaterial("aottg_hero_brand_sc");
NewMaterial("aottg_hero_brand_mp");
NewMaterial("aottg_hero_brand_g");
NewMaterial("aottg_hero_brand_ts");
NewMaterial("aottg_hero_skin_1");
NewMaterial("aottg_hero_skin_2");
NewMaterial("aottg_hero_skin_3");
NewMaterial("aottg_hero_casual_fa_1");
NewMaterial("aottg_hero_casual_fa_2");
NewMaterial("aottg_hero_casual_fa_3");
NewMaterial("aottg_hero_casual_fb_1");
NewMaterial("aottg_hero_casual_fb_2");
NewMaterial("aottg_hero_casual_ma_1");
NewMaterial("aottg_hero_casual_ma_1_ahss");
NewMaterial("aottg_hero_casual_ma_2");
NewMaterial("aottg_hero_casual_ma_3");
NewMaterial("aottg_hero_casual_mb_1");
NewMaterial("aottg_hero_casual_mb_2");
NewMaterial("aottg_hero_casual_mb_3");
NewMaterial("aottg_hero_casual_mb_4");
NewMaterial("aottg_hero_uniform_fa_1");
NewMaterial("aottg_hero_uniform_fa_2");
NewMaterial("aottg_hero_uniform_fa_3");
NewMaterial("aottg_hero_uniform_fb_1");
NewMaterial("aottg_hero_uniform_fb_2");
NewMaterial("aottg_hero_uniform_ma_1");
NewMaterial("aottg_hero_uniform_ma_2");
NewMaterial("aottg_hero_uniform_ma_3");
NewMaterial("aottg_hero_uniform_mb_1");
NewMaterial("aottg_hero_uniform_mb_2");
NewMaterial("aottg_hero_uniform_mb_3");
NewMaterial("aottg_hero_uniform_mb_4");
NewMaterial("hair_annie");
NewMaterial("hair_armin");
NewMaterial("hair_boy1");
NewMaterial("hair_boy2");
NewMaterial("hair_boy3");
NewMaterial("hair_boy4");
NewMaterial("hair_eren");
NewMaterial("hair_girl1");
NewMaterial("hair_girl2");
NewMaterial("hair_girl3");
NewMaterial("hair_girl4");
NewMaterial("hair_girl5");
NewMaterial("hair_hanji");
NewMaterial("hair_jean");
NewMaterial("hair_levi");
NewMaterial("hair_marco");
NewMaterial("hair_mike");
NewMaterial("hair_petra");
NewMaterial("hair_rico");
NewMaterial("hair_sasha");
NewMaterial("hair_mikasa");
Texture mainTexture = (Texture)Object.Instantiate(Resources.Load("NewTexture/aottg_hero_eyes"));
Material material = (Material)Object.Instantiate(Resources.Load("NewTexture/MaterialGLreplaced"));
material.mainTexture = mainTexture;
Materials.Add("aottg_hero_eyes", material);
}
19
Source : UIMainReferences.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
private void Start()
{
GameObject.Find("VERSION").GetComponent<UILabel>().text = "Loading...";
NGUITools.SetActive(this.panelMain, false);
if (isGAMEFirstLaunch)
{
isGAMEFirstLaunch = false;
GameObject input = (GameObject)Resources.Load("InputManagerController");
input.GetComponent<FengCustomInputs>().enabled = false;
input.AddComponent<Anarchy.InputManager>();
var inputs = (GameObject)Instantiate(input);
inputs.name = "InputManagerController";
DontDestroyOnLoad(inputs);
new GameObject("AnarchyManager").AddComponent<Anarchy.AnarchyManager>();
}
Anarchy.Network.NetworkManager.TryRejoin();
}
19
Source : Language.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
public static void init()
{
string text = ((Textreplacedet)Resources.Load("lang")).text;
string[] array = text.Split(new char[]
{
"\n"[0]
});
string text2 = string.Empty;
int num = 0;
string a = string.Empty;
string text3 = string.Empty;
foreach (string text4 in array)
{
if (!text4.Contains("//"))
{
if (text4.Contains("#START"))
{
text2 = text4.Split(new char[]
{
"@"[0]
})[1];
num = Language.GetLangIndex(text2);
}
else if (text4.Contains("#END"))
{
text2 = string.Empty;
}
else if (text2 != string.Empty && text4.Contains("@"))
{
a = text4.Split(new char[]
{
"@"[0]
})[0];
text3 = text4.Split(new char[]
{
"@"[0]
})[1];
if (a == "btn_single")
{
Language.btn_single[num] = text3;
}
else if (a == "btn_multiplayer")
{
Language.btn_multiplayer[num] = text3;
}
else if (a == "btn_option")
{
Language.btn_option[num] = text3;
}
else if (a == "btn_credits")
{
Language.btn_credits[num] = text3;
}
else if (a == "btn_back")
{
Language.btn_back[num] = text3;
}
else if (a == "btn_refresh")
{
Language.btn_refresh[num] = text3;
}
else if (a == "btn_join")
{
Language.btn_join[num] = text3;
}
else if (a == "btn_start")
{
Language.btn_start[num] = text3;
}
else if (a == "btn_create_game")
{
Language.btn_create_game[num] = text3;
}
else if (a == "btn_LAN")
{
Language.btn_LAN[num] = text3;
}
else if (a == "btn_server_US")
{
Language.btn_server_US[num] = text3;
}
else if (a == "btn_server_EU")
{
Language.btn_server_EU[num] = text3;
}
else if (a == "btn_server_ASIA")
{
Language.btn_server_ASIA[num] = text3;
}
else if (a == "btn_server_replacedAN")
{
Language.btn_server_replacedAN[num] = text3;
}
else if (a == "btn_QUICK_MATCH")
{
Language.btn_QUICK_MATCH[num] = text3;
}
else if (a == "btn_default")
{
Language.btn_default[num] = text3;
}
else if (a == "btn_ready")
{
Language.btn_ready[num] = text3;
}
else if (a == "server_name")
{
Language.server_name[num] = text3;
}
else if (a == "server_ip")
{
Language.server_ip[num] = text3;
}
else if (a == "port")
{
Language.port[num] = text3;
}
else if (a == "choose_map")
{
Language.choose_map[num] = text3;
}
else if (a == "choose_character")
{
Language.choose_character[num] = text3;
}
else if (a == "camera_type")
{
Language.camera_type[num] = text3;
}
else if (a == "camera_original")
{
Language.camera_original[num] = text3;
}
else if (a == "camera_wow")
{
Language.camera_wow[num] = text3;
}
else if (a == "camera_tps")
{
Language.camera_tps[num] = text3;
}
else if (a == "max_player")
{
Language.max_player[num] = text3;
}
else if (a == "max_Time")
{
Language.max_Time[num] = text3;
}
else if (a == "game_time")
{
Language.game_time[num] = text3;
}
else if (a == "difficulty")
{
Language.difficulty[num] = text3;
}
else if (a == "normal")
{
Language.normal[num] = text3;
}
else if (a == "hard")
{
Language.hard[num] = text3;
}
else if (a == "abnormal")
{
Language.abnormal[num] = text3;
}
else if (a == "mouse_sensitivity")
{
Language.mouse_sensitivity[num] = text3;
}
else if (a == "change_quality")
{
Language.change_quality[num] = text3;
}
else if (a == "camera_tilt")
{
Language.camera_tilt[num] = text3;
}
else if (a == "invert_mouse")
{
Language.invert_mouse[num] = text3;
}
else if (a == "waiting_for_input")
{
Language.waiting_for_input[num] = text3;
}
else if (a == "key_set_info_1")
{
Language.key_set_info_1[num] = text3;
}
else if (a == "key_set_info_2")
{
Language.key_set_info_2[num] = text3;
}
else if (a == "soldier")
{
Language.soldier[num] = text3;
}
else if (a == "replacedan")
{
Language.replacedan[num] = text3;
}
else if (a == "select_replacedan")
{
Language.select_replacedan[num] = text3;
}
else if (a == "camera_info")
{
Language.camera_info[num] = text3;
}
else if (a == "btn_continue")
{
Language.btn_continue[num] = text3;
}
else if (a == "btn_quit")
{
Language.btn_quit[num] = text3;
}
else if (a == "choose_region_server")
{
Language.choose_region_server[num] = text3;
}
}
}
}
}
19
Source : CacheResources.cs
with GNU General Public License v3.0
from aelariane
with GNU General Public License v3.0
from aelariane
internal static Object Load(string path)
{
cache.TryGetValue(path, out Object obj);
if (obj != null)
{
return obj;
}
if (cache.ContainsKey(path))
{
cache[path] = Resources.Load(path);
}
else
{
cache.Add(path, Resources.Load(path));
}
return cache[path];
}
19
Source : AoiManager.cs
with MIT License
from Bestpoker
with MIT License
from Bestpoker
void Start () {
//生成100实体并初始化第一个为主角控制 create 100 player and instantial player of control
Material mat = Resources.Load<Material>("Cube");
for (int i = 0; i < enreplacedyCount; i++)
{
Random.InitState(i);
GameObject go = GameObject.CreatePrimitive(PrimitiveType.Cube);
go.name = i.ToString();
go.transform.position = new Vector3(Random.Range(-randomRange, randomRange), 0, Random.Range(-randomRange, randomRange));
go.transform.localScale = new Vector3(3, 3, 3);
go.GetComponent<BoxCollider>().enabled = false;
MeshRenderer render = go.GetComponent<MeshRenderer>();
render.material = mat;
if (i == 0)
{
render.material.color = Color.green;
}
else
{
render.material.color = Color.white;
}
Enreplacedy enreplacedy = new Enreplacedy();
enreplacedy.go = go;
enreplacedy.mat = render.material;
if (i == 0)
{
playerEnreplacedy = enreplacedy;
enreplacedy.isPlayer = true;
}
allEnreplacedy[i] = enreplacedy;
RefreshAoi(enreplacedy);
}
}
19
Source : IconAttribute.cs
with MIT License
from BrunoS3D
with MIT License
from BrunoS3D
public Texture GetIcon() {
Texture t;
if (icons.TryGetValue(icon_path, out t)) {
return t;
}
else {
#if UNITY_EDITOR
return icons[icon_path] = EditorUtils.FindreplacedetByName<Texture>(icon_path);
#else
return icons[icon_path] = Resources.Load<Texture>(icon_path);
#endif
}
}
19
Source : AssetPathConvert.cs
with MIT License
from ByronMayne
with MIT License
from ByronMayne
public static T Load<T>(string projectPath) where T : UnityEngine.Object
{
// Make sure our path is not null
if(string.IsNullOrEmpty(projectPath))
{
return null;
}
// Get our resources path
string resourcesPath = ConvertToResourcesPath(projectPath);
if(!string.IsNullOrEmpty(resourcesPath))
{
// The replacedet is in a resources folder.
return Resources.Load<T>(resourcesPath);
}
#if UNITY_EDITOR
// We could not find it in resources so we just try the replacedetDatabase.
return UnityEditor.replacedetDatabase.LoadreplacedetAtPath<T>(projectPath);
#else
return null;
#endif
}
19
Source : SoftMaskable.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
void OnEnable()
{
// Register.
if (s_ActiveSoftMaskables == null)
{
s_ActiveSoftMaskables = new List<SoftMaskable>();
#if UNITY_EDITOR
UnityEditor.EditorApplication.update += UpdateSceneViewMatrixForShader;
s_GameVPId = Shader.PropertyToID("_GameVP");
s_GameTVPId = Shader.PropertyToID("_GameTVP");
#endif
s_SoftMaskTexId = Shader.PropertyToID("_SoftMaskTex");
s_StencilCompId = Shader.PropertyToID("_StencilComp");
s_MaskInteractionId = Shader.PropertyToID("_MaskInteraction");
}
s_ActiveSoftMaskables.Add(this);
var g = graphic;
if (g)
{
if (!g.material || g.material == Graphic.defaultGraphicMaterial)
{
g.material = s_DefaultMaterial ?? (s_DefaultMaterial = new Material(Resources.Load<Shader>("UI-Default-SoftMask")) { hideFlags = HideFlags.HideAndDontSave, });
}
g.SetMaterialDirty();
}
_softMask = null;
}
19
Source : SoftMaskableEditor.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
Material ModifyTMProMaterialPreset (Material baseMaterial, Shader shader, System.Action<Material> onCreatedMaterial)
{
string path = replacedetDatabase.GetreplacedetPath (baseMaterial);
string filename = Path.GetFileNameWithoutExtension (path) + " (" + typeof (SoftMaskable).Name + ")";
string defaultreplacedetPath = s_PiDefaultFontreplacedetPath.GetValue (null, new object [0]) as string;
Material mat = Resources.Load<Material> (defaultreplacedetPath + filename);
if (!mat)
{
mat = new Material (baseMaterial)
{
shaderKeywords = baseMaterial.shaderKeywords,
shader = shader,
};
onCreatedMaterial (mat);
replacedetDatabase.Createreplacedet (mat, Path.GetDirectoryName (path) + "/" + filename + ".mat");
EditorUtility.FocusProjectWindow ();
EditorGUIUtility.PingObject (mat);
}
else
{
mat.shader = shader;
}
EditorUtility.SetDirty (mat);
return mat;
}
19
Source : ResourceManager.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public void InitPool(string poolName, int size, PoolInflationType type = PoolInflationType.DOUBLE)
{
if (poolDict.ContainsKey(poolName))
{
return;
}
else
{
GameObject pb = Resources.Load<GameObject>(poolName);
if (pb == null)
{
Debug.LogError("[ResourceManager] Invalide prefab name for pooling :" + poolName);
return;
}
poolDict[poolName] = new Pool(poolName, pb, gameObject, size, type);
}
}
19
Source : LocalizationEditor.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
[MenuItem(MenuItemPath + "Configurate", false, 0)]
public static void Configurate()
{
var replacedet = Resources.Load<Localization>(LocalizationreplacedetName);
if (replacedet == null)
{
replacedet = CreateInstance<Localization>();
var replacedetPathAndName = replacedetDatabase.GenerateUniquereplacedetPath (LocalizationreplacedetPath);
replacedetDatabase.Createreplacedet(replacedet, replacedetPathAndName);
}
Selection.activeObject = replacedet;
}
19
Source : QuickActions.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
[Button(Name = "Story: Intro")]
[DisableInEditorMode]
public async void StoryIntro()
{
var intro = Resources.Load<Textreplacedet>("Stories/Intro");
LevelSelectionScreen.HighlightedLevelId = BuiltInData.TutorialLevelId;
var story = new Story(intro.text);
story.variablesState["IsBeginner"] = true;
await DialogueOverlay.Show(story);
LevelSelectionScreen.HighlightedLevelId = null;
}
19
Source : QuickActions.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
[Button(Name = "Story: Debug")]
[DisableInEditorMode]
public async void StoryDebug()
{
var text = Resources.Load<Textreplacedet>("Stories/Debug");
var story = new Story(text.text);
Resources.Unloadreplacedet(text);
await DialogueOverlay.Show(story);
}
19
Source : QuickActions.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
[Button(Name = "Story: Badge")]
[DisableInEditorMode]
public async void StoryBadge()
{
DialogueOverlay.CurrentBadge = new Badge
{
replacedle = "夏祭:一段",
description = "测试\n你好\n贵阳!\n11111111111",
type = BadgeType.Event,
metadata = new Dictionary<string, object>
{
{"imageUrl", "http://artifacts.cytoid.io/badges/sora1.jpg"}
}
};
var badge = Resources.Load<Textreplacedet>("Stories/Badge");
var story = new Story(badge.text);
await DialogueOverlay.Show(story);
}
19
Source : QuickActions.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
[Button(Name = "Story: Practice Mode")]
[DisableInEditorMode]
public async void StoryPracticeMode()
{
var text = Resources.Load<Textreplacedet>("Stories/PracticeMode");
var story = new Story(text.text);
Resources.Unloadreplacedet(text);
await DialogueOverlay.Show(story);
}
19
Source : HitSoundSelect.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public void Load()
{
if (select == null) select = GetComponentInChildren<CaretSelect>();
select.labels = new List<string>(HitSoundNameKeys.Select(it => it.Get()));
select.values = new List<string>(HitSounds);
var lp = Context.Player;
select.Select(lp.Settings.HitSound, false, false);
select.onSelect.RemoveAllListeners();
select.onSelect.AddListener((_, it) =>
{
lp.Settings.HitSound = it;
lp.SaveSettings();
if (it != "none")
{
var audioClip = Resources.Load<AudioClip>("Audio/HitSounds/" + it);
var hitSound = Context.AudioManager.Load("HitSound", audioClip, isResource: true);
hitSound.Play();
}
else
{
Context.AudioManager.Unload("HitSound");
}
});
}
19
Source : TrainingSelectionScreen.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public async UniTask ShowTrainingDialogue(bool isFirstMet)
{
var text = Resources.Load<Textreplacedet>("Stories/Training");
var story = new Story(text.text);
Resources.Unloadreplacedet(text);
story.variablesState["IsFirstMet"] = isFirstMet;
var shouldIntroduceMechanisms = Context.Player.ShouldOneShot("Training Mode: Should Introduce Mechanisms");
story.variablesState["ShouldIntroduceMechanisms"] = shouldIntroduceMechanisms;
story.variablesState["SignedIn"] = Context.OnlinePlayer.IsAuthenticated;
story.variablesState["Rating"] = Context.OnlinePlayer.LastProfile?.Rating ?? 0;
await DialogueOverlay.Show(story);
if (shouldIntroduceMechanisms && (int) story.variablesState["IntroducedMechanisms"] == 0)
{
Context.Player.ClearOneShot("Training Mode: Should Introduce Mechanisms");
}
}
19
Source : FontManager.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public void LoadFonts()
{
RegularFont = Resources.Load<Font>("Fonts/Nunito-Regular");
BoldFont = Resources.Load<Font>("Fonts/Nunito-Bold");
ExtraLightFont = Resources.Load<Font>("Fonts/Nunito-ExtraLight");
ExtraBoldFont = Resources.Load<Font>("Fonts/Nunito-ExtraBold");
RegularJpFont = Resources.Load<Font>("Fonts/Nunito-Regular-JP");
BoldJpFont = Resources.Load<Font>("Fonts/Nunito-Bold-JP");
ExtraLightJpFont = Resources.Load<Font>("Fonts/Nunito-ExtraLight-JP");
ExtraBoldJpFont = Resources.Load<Font>("Fonts/Nunito-ExtraBold-JP");
Loaded = true;
}
19
Source : GamePreparationScreen.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
private async void UpdateStartButton(bool justDownloadedLevel = false)
{
if (Level.IsLocal)
{
startButton.State = Context.Player.Settings.PlayRanked ? CircleButtonState.Start : CircleButtonState.Practice;
print(actionTabs.CurrentActionIndex + "/" + Context.Player.Settings.PlayRanked);
if (actionTabs.CurrentActionIndex < 0 && !Context.Player.Settings.PlayRanked && Context.Player.ShouldOneShot("Practice Mode Explanation"))
{
var text = Resources.Load<Textreplacedet>("Stories/PracticeMode");
var story = new Story(text.text);
Resources.Unloadreplacedet(text);
await DialogueOverlay.Show(story);
}
if (justDownloadedLevel && Level.Type == LevelType.User && Context.Player.ShouldOneShot("Community Level Offset Calibration"))
{
Dialog.PromptAlert("DIALOG_TUTORIAL_OFFSET_CALIBRATION".Get());
}
}
else
{
startButton.State = CircleButtonState.Download;
}
}
19
Source : MainMenuScreen.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public override async void OnScreenBecameActive()
{
base.OnScreenBecameActive();
//WebViewOverlay.Show();
if (StartupLogger.Instance != null)
{
StartupLogger.Instance.Dispose();
}
upperLeftOverlayImage.SetAlpha(Context.CharacterManager.GetActiveCharacterreplacedet().mainMenuUpperLeftOverlayAlpha);
overlayImage.SetAlpha(Context.CharacterManager.GetActiveCharacterreplacedet().mainMenuRightOverlayAlpha);
var levelCount = Context.LevelManager.LoadedLocalLevels.Count(it =>
(it.Value.Type == LevelType.User || it.Value.Type == LevelType.BuiltIn) && !BuiltInData.TrainingModeLevelIds.Contains(it.Value.Id));
freePlayText.text = "MAIN_LEVELS_LOADED".Get(levelCount);
freePlayText.transform.RebuildLayout();
ProfileWidget.Instance.Enter();
if (Context.CharacterManager.GetActiveCharacterreplacedet().mirrorLayout)
{
layout.anchorMin = new Vector2(0, 0.5f);
layout.anchorMax = new Vector2(0, 0.5f);
layout.pivot = new Vector2(0, 0.5f);
layout.ancreplaceddPosition = new Vector2(96, -90);
overlayHolder.SetLeft(280);
overlayHolder.SetRight(840);
overlayHolder.SetLocalScaleX(-2);
}
else
{
layout.anchorMin = new Vector2(1, 0.5f);
layout.anchorMax = new Vector2(1, 0.5f);
layout.pivot = new Vector2(1, 0.5f);
layout.ancreplaceddPosition = new Vector2(-96, -90);
overlayHolder.SetLeft(840);
overlayHolder.SetRight(280);
overlayHolder.SetLocalScaleX(2);
}
// Check new events
if (Context.IsOnline() && Context.OnlinePlayer.IsAuthenticated)
{
RestClient.GetArray<EventMeta>(new RequestHelper
{
Uri = $"{Context.ApiUrl}/events",
Headers = Context.OnlinePlayer.GetRequestHeaders(),
EnableDebug = true
}).AbortOnScreenBecameInactive(this).Then(events =>
{
var hasUnseenEvent = false;
foreach (var meta in events)
{
if (Context.Player.Settings.SeenEvents.Contains(meta.uid))
{
continue;
}
hasUnseenEvent = true;
}
if (hasUnseenEvent)
{
eventNotification.Show();
}
}).CatchRequestError(Debug.LogWarning);
}
if (Context.InitializationState.IsAfterFirstLaunch() && !LaunchedFirstLaunchDialogue)
{
LaunchedFirstLaunchDialogue = true;
var text = Resources.Load<Textreplacedet>("Stories/Intro");
LevelSelectionScreen.HighlightedLevelId = BuiltInData.TutorialLevelId;
var story = new Story(text.text);
Resources.Unloadreplacedet(text);
story.variablesState["IsBeginner"] = levelCount < 10;
await DialogueOverlay.Show(story);
LevelSelectionScreen.HighlightedLevelId = null;
Context.Player.ShouldOneShot("Android Migration Info");
}
else
{
if (DialogueOverlay.IsShown())
{
await UniTask.WaitUntil(() => !DialogueOverlay.IsShown());
}
if (Context.AndroidVersionCode >= 30 || Application.isEditor)
{
if (Context.Player.ShouldOneShot("Android Migration Info"))
{
await AndroidMigrationInfoOverlay.Show();
}
}
if (PromptCachedCharacterDataCleared)
{
PromptCachedCharacterDataCleared = false;
Dialog.PromptAlert("DIALOG_CACHED_CHARACTER_DATA_CLEARED".Get());
}
// Check announcement
if (!CheckedAnnouncement && Context.IsOnline())
{
RestClient.Get<Announcement>(new RequestHelper
{
Uri = $"{Context.ApiUrl}/announcements",
Headers = Context.OnlinePlayer.GetRequestHeaders(),
EnableDebug = true
}).Then(it =>
{
CheckedAnnouncement = true;
if (it.message != null)
{
Dialog.PromptAlert(it.message);
}
print($"local: {Application.version}, latest: {it.currentVersion}, min supported: {it.minSupportedVersion}");
var localVersion = new Version(Application.version);
var currentVersion = new Version(it.currentVersion);
var minSupportedVersion = new Version(it.minSupportedVersion);
if (localVersion < minSupportedVersion)
{
Dialog.PromptUnclosable("DIALOG_UPDATE_REQUIRED".Get(),
() => Application.OpenURL(Context.StoreUrl));
return;
}
if (localVersion < currentVersion)
{
Dialog.Prompt("DIALOG_UPDATE_AVAILABLE_X_Y".Get(currentVersion, localVersion),
() => Application.OpenURL(Context.StoreUrl));
}
}).CatchRequestError(Debug.LogError);
}
}
}
19
Source : BadgeDisplay.cs
with GNU General Public License v3.0
from Cytoid
with GNU General Public License v3.0
from Cytoid
public void SetModel(Badge badge)
{
this.badge = badge;
LoadImage();
graphicRaycaster.enabled = interactable;
if (interactable) onPointerClick.SetListener(_ =>
{
DialogueOverlay.CurrentBadge = badge;
var story = new Story(Resources.Load<Textreplacedet>("Stories/Badge").text);
DialogueOverlay.Show(story);
});
}
19
Source : SteamVR_Render.cs
with MIT License
from dag10
with MIT License
from dag10
void Awake()
{
if (externalCamera == null && System.IO.File.Exists(externalCameraConfigPath))
{
var prefab = Resources.Load<GameObject>("SteamVR_ExternalCamera");
var instance = Instantiate(prefab);
instance.gameObject.name = "External Camera";
externalCamera = instance.transform.GetChild(0).GetComponent<SteamVR_ExternalCamera>();
externalCamera.configPath = externalCameraConfigPath;
externalCamera.ReadConfig();
}
}
19
Source : TestGameMain.cs
with Apache License 2.0
from DarkLop
with Apache License 2.0
from DarkLop
private void Start()
{
// 实例化一个测试Handler与Listener事件的对象
GameObject prefab = Resources.Load<GameObject>(m_PrefabPath + "TestHandlerAndListener");
GameObject handler = GameObject.Instantiate<GameObject>(prefab);
handler.transform.SetParent(transform);
// 注册初始化事件Controller
MessageCenter.RegisterController<TestGameInitController>(TestEventNames.TestGameInit);
// 发送初始化事件
this.SendByMessageCenter(TestEventNames.TestGameInit);
}
19
Source : ConfigLoader.cs
with Apache License 2.0
from DarkLop
with Apache License 2.0
from DarkLop
internal static byte[] LoadConfigBytesInternal(ConfigFile config)
{
string path = Path.Combine(rootDirectory, config.relativePath);
byte[] bytes;
switch (config.loadType)
{
// 使用Resources读取Bytes
case ConfigFile.LoadType.Resources:
{
Textreplacedet replacedet = Resources.Load<Textreplacedet>(path);
if (replacedet == null)
{
Debug.LogError("Resources: Config is not found. Path: " + path);
return null;
}
bytes = replacedet.bytes;
break;
}
// 使用WWW从本地读取Bytes
case ConfigFile.LoadType.WWW:
{
LoadConfigBytesFromWWW(path, false, out bytes);
break;
}
// 使用WWW从网络读取Bytes
case ConfigFile.LoadType.WWWInternet:
{
LoadConfigBytesFromWWW(path, true, out bytes);
break;
}
// 使用Resources读取Config所在replacedetBundle,从replacedetBundle中读取Bytes
case ConfigFile.LoadType.Resources | ConfigFile.LoadType.replacedetBundle:
{
replacedetBundle bundle = Resources.Load<replacedetBundle>(path);
if (bundle == null)
{
Debug.LogError("Resources: replacedetBundle is not found. Path: " + path);
return null;
}
LoadConfigBytesFromreplacedetBundle(bundle, config.pathInreplacedetBundle, out bytes);
bundle.Unload(false);
break;
}
// 使用WWW读取本地Config所在replacedetBundle,从replacedetBundle中读取Bytes
case ConfigFile.LoadType.WWW | ConfigFile.LoadType.replacedetBundle:
{
replacedetBundle bundle = LoadreplacedetBundleFromWWW(path, false);
if (bundle == null)
{
Debug.LogError("WWW: replacedetBundle is not found. Path: " + path);
return null;
}
LoadConfigBytesFromreplacedetBundle(bundle, config.pathInreplacedetBundle, out bytes);
bundle.Unload(false);
break;
}
// 使用WWW读取网络Config所在replacedetBundle,从replacedetBundle中读取Bytes
case ConfigFile.LoadType.WWWInternet | ConfigFile.LoadType.replacedetBundle:
{
replacedetBundle bundle = LoadreplacedetBundleFromWWW(path, true);
if (bundle == null)
{
Debug.LogError("WWWInternet: replacedetBundle is not found. Path: " + path);
return null;
}
LoadConfigBytesFromreplacedetBundle(bundle, config.pathInreplacedetBundle, out bytes);
bundle.Unload(false);
break;
}
// 不支持的读取类型,抛出异常
default:
throw new NotSupportedException("Load Type '" + config.loadType.ToString() + "' is not supported.");
}
return bytes;
}
19
Source : MapGraph.cs
with Apache License 2.0
from DarkLop
with Apache License 2.0
from DarkLop
private MapObject LoadMapObjectPrefab(string prefabName)
{
if (string.IsNullOrEmpty(prefabName))
{
Debug.LogError("MapGraph -> LoadMapObjectPrefab ERROR!!" +
" Prefab name is null or empty.");
return null;
}
// TODO ResourcesManager 读取prefab
MapObject prefab = Resources.Load<MapObject>(prefabName);
return prefab;
}
19
Source : ViewDictionary.cs
with Apache License 2.0
from DarkLop
with Apache License 2.0
from DarkLop
protected virtual GameObject LoadPrefab(string path)
{
return Resources.Load<GameObject>(path);
}
19
Source : ResourceLoader.cs
with MIT License
from DonnYep
with MIT License
from DonnYep
public T Loadreplacedet<T>(replacedetInfo info) where T : UnityEngine.Object
{
var replacedet = Resources.Load<T>(info.replacedetPath);
if (replacedet == null)
{
throw new ArgumentNullException($"Resources文件夹中不存在资源 {info.replacedetPath}!");
}
return replacedet;
}
19
Source : ServerHandle.cs
with MIT License
from Filigrani
with MIT License
from Filigrani
private static GearItem GetGearItemPrefab(string name) => Resources.Load(name).Cast<GameObject>().GetComponent<GearItem>();
19
Source : ServerHandle.cs
with MIT License
from Filigrani
with MIT License
from Filigrani
private static GameObject GetGearItemObject(string name) => Resources.Load(name).Cast<GameObject>();
19
Source : GvrAudioSoundfield.cs
with MIT License
from harshitjuneja
with MIT License
from harshitjuneja
void Awake () {
// Route the source output to |GvrAudioMixer|.
AudioMixer mixer = (Resources.Load("GvrAudioMixer") as AudioMixer);
if(mixer == null) {
Debug.LogError("GVRAudioMixer could not be found in Resources. Make sure that the GVR SDK" +
"Unity package is imported properly.");
return;
}
audioSources = new AudioSource[GvrAudio.numFoaChannels / 2];
for (int channelSet = 0; channelSet < audioSources.Length; ++channelSet) {
GameObject channelSetObject = new GameObject("Channel Set " + channelSet);
channelSetObject.transform.parent = gameObject.transform;
channelSetObject.hideFlags = HideFlags.HideAndDontSave;
audioSources[channelSet] = channelSetObject.AddComponent<AudioSource>();
audioSources[channelSet].enabled = false;
audioSources[channelSet].playOnAwake = false;
audioSources[channelSet].bypreplacedReverbZones = true;
audioSources[channelSet].dopplerLevel = 0.0f;
audioSources[channelSet].spatialBlend = 0.0f;
audioSources[channelSet].outputAudioMixerGroup = mixer.FindMatchingGroups("Master")[0];
}
OnValidate();
}
19
Source : GvrAudioSource.cs
with MIT License
from harshitjuneja
with MIT License
from harshitjuneja
void Awake () {
if (audioSource == null) {
// Ensure the audio source gets created once.
audioSource = gameObject.AddComponent<AudioSource>();
}
audioSource.enabled = false;
audioSource.hideFlags = HideFlags.HideInInspector | HideFlags.HideAndDontSave;
audioSource.playOnAwake = false;
audioSource.bypreplacedReverbZones = true;
audioSource.spatialBlend = 1.0f;
OnValidate();
// Route the source output to |GvrAudioMixer|.
AudioMixer mixer = (Resources.Load("GvrAudioMixer") as AudioMixer);
if(mixer != null) {
audioSource.outputAudioMixerGroup = mixer.FindMatchingGroups("Master")[0];
} else {
Debug.LogError("GVRAudioMixer could not be found in Resources. Make sure that the GVR SDK " +
"Unity package is imported properly.");
}
}
19
Source : EditorScriptableSingleton.cs
with MIT License
from Hello-Meow
with MIT License
from Hello-Meow
private static void GetInstance()
{
if (_instance == null)
_instance = Resources.Load<T>(typeof(T).Name);
if (_instance == null)
{
_instance = CreateInstance<T>();
if (Application.isEditor)
Createreplacedet();
}
}
19
Source : ScriptableSingleton.cs
with MIT License
from Hello-Meow
with MIT License
from Hello-Meow
protected static void GetInstance()
{
if (_instance == null)
_instance = Resources.Load<T>(typeof(T).Name);
if (_instance == null)
{
_instance = CreateInstance<T>();
if (Application.isEditor)
Createreplacedet();
}
}
19
Source : GameTopBarController.cs
with MIT License
from iMemento
with MIT License
from iMemento
public static GameTopBarController Create(RectTransform parent, Vector2 localPos)
{
// todo:
// set correct ui prefab path
var prefab = Resources.Load("todo: path to load") as GameObject;
var go = Instantiate(prefab);
var p = go.GetComponent<GameTopBarPresenter>();
var ret = go.GetComponent<GameTopBarController>();
p.SetParentAndPostion(parent, localPos);
ret.SetPresenter(p);
return ret;
}
19
Source : MainController.cs
with MIT License
from iMemento
with MIT License
from iMemento
public static MainController Create(RectTransform parent, Vector2 localPos)
{
// todo:
// set correct ui prefab path
var prefab = Resources.Load("todo: path to load") as GameObject;
var go = Instantiate(prefab);
var p = go.GetComponent<MainPresenter>();
var ret = go.GetComponent<MainController>();
p.SetParentAndPostion(parent, localPos);
ret.SetPresenter(p);
return ret;
}
19
Source : ChatController.cs
with MIT License
from iMemento
with MIT License
from iMemento
public static ChatController Create(RectTransform parent, Vector2 localPos)
{
// todo:
// set correct ui prefab path
var prefab = Resources.Load("todo: path to load") as GameObject;
var go = Instantiate(prefab);
var p = go.GetComponent<ChatPresenter>();
var ret = go.GetComponent<ChatController>();
p.SetParentAndPostion(parent, localPos);
ret.SetPresenter(p);
return ret;
}
19
Source : TemplateController.cs
with MIT License
from iMemento
with MIT License
from iMemento
public static TemplateController Create(RectTransform parent, Vector2 localPos)
{
// todo:
// set correct ui prefab path
var prefab = Resources.Load("todo: path to load") as GameObject;
var go = Instantiate(prefab);
var p = go.GetComponent<TemplatePresenter>();
var ret = go.GetComponent<TemplateController>();
p.SetParentAndPostion(parent, localPos);
return ret;
}
19
Source : MainUIMenuManager.cs
with MIT License
from iMemento
with MIT License
from iMemento
private MenuBaseController Create(MenuType menu)
{
var prefab = Resources.Load(menu.Path) as GameObject;
var go = GameObject.Instantiate(prefab);
var rt = go.GetComponent<RectTransform>();
rt.SetParent(MainCanvas.Root.RectTransform);
rt.offsetMin = new Vector2(0f, 0f);
rt.offsetMax = new Vector2(0f, -140f);
return go.GetComponent<MenuBaseController>();
}
19
Source : InputSetupEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
protected override void ShowBodyFields()
{
GUILayout.Space(10);
ShowEnableUniversalInterfaceToggle();
GUILayout.Space(20);
GUILayout.BeginHorizontal();
GUILayout.Label("Choose Input Device", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
// sets the device
ShowDeviceOptions();
GUILayout.EndHorizontal();
//sets the controller side for the training examples whether left right or both
GUI.changed = false;
GUILayout.Space(20);
GUILayout.Label("Teach The Machine Controls", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"));
GUILayout.Space(10);
// if the input is from vr controllers or hands show choice for training examples related buttons to be on the left hand or right hand or both
/* if (m_InputSetUp.device == IMLInputDevices.VRControllers)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Hand", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
m_InputSetUp.trainingHand = (IMLSides)EditorGUILayout.EnumPopup(m_InputSetUp.trainingHand);
GUILayout.EndHorizontal();
GUILayout.Space(10);
}
if (GUI.changed)
{
m_InputSetUp.OnHandChange(m_InputSetUp.trainingHand, "trainingSide");
EditorUtility.SetDirty(m_InputSetUp);
}8/
// choose delete last button
GUI.changed = false;
// set button choice for delete last
/* // delete last
Debug.Log(m_InputSetUp);
GUILayout.BeginHorizontal();
GUILayout.Label("Delete Last", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
ShowButtonChoice(m_InputSetUp.DeleteLast.buttonName, m_InputSetUp.deleteLastButtonNo, out m_InputSetUp.deleteLastButtonNo, m_InputSetUp.deleteLastButtonTT, out m_InputSetUp.deleteLastButtonTT);
GUILayout.EndHorizontal();*/
// choose delete all button
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("Delete All", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
ShowButtonChoice(m_InputSetUp.deleteAllName, deleteAllButtonNo, out deleteAllButtonNo, deleteAllButtonTT, out deleteAllButtonTT);
GUILayout.EndHorizontal();
// record one
/* GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("Record One", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
ShowButtonChoice(m_InputSetUp.recordOneName, m_InputSetUp.recordOneButtonNo, out m_InputSetUp.recordOneButtonNo, m_InputSetUp.recordOneButtonTT, out m_InputSetUp.recordOneButtonTT);
GUILayout.EndHorizontal();
// choose toggle record button
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("Toggle Record", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
ShowButtonChoice(m_InputSetUp.toggleRecordName, m_InputSetUp.toggleRecordButtonNo, out m_InputSetUp.toggleRecordButtonNo, m_InputSetUp.toggleRecordButtonTT, out m_InputSetUp.toggleRecordButtonTT);
GUILayout.EndHorizontal();
GUILayout.Space(30);
GUILayout.Label("Machine Learning System Controls", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"));
GUILayout.Space(10);
// sets the controller side for the training
GUI.changed = false;
// if the input is from vr controllers or hands show choice for training examples related buttons to be on the left hand or right hand or both
/* if (m_InputSetUp.device == IMLInputDevices.VRControllers)
{
GUILayout.BeginHorizontal();
GUILayout.Label("Hand", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
m_InputSetUp.mlsHand = (IMLSides)EditorGUILayout.EnumPopup(m_InputSetUp.mlsHand);
GUILayout.EndHorizontal();
}
if (GUI.changed)
{
m_InputSetUp.OnHandChange(m_InputSetUp.mlsHand, "mlsSide");
EditorUtility.SetDirty(m_InputSetUp);
}*/
// sets the button for training
/* GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("Train", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
ShowButtonChoice(m_InputSetUp.trainName, m_InputSetUp.trainButtonNo, out m_InputSetUp.trainButtonNo, m_InputSetUp.trainButtonTT, out m_InputSetUp.trainButtonTT);
GUILayout.EndHorizontal();
// sets the button for running
GUILayout.Space(10);
GUILayout.BeginHorizontal();
GUILayout.Label("Toggle Run", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Port Label"), GUILayout.MinWidth(200));
ShowButtonChoice(m_InputSetUp.toggleRunName, m_InputSetUp.toggleRunButtonNo, out m_InputSetUp.toggleRunButtonNo, m_InputSetUp.toggleRunButtonTT, out m_InputSetUp.toggleRunButtonTT);
GUILayout.EndHorizontal();*/
}
19
Source : IMLNodeEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
public override void OnHeaderGUI()
{
if(EditorWindow.focusedWindow != null)
{
/*if (!EditorWindow.focusedWindow.ToString().Contains("XNodeEditor.NodeEditorWindow") && lastWindow != EditorWindow.focusedWindow.ToString())
{
Resources.UnloadUnusedreplacedets();
lastWindow = EditorWindow.focusedWindow.ToString();
}*/
}
// Load node skin
if (m_NodeSkin == null)
m_NodeSkin = Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin");
IMLGraph m_IMLGraph = target.graph as IMLGraph;
if (!m_IMLGraph.IsGraphRunning/* && Event.current.type == EventType.Repaint*/)
{
HeaderRect.height = 500;
HeaderRect.width = 800;
GUILayout.BeginArea(HeaderRect);
GUILayout.Label("Graph not in this scene", m_NodeSkin.GetStyle("Header"), GUILayout.MinWidth(200));
GUILayout.Label("Please open scene with this graph in or add to this scene", m_NodeSkin.GetStyle("Header Small"), GUILayout.MinWidth(200));
GUILayout.EndArea();
} else
{
// If we want to reskin the node
if (UIReskinAuto)
{
// Get references
m_IMLNode = target as IMLNode;
m_IMLNodeSerialized = new SerializedObject(m_IMLNode);
NodeWidth = this.GetWidth();
// Draws header with live subreplacedle if input connected - only data type nodes
string name = m_IMLNode.GetType().ToString();
//find out if the node is a data type node
if (name.Contains("DataType"))
NodeSubreplacedle = m_IMLNode.GetInputNodesConnected("m_In")!=null ? "LIVE" : null;
// Initialise header background Rects
InitHeaderRects();
NodeColor = GetColorTextureFromHexString("#3A3B5B");
if (Event.current.type == EventType.Repaint)
{
// Draw over xnode header tint
//GUI.DrawTexture(new Rect(6, 6, GetWidth() - 12, 24), NodeColor);
// Draw line below header
GUI.DrawTexture(LineBelowHeader, GetColorTextureFromHexString("#888EF7"));
}
//Display Node name
if (String.IsNullOrEmpty(NodeName))
NodeName = target.GetType().Name;
GUILayout.BeginArea(HeaderRect);
GUILayout.Label(NodeName, m_NodeSkin.GetStyle("Header"), GUILayout.MinWidth(NodeWidth - 10));
//if(!String.IsNullOrEmpty(NodeSubreplacedle)) this causes the GUI to stutter
//commented out nodeid in subreplacedle for debugging
GUILayout.Label(NodeSubreplacedle, m_NodeSkin.GetStyle("Header Small"), GUILayout.MinWidth(NodeWidth - 10));
GUILayout.EndArea();
GUILayout.Label("", GUILayout.MinHeight(60));
}
// If we want to keep xNode's default skin
else
{
base.OnHeaderGUI();
}
}
}
19
Source : IMLNodeEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
public virtual void ShowHelpButton(Rect m_HelpRect)
{
if (m_NodeSkin == null)
m_NodeSkin = Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin");
m_HelpRect.x = m_HelpRect.x + 20;
m_HelpRect.y = m_HelpRect.y + 10;
m_HelpRect.width = m_HelpRect.width - 40;
GUILayout.BeginArea(m_HelpRect);
GUILayout.BeginHorizontal();
GUILayout.Label("");
if (GUILayout.Button(new GUIContent("Help"), m_NodeSkin.GetStyle("Help Button")))
{
if (showHelp)
{
showHelp = false;
}
else
{
showHelp = true;
}
}
GUILayout.EndHorizontal();
GUILayout.EndArea();
}
19
Source : IMLNodeEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
public void DataInToggle(Boolean dataIn, Rect m_InnerBodyRect, Rect m_BodyRect)
{
// Load node skin
if (m_NodeSkin == null)
m_NodeSkin = Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin");
GUILayout.Space(60);
GUILayout.BeginArea(m_BodyRect);
GUILayout.Space(30);
//if data coming in green if not red toggle
if (dataIn)
{
DrawFeatureValueTogglesAndLabels(m_NodeSkin.GetStyle("Green Toggle"));
}
else
{
DrawFeatureValueTogglesAndLabels(m_NodeSkin.GetStyle("Red Toggle"));
}
GUILayout.EndArea();
}
19
Source : TextNoteEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
public override void OnHeaderGUI()
{
// Get reference to the current node
m_TextNote = (target as TextNote);
// Initialise header background Rects
InitHeaderRects();
NodeColor = GetColorTextureFromHexString("#3A3B5B");
// Set node width
NodeWidth = 200;
if (Event.current.type == EventType.Layout)
{
// Draw header background Rect
GUI.DrawTexture(HeaderRect, NodeColor);
// Draw line below header
GUI.DrawTexture(LineBelowHeader, GetColorTextureFromHexString("#F6C46F"));
}
//Display Node name
GUILayout.BeginArea(HeaderRect);
GUILayout.Space(10);
GUILayout.Label("TEXT NOTE", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Header"), GUILayout.MinWidth(NodeWidth - 10));
GUILayout.EndArea();
GUILayout.Label("", GUILayout.MinHeight(60));
}
19
Source : TrainingExamplesNodeEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
protected string ShowRecordExamplesButton()
{
string nameButton = "";
//// Only run button logic when there are features to extract from
if (m_TrainingExamplesNode.CollectingData)
{
nameButton = "stop recording";
}
else
{
nameButton = "start recording";
}
if (!m_TrainingExamplesNode.canCollect)
{
GUI.enabled = false;
}
if (GUILayout.Button("Record Data", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Record Button")))
{
IMLEventDispatcher.ToggleRecordCallback(m_TrainingExamplesNode.id);
}
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
buttonTipHelper = true;
//TooltipText = m_TrainingExamplesNode.TrainingTips.BodyTooltip.Tips[3];
}
else if (Event.current.type == EventType.MouseMove && !GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
buttonTip = false;
}
if (Event.current.type == EventType.Layout && buttonTipHelper)
{
buttonTip = true;
buttonTipHelper = false;
}
// Always enable it back at the end
GUI.enabled = true;
return nameButton;
}
19
Source : TrainingExamplesNodeEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
protected void SetDropdownStyle()
{
GUI.skin = Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin");
GUIStyle myFoldoutStyle = new GUIStyle(EditorStyles.foldout);
Color myStyleColor = Color.white;
myFoldoutStyle.fontStyle = FontStyle.Bold;
myFoldoutStyle.normal.textColor = myStyleColor;
myFoldoutStyle.onNormal.textColor = myStyleColor;
myFoldoutStyle.hover.textColor = myStyleColor;
myFoldoutStyle.onHover.textColor = myStyleColor;
myFoldoutStyle.focused.textColor = myStyleColor;
myFoldoutStyle.onFocused.textColor = myStyleColor;
myFoldoutStyle.active.textColor = myStyleColor;
myFoldoutStyle.onActive.textColor = myStyleColor;
myFoldoutStyle.fontStyle = FontStyle.Bold;
myFoldoutStyle.normal.textColor = myStyleColor;
myFoldoutStyle.fontStyle = Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("scrollview").fontStyle;
m_ShowTrainingDataDropdown = EditorGUILayout.Foldout(m_ShowTrainingDataDropdown, "View Training Pairs", myFoldoutStyle);
}
19
Source : TrainingExamplesNodeEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
private void ShowButtons()
{
int offset = 1;
GUILayout.Space(20);
// show record ONE example button
//if it is a single training examples node
if (m_TrainingExamplesNode.ModeOfCollection == TrainingExamplesNode.CollectionMode.SingleExample)
{
GUILayout.BeginHorizontal();
// Draw port
IMLNodeEditor.PortField(m_ButtonPortLabel, m_ButtonPortRecordOneInput, m_NodeSkin.GetStyle("Port Label"), GUILayout.MaxWidth(10));
GUILayout.Space(offset);
if (GUILayout.Button(new GUIContent(""), Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Record One Button")))
{
IMLEventDispatcher.RecordOneCallback?.Invoke(m_TrainingExamplesNode.id);
}
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.Space(10);
GUILayout.Label("record one example", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Record Button Green"));
GUILayout.Label("");
GUILayout.EndHorizontal();
//button tooltip code
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition)
&& m_TrainingExamplesNode.tooltips != null
&& m_TrainingExamplesNode.tooltips.BodyTooltip != null
&& m_TrainingExamplesNode.tooltips.BodyTooltip.Tips != null
&& m_TrainingExamplesNode.tooltips.BodyTooltip.Tips.Length > 2)
{
buttonTipHelper = true;
TooltipText = m_TrainingExamplesNode.tooltips.BodyTooltip.Tips[2];
}
else if (Event.current.type == EventType.MouseMove && !GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
buttonTip = false;
}
if (Event.current.type == EventType.Layout && buttonTipHelper)
{
buttonTip = true;
buttonTipHelper = false;
}
GUILayout.EndHorizontal();
}
// show record examples button
GUILayout.Space(15);
GUILayout.BeginHorizontal();
// Draw port
IMLNodeEditor.PortField(m_ButtonPortLabel, m_ButtonPortToggleRecord, m_NodeSkin.GetStyle("Port Label"), GUILayout.MaxWidth(10));
GUILayout.Space(offset);
// draw record button
string recordNameButton = ShowRecordExamplesButton();
GUILayout.Space(5);
// draw record label
GUILayout.BeginHorizontal();
GUILayout.Space(10);
GUILayout.Label(recordNameButton, Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Record Button Green"));
GUILayout.Label("");
GUILayout.EndHorizontal();
GUILayout.EndHorizontal();
// show delete all button
GUILayout.Space(15);
GUILayout.BeginHorizontal();
//GUILayout.Space(spacing);
// Draw port
IMLNodeEditor.PortField(m_ButtonPortLabel, m_ButtonPortDeleteExamples, m_NodeSkin.GetStyle("Port Label"), GUILayout.MaxWidth(10));
GUILayout.Space(offset);
// draw delete all button
ShowClearAllExamplesButton();
GUILayout.Space(5);
GUILayout.BeginHorizontal();
GUILayout.Space(10);
GUILayout.Label("delete all recordings", Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Delete Button Pink"));
GUILayout.Label("");
GUILayout.EndHorizontal();
GUILayout.EndHorizontal();
GUILayout.Space(20);
GUILayout.BeginHorizontal();
GUILayout.Space(15);
if (m_TrainingExamplesNode.ModeOfCollection == TrainingExamplesNode.CollectionMode.SingleExample)
{
GUILayout.Label("Number of training pairs: " + m_TrainingExamplesNode.TrainingExamplesVector.Count, Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Header Small"));
}
else{
GUILayout.Label("Number of training examples: " + m_TrainingExamplesNode.TrainingSeriesCollection.Count, Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Header Small"));
}
GUILayout.EndHorizontal();
}
19
Source : MLSystemEditor.cs
with MIT License
from Interactml
with MIT License
from Interactml
protected virtual void RunModelButton()
{
string nameButton = "";
if (m_MLSystem.Running)
{
nameButton = "STOP";
}
else
{
if (m_MLSystem.TrainingType == IMLSpecifications.TrainingSetType.SeriesTrainingExamples)
nameButton = "Populate";
else
nameButton = "Run";
}
// If rapidlib reference is null we draw a disabled button
if ((m_MLSystem.Model == null || m_MLSystem.Model.ModelAddress == (IntPtr)0 || m_MLSystem.Training || m_MLSystem.Untrained || !m_MLSystem.matchLiveDataInputs || !m_MLSystem.matchVectorLength) && !m_MLSystem.Running)
{
/* Debug.Log(m_MLSystem.Model == null);
Debug.Log(m_MLSystem.Model.ModelAddress != (IntPtr)0);
Debug.Log(m_MLSystem.Training);
Debug.Log(m_MLSystem.Untrained);
Debug.Log(!m_MLSystem.matchLiveDataInputs);
Debug.Log(!m_MLSystem.matchVectorLength);*/
// Disable button if model is Trainig OR Untrained
GUI.enabled = false;
}
else
{
GUI.enabled = true;
}
if (GUILayout.Button(nameButton, Resources.Load<GUISkin>("GUIStyles/InteractMLGUISkin").GetStyle("Run")))
{
IMLEventDispatcher.ToggleRunCallback(m_MLSystem.id);
}
if (GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
buttonTipHelper = true;
if (GUI.enabled)
{
// Check for null
if (m_MLSystem.tooltips != null && m_MLSystem.tooltips.BodyTooltip != null && m_MLSystem.tooltips.BodyTooltip.Tips != null)
TooltipText = m_MLSystem.tooltips.BodyTooltip.Tips[2];
}
else
{
// Check for null
if (m_MLSystem.tooltips != null && m_MLSystem.tooltips.BodyTooltip != null && m_MLSystem.tooltips.BodyTooltip.Tips != null)
TooltipText = m_MLSystem.tooltips.BodyTooltip.Error[1];
}
}
else if (Event.current.type == EventType.MouseMove && !GUILayoutUtility.GetLastRect().Contains(Event.current.mousePosition))
{
buttonTip = false;
}
GUI.enabled = true;
if (Event.current.type == EventType.Layout && buttonTipHelper)
{
buttonTip = true;
buttonTipHelper = false;
}
}
See More Examples